微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

当我单击“提交”按钮时,Flutter FA Stepper将获取所有数据

如何解决当我单击“提交”按钮时,Flutter FA Stepper将获取所有数据

我正在使用此库FA Stepper the link for the library(fa_stepper) 我有5个步骤,每个步骤都有8-10个字段。在每个步骤上,用户单击``继续''按钮并转到下一步。如果我想在整个步骤中创建和维护对象,应该怎么做?就像在最后一步的最后,我需要获取具有键值对的最终JsonObject。

这就是我所做的。

List<FAStep> get mySteps => [

FAStep(
    // Title of the Step
    title: //Text("Step 1"),Column(
      children: <Widget>[
        Icon(
          Icons.account_Box,color: Colors.grey,size: 24,),Padding(
          padding: const EdgeInsets.only(top: 5),child: Text("Step01"),)
      ],// Content,it can be any widget here. Using basic Text for this example,subtitle: Text("subT"),content: Form(
      key: formKeys[0],child: First()
    ),isActive: true),//2
FAStep(
    title: Column(children: <Widget>[
      Icon(
        Icons.account_Box,Padding(
        padding: const EdgeInsets.only(top: 5),child: Text("Step02"),)
    ]),content:Form(
      key: formKeys[1],child: Second()
    ),//Text("World!"),// You can change the style of the step icon i.e number,editing,etc.
    state: FAStepstate.complete,//FAStepState.complete,//3.
FAStep(
    title: Column(children: <Widget>[
      Icon(
        Icons.account_Box,child: Text("Step03"),content:Form(
      key: formKeys[2],child: Third()
    ),// Text("Hello World!"),//4
FAStep(
    title: Column(children: <Widget>[
      Icon(
        Icons.account_Box,child: Text("Step04"),content:Form(
      key: formKeys[3],child: Fourth()
    ),// Text("Hello World 4!"),

];

class First extends StatefulWidget {
 @override
_FirstState createState() => _FirstState();
}

class _FirstState extends State<First> {
static var _focusNode =  FocusNode();
  TextEditingController textEditingController = TextEditingController();

 @override
void initState() {
super.initState();
_focusNode.addListener(() {
  print('Has focus: $_focusNode.hasFocus');
});

}

@override
Widget build(BuildContext context) {
return Column(
        children: <Widget>[
           TextFormField(
             controller:textEditingController,focusNode: _focusNode,keyboardType: TextInputType.text,autocorrect: false,onChanged: (String value) {
              print(value);
            },onSaved: (String value) {
              print(value);
            },maxLines: 1,//initialValue: 'Aseem Wangoo',validator: (value) {
              if (value.isEmpty || value.length < 1) {
                return 'Please enter name';
              }
            },decoration:  Inputdecoration(
                labelText: 'Enter your name',hintText: 'Enter a name',//filled: true,icon: const Icon(Icons.person),labelStyle:
                 TextStyle(decorationStyle: TextdecorationStyle.solid)),],);

} }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。