我需要带有TabBarView
小部件的Expanded
。 TabBarView
在小部件之间。高度与Sizedbox
一起使用。
类似错误
失败的断言:1651行pos 12:'!_debugDoingThisLayout':不正确
未布置RenderBox:RenderFlex#3caee relayoutBoundary = up6 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
失败的断言:1687行pos 12:'hasSize'
TabBarView
在代码的末尾:
class TabBarNavigation extends StatefulWidget {
TabBarNavigation({this.posts});
final List<Post> posts;
@override
_TabBarNavigationState createState() => _TabBarNavigationState();
}
class _TabBarNavigationState extends State<TabBarNavigation>
with SingleTickerProviderStateMixin {
TabController _tabController;
@override
void initState() {
super.initState();
_tabController = TabController(
length: 2,
vsync: this,
);
}
Widget build(BuildContext context) {
return DefaultTabController(
length: 2,
initialIndex: 0,
child: Padding(
padding: kPaddingTabBar,
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.all(5.0),
decoration: BoxDecoration(
color: kLightGrey,
borderRadius: BorderRadius.all(
Radius.circular(50),
),
),
child: TabBar(
tabs: <Tab>[Tab(text: kArtwork), Tab(text: kPastJobs)],
unselectedLabelColor: Colors.black54,
labelColor: Colors.black,
unselectedLabelStyle: kBoldText,
labelStyle: kBoldText,
indicatorSize: TabBarIndicatorSize.tab,
indicator: BoxDecoration(
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(50),
color: Colors.white,
),
),
),
const SizedBox(height: kCommonSeparation),
Expanded(
child: TabBarView(
controller: _tabController,
children: [ArtworkTab(widget.posts), PastJobsTab()]
)
),
],
),
),
);
}
}
[我认为这就是为什么TabBarView需要const大小的原因,我建议您使用具有固定高度而不是Expanded的Container标签包装。对不起我的英语。