我的 Widget 正文中有一个 StreamBuilder
body: RefreshIndicator(
onRefresh: () => _sheetDetailBloc.fetchSheetDetail(
widget.selectedSheet, widget.selectedSheetTitle),
child: StreamBuilder<ApiResponse<Sheet>>(
stream: _sheetDetailBloc.sheetDetailStream,
builder: (context, snapshot) {
if (snapshot.hasData) {
switch (snapshot.data.status) {
case Status.LOADING:
return Loading(loadingMessage: snapshot.data.message);
break;
case Status.COMPLETED:
return ShowSheetDetail(displaySheet: snapshot.data.data);
break;
case Status.ERROR:
return Error(
errorMessage: snapshot.data.message,
onRetryPressed: () => _sheetDetailBloc.fetchSheetDetail(
widget.selectedSheet, widget.selectedSheetTitle),
);
break;
}
我的应用程序栏中有一个抽屉,我想在其中显示contactNoToDisp和emailIDToDisp,它们将在asyc调用后作为snapshot.data.data.contactNo和snapshot.data.data.emailID到达
抽屉代码如下:
endDrawer: Drawer(
child: ListView(
children: <Widget>[
ListTile(
title: Text("First Item"),
),
ListTile(title: Text(contactNoForDisp)),
ListTile(title: Text(emailIDForDisp)),
],
)),
我不确定在future/asyc返回后如何更新两个类变量contactNoToDisp和emailIDToDisp,以便在抽屉中显示相同的变量