小编Dar*_*da0的帖子

在Streambuilder中使用TextField

我们如何在StreamBuilder中添加TextField?我有一个TextField / TextFormField作为StreamBuilder或FutureBuilder的构建器函数内的小部件之一,每当我们尝试与文本字段进行交互时,它只会刷新整个构建器小部件并再次调用流/未来。

body: StreamBuilder(
      stream: getClientProfile().snapshots(),
      builder: (context, snapshot) {
        if (snapshot.connectionState == ConnectionState.active) {
          print(snapshot.data.data);
          Client tempClient = Client.from(snapshot.data);
          print('details = ${tempClient.representative.email} ${tempClient
              .address.location} ${tempClient.businessDescription}');
          return Container(
            child: Column(
              children: <Widget>[
                TextFormField(

                )
              ],
            ),
          );
        } else if (snapshot.connectionState == ConnectionState.waiting) {
          return Center(child: CircularProgressIndicator());
        } else {
          return Center(
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.center,
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: Icon(Icons.error),
                ),
                Text('Error loading data')
              ],
            ),
          );
        }
      }),
Run Code Online (Sandbox Code Playgroud)

和消防功能

DocumentReference getClientProfile() { …
Run Code Online (Sandbox Code Playgroud)

dart firebase flutter google-cloud-firestore

5
推荐指数
1
解决办法
2760
查看次数

标签 统计

dart ×1

firebase ×1

flutter ×1

google-cloud-firestore ×1