用 SliverFillRemaining 包装 TabBarView(填充剩余的空白空间,如 Expanded)给出以下错误输出。
颤振:RenderPositionedBox 期望 RenderBox 类型的子级,但收到颤振类型的子级:RenderSliverList。
TabController tabContoller;
@override
void initState() {
tabContoller = new TabController(
vsync: this,
length: 3,
);
@override
Widget build(BuildContext context) {
return new Scaffold(
floatingActionButton:floatActionBtn(...),
bottomNavigationBar: bottomNavigationBar(...),
appBar: apBar(),
body: Stack(
children: <Widget>[
CustomScrollView(
slivers: <Widget>[
SliverAppBar(
backgroundColor: Colors.transparent,
automaticallyImplyLeading: false,
expandedHeight: 195.0,
flexibleSpace: FlexibleSpaceBar(
background: new Stack(
children: <Widget>[
...
]),
),
),
new SliverFillRemaining(
child: TabBarView(
controller: tabContoller,
children: <Widget>[
Tab(...),
Tab(...),
Tab(...)
],
),
),
],
),
],
)
Run Code Online (Sandbox Code Playgroud)
die*_*per 12
不要忘记DefaultTabController,这段代码工作正常:
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 3,
child: Container(
child: CustomScrollView(slivers: <Widget>[
SliverAppBar(),
new SliverFillRemaining(
child: TabBarView(
children: <Widget>[
Text("Tab 1"),
Text("Tab 2"),
Text("Tab 3"),
],
),
),
])),
);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7448 次 |
| 最近记录: |