[英]Does creating multiple custom stateless widgets inside another custom widget affect performance?
So i have TabBar and i make resuable Tab or custom widget TabBarPage
inside the TabBarView
.所以我有 TabBar 并且我在 TabBarView 内制作了可
TabBarView
TabBarPage
my question is does my approach like this code below do affect bad perfomance or is it the same if i not make any custom widget inside custom widget ?我的问题是我像下面的代码这样的方法是否会影响性能不佳,或者如果我没有在自定义小部件中制作任何自定义小部件,它是否相同?
TabBarView(
children: [
TabBarPage(
child: NowPlaying(),
),
TabBarPage(
child: Upcoming(),
),
TabBarPage(
child: Popular(),
),
],
),
inside TabBarPage i have final Widget child;
在 TabBarPage 我有
final Widget child;
that is filled with NowPlaying, Upcoming, or Popular and this three child have the same code but different provider填充了 NowPlaying、Upcoming 或 Popular 并且这三个孩子有相同的代码但不同的提供者
Container(
padding: EdgeInsets.fromLTRB(18.w, 0, 18.w, 0),
child: SingleChildScrollView(
child: this.widget.child,
),
),
and in NowPlaying, Upcoming, or Popular i have my 2 another custom widget (TabLoading, TabContent)在 NowPlaying、Upcoming 或 Popular 我有我的 2 另一个自定义小部件(TabLoading、TabContent)
class NowPlaying extends StatelessWidget {
const NowPlaying({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Consumer<NowPlayingProvider>(
builder: (context, data, child) {
if (data.isLoading == true) return TabLoading();
return TabContent(data: data.nowPlaying);
},
);
}
}
显然不,通过在另一个自定义小部件中创建多个自定义无状态小部件对性能没有影响,通过这个
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.