我有一个带有其他班级“样式”的回调的班级:
class StationState extends State<Stations> {
Widget secondWidget;
@override
Widget build(BuildContext context) {
Widget nowStyles = Styles(onStyleTap: () => setState(() {
secondWidget = Genres();
}));
secondWidget = nowStyles;
return DefaultTabController(
length: 3,
child: Scaffold(
backgroundColor: Color(0xFF000000),
appBar: AppBar(
title: HeaderLogo(),
backgroundColor: Color(0xFF000000),
bottom: TabBar(
indicatorColor: Colors.white,
tabs: [
Tab(
text: 'Favorites',
),
Tab(
text: 'Genres',
),
Tab(
text: 'Networks',
),
],
),
),
body: TabBarView(children: [
Favorites(),
secondWidget,
Networks(),
]),
),
);
}
}
您能帮我解释一下为什么setstate不起作用吗?毕竟,当我更改TabBarView子级并进行更新时,例如“收藏夹”,一切正常。谢谢。