【发布时间】:2019-11-05 21:11:00
【问题描述】:
我有两个页面,一个是列表视图,另一个是表单类型的页面。使用 sqflite 和 streambuilder 进行 crud 操作,一旦我输入输入并从屏幕的第二个屏幕列表视图中保存,应该更新。
首屏:
列表视图将像这样从 sqflite 数据库返回。
Widget getDebtorsWidget() {
return StreamBuilder(
stream: debtorBloc.debtors,
builder: (BuildContext context, AsyncSnapshot<List<Debtor>> snapshot) {
return getDebtorCardWidget(snapshot);
},
);
}
-----------------------------------------------------------------------------
floatingActionButton: FloatingActionButton(
tooltip: 'Add an entry',
child: Icon(Icons.add),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => DebtorFormFullScreenDialog(),
fullscreenDialog: true,
));
//_showAddDebtorSheet(context);
},
),
void _showAddDebtorSheet(BuildContext context) {
......
}
第二屏:
onPressed: () {
final newDebtor =
Debtor(name: _debtorNameFormController.value.text);
if (newDebtor.name.isNotEmpty) {
debtorBloc.addDebtor(newDebtor);
//dismisses the bottomsheet
Navigator.pop(context, false);
}
},
_showAddDebtorSheet() 在此列表视图中输入数据时在同一屏幕上立即更新。但是什么时候在第二个屏幕上做不是列表视图,即使我导航回第一个屏幕也不会更新。
注意:如果您需要更多信息,请通知我。
【问题讨论】: