【问题标题】:How the get specific user details from the user id in flutterFlutter中如何从用户ID中获取特定的用户详细信息
【发布时间】:2021-08-15 05:57:10
【问题描述】:

我有选民 id api,我想显示从文本字段输入的显示特定选民详细信息,例如,如果用户输入文本字段选民姓名和选民在下一页特定选民详细信息中显示所有详细信息

【问题讨论】:

标签: flutter dart


【解决方案1】:

1. 创建一个TextEditController,这是一个可以链接到输入字段以获取其中文本的类(最好将其放在StatefulWidget中,这样我们可以处理它):

// Define a custom Form widget.
class MyCustomForm extends StatefulWidget {
  const MyCustomForm({Key? key}) : super(key: key);

  @override
  _MyCustomFormState createState() => _MyCustomFormState();
}

// Define a corresponding State class.
// This class holds the data related to the Form.
class _MyCustomFormState extends State<MyCustomForm> {
  // Create a text controller and use it to retrieve the current value
  // of the TextField.
  final myController = TextEditingController();

  @override
  void dispose() {
    // Clean up the controller when the widget is disposed.
    myController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    // Fill this out in the next step.
  }
}

2. 将控制器与您的文本字段链接:

TextField(
  controller: myController,
);

3. 获取文本:

myController.text

4. 实现 Navigator 类,按照官方文档发送数据作为下一页的参数:

【讨论】:

  • 但我想通过 APi 实现
  • 我有选民 id api,我想显示从文本字段输入的显示特定选民详细信息,例如,如果用户在文本字段中输入选民姓名并且选民在下一页特定的 voteruser 详细信息中显示所有详细信息跨度>
  • 请先生提供一些我可以从该代码中理解的代码
猜你喜欢
  • 2021-08-27
  • 2018-05-18
  • 1970-01-01
  • 1970-01-01
  • 2021-04-03
  • 1970-01-01
  • 2017-01-28
  • 1970-01-01
  • 2014-11-08
相关资源
最近更新 更多