当 FAB 在屏幕上按下时,我正在显示 ModelBottomSheet。当 ModelBottomSheet 弹出时,我使用从 ModelBottomSheet 返回的数据运行一个方法,该方法更新屏幕。
onPressed: () {
print('FAB Pressed');
showModalBottomSheet<SearchData>(
isScrollControlled: true,
context: context,
builder: (context) => SingleChildScrollView(
child: SearchScreen(
searchData: _searchData,
locationEnabled: !userPosition.error,
),
),
).then((value) => _updateList(value));
},
在 ModelBottomSheet 上,我有一个弹出 ModelBottomSheet 并返回数据 (_searchData) 的按钮。
ElevatedButton(
onPressed: () {
print('search button pressed');
if (_textSearch.text == null || _textSearch.text.isEmpty) {
_searchData.searchTerm = '';
} else {
_searchData.searchTerm = 'value=${_textSearch.text}';
}
if (_idSearch.text == null || _idSearch.text.isEmpty) {
_searchData.guideId = '';
} else {
_searchData.guideId = '&location=${_idSearch.text}';
_searchData.showOfficial = false;
}
Navigator.pop(context, _searchData);
},
当 ModelBottomSheet 被解除(即用户点击屏幕的上半部分)时,如何获得与按下 ModelBottomSheet 上的按钮相同的结果?