【发布时间】:2019-06-03 05:05:05
【问题描述】:
堆栈有 3 个子属性,第一个子属性(红色背景)部分可见,因为最后一个子属性(黑色背景)在顶部。我需要最后一个孩子在其他两个孩子的正下方,它不应该像现在这样重叠。最后一个子项包含动态文本 - 多行文本会导致文本块向上移动而不是向下移动 - 尝试在最后一个子项中添加几行。
return new Scaffold(
body: NestedScrollView(
controller:_scrollController ,
headerSliverBuilder:
(BuildContext contrxt, bool innerBoxIsScrolled) {
print('scrolled $innerBoxIsScrolled');
return <Widget>[
SliverAppBar(
backgroundColor: Colors.transparent,
automaticallyImplyLeading: false,
expandedHeight: 195.0,
pinned: true,
floating: true,
forceElevated: innerBoxIsScrolled,
flexibleSpace: FlexibleSpaceBar(
background: new Stack(children: <Widget>[
Positioned(
right: 0.0,
left: 0,
bottom: -1,
child: Container(
color: Colors.redAccent,
height: 50.0,
child: Text("Container 1 Text", textAlign: TextAlign.center,),
),
),
Container(
color: Colors.blue,
height: MediaQuery.of(context).size.height / 6,
width: MediaQuery.of(context).size.width,
child: Text("Container 2 Text", textAlign: TextAlign.center,),
),
Positioned(
bottom: 0,
left: 0,
right: 0,
child: Container(
//margin: EdgeInsets.only(top: 49.0),
color: Colors.black,
//height: 20.0,
width: MediaQuery.of(context).size.width,
//padding: EdgeInsets.only(top: 5.0, left: 20.0, bottom: 5.0, right: 20.0),
child: Padding(
padding: const EdgeInsets.all(10.0),
child: new Text("Container 3",
style: TextStyle(fontSize: 12.0, color: Colors.grey[800]),
),
),
),
)
]),
),
),
];
},
body: Container(),
【问题讨论】:
-
可以提供截图吗?
-
@OzanYurtsever 运行上述内容,应该很清楚。
-
代码不会编译,你应该共享_scrollController
-
@OzanYurtsever 注释掉一行:controller:_scrollController