【发布时间】:2020-06-15 01:19:46
【问题描述】:
我有一个MultiBlocProvider 分配给一个应用程序,该应用程序有一个底部导航栏,可以在主页、搜索等主要路线中导航, 愿望清单 ...
我使用setState(){} 为每条路线更改currentPage。
最近我通过使用flutter_bloc 包为每个人添加了Blocs,并且我正在使用BlocProvider 为每个BlocBuilder 提供bloc,
@override
Widget build(BuildContext context) {
return SafeArea(
top: false,
child: Scaffold(
key: _scaffoldKey,
body: PageStorage(
child: Stack(
children: <Widget>[
AnimatedSwitcher(
duration: Duration(milliseconds: 200),
child: BlocProvider<WishlistBloc>(
create: (BuildContext context) => WishlistBloc(WishlistRepository()),
child: currentPage),
),
bottomBar(currentPageScroll)
],
),
bucket: bucket,
),
),
);
}
可以使用MultiBlocProvider 提供我需要的所有 BlocsProviders 吗?
他们可能超过 10 个提供商,这会影响应用程序的性能吗?
【问题讨论】:
标签: android performance flutter bloc flutter-bloc