Flutter ListView-删除剪辑?

时间:2018-07-28 13:45:08

标签: listview dart stack flutter clipping

我有以下布局,一个Stack,下面有一个ListView,两个布局都位于一个Column内。

当我按预期滚动ListView时,它会在自己的框中自动裁剪。

在滚动到上方ListView上方并向上滚动时,我想要Stack。就像它没有被限制在边界一样。

我该如何实现?谢谢。

2 个答案:

答案 0 :(得分:0)

您将需要一个var text = "Some unnecessarily long, long, long string."; var size = default(SizeF); // SizeF size; // Use this if you're on an older version of C# without default do { using (var font = new Font(textBox1.Font.Name, textBox1.Font.SizeInPoints)) { size = TextRenderer.MeasureText(text, font); if (size.Width <= textBox1.Width) textBox1.Text = text; else { textBox1.Text = "Won't fit"; textBox1.Font = new Font(font.Name, font.SizeInPoints - 1f); } } } while (size.Width > textBox1.Width); ,并且标头小部件必须放在CustomScrollView中:

SliverPersistentHeader


要创建浮动的class MyPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: CustomScrollView( slivers: <Widget>[ SliverPersistentHeader( delegate: MyHeader(), pinned: true, ), SliverList(delegate: SliverChildBuilderDelegate((context, index) { return ListTile( title: Text('Test $index'), ); })) ], ), ); } } class MyHeader extends SliverPersistentHeaderDelegate { @override Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) { return Stack( children: <Widget>[ Container(color: Colors.blue.withOpacity(0.5)), Align( alignment: Alignment.bottomCenter, child: Text('Hello World'), ) ], ); } @override double get maxExtent => 100.0; @override double get minExtent => 100.0; @override bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) { return false; } } ,请使用AppBar小部件:

SliverAppBar

答案 1 :(得分:0)

在列表视图中添加

clipBehavior: Clip.none