【问题标题】:Navigte back with params in flutter using GetX and accessing the results in the previous page使用 GetX 在颤振中返回参数并访问上一页中的结果
【发布时间】:2021-12-01 02:21:58
【问题描述】:

我正在创建一个 Flutter 应用程序,它允许用户在从联系人列表导航返回之前选择一个联系人并显示所选联系人。

 class ContactsList extends StatelessWidget {
      final List<AppContact> contacts;
      Function() reloadContacts;
      ContactsList({Key? key, required this.contacts, required this.reloadContacts})
          : super(key: key);
      @override
      Widget build(BuildContext context) {
        return Expanded(
          child: ListView.builder(
            shrinkWrap: true,
            itemCount: contacts.length,
            itemBuilder: (context, index) {
              AppContact contact = contacts[index];
    
              return ListTile(
                  onTap: () {
                    Get.back(result:contact.info.phones!.elementAt(0).value!);
                  },
                  title: Text(contact.info.displayName!),
                  subtitle: Text(contact.info.phones!.length > 0
                      ? contact.info.phones!.elementAt(0).value!
                      : ''),
                  leading: ContactAvatar(contact, 36));
            },
          ),
        );
      }
    }

【问题讨论】:

    标签: flutter dart navigation contacts flutter-getx


    【解决方案1】:

    我不确定你是否想要这个,但是你可以使用 await 关键字和导航功能。

    例如;

    final data = await Get.to(Payment());
    

    如果您想了解一些有关使用 getx 进行导航的信息,您可以访问documentation

    【讨论】:

      猜你喜欢
      • 2021-09-12
      • 2022-01-05
      • 2021-10-10
      • 2021-03-03
      • 1970-01-01
      • 2020-02-07
      • 2021-10-05
      • 2021-03-02
      • 2020-01-10
      相关资源
      最近更新 更多