Flutter 当“包覆面提取”为真时,为什么CustomScrollView的滑动条显示在滑动条列表的元素下方?
通常,当我们向下滑动滑动滑动列表时,浮动滑动条将显示在滑动列表的上层。如下所示: 但是,当将Flutter 当“包覆面提取”为真时,为什么CustomScrollView的滑动条显示在滑动条列表的元素下方?,flutter,shrinkwrap,customscrollview,Flutter,Shrinkwrap,Customscrollview,通常,当我们向下滑动滑动滑动列表时,浮动滑动条将显示在滑动列表的上层。如下所示: 但是,当将包覆面提取的值更改为真时,滑动条显示在滑动列表或滑动网格的元素下方 如何解决这个问题 代码如下: import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContex
包覆面提取
的值更改为真
时,滑动条
显示在滑动列表
或滑动网格
的元素下方
如何解决这个问题
代码如下:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return CustomScrollView(
shrinkWrap: false,
slivers: <Widget>[
const SliverAppBar(
pinned: false,
floating: true,
flexibleSpace: FlexibleSpaceBar(
title: Text('SliverAPPBar'),
),
),
SliverGrid.count(
crossAxisCount: 3,
children: [
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.red, height: 150.0),
),
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.purple, height: 150.0),
),
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.green, height: 150.0),
),
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.orange, height: 150.0),
),
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.yellow, height: 150.0),
),
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.pink, height: 150.0),
),
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.cyan, height: 150.0),
),
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.indigo, height: 150.0),
),
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.blue, height: 150.0),
),
],
),
SliverList(
delegate: SliverChildListDelegate(
[
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.pink, height: 100.0),
),
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.cyan, height: 100.0),
),
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.indigo, height: 100.0),
),
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.blue, height: 100.0),
),
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.yellow, height: 100.0),
),
],
),
),
SliverFixedExtentList(
itemExtent: 150.0,
delegate: SliverChildListDelegate(
[
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.red, height: 150.0),
),
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.purple, height: 150.0),
),
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.green, height: 150.0),
),
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.orange, height: 150.0),
),
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.yellow, height: 150.0),
),
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.pink, height: 150.0),
),
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.cyan, height: 150.0),
),
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.indigo, height: 150.0),
),
Padding(
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Container(color: Colors.blue, height: 150.0),
),
],
),
),
],
);
}
}
导入“包装:颤振/材料.省道”;
void main()=>runApp(MyApp());
类MyApp扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
返回材料PP(
标题:“颤振演示”,
主题:主题数据(
主样本:颜色。蓝色,
),
主页:MyHomePage(标题:“颤振演示主页”),
);
}
}
类MyHomePage扩展StatefulWidget{
MyHomePage({Key,this.title}):超级(Key:Key);
最后的字符串标题;
@凌驾
_MyHomePageState createState()=>\u MyHomePageState();
}
类_MyHomePageState扩展状态{
@凌驾
小部件构建(构建上下文){
返回自定义滚动视图(
收缩膜:假,
条子:[
常量滑动条(
错,,
浮动:是的,
flexibleSpace:FlexibleSpaceBar(
标题:文本(“滑动条”),
),
),
SliverGrid.count(
交叉轴计数:3,
儿童:[
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子容器(颜色:Colors.red,高度:150.0),
),
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子:容器(颜色:Colors.purple,高度:150.0),
),
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子容器(颜色:Colors.green,高度:150.0),
),
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子容器(颜色:Colors.orange,高度:150.0),
),
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子容器(颜色:Colors.yellow,高度:150.0),
),
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子:容器(颜色:Colors.pink,高度:150.0),
),
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子:容器(颜色:Colors.cyan,高度:150.0),
),
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子:容器(颜色:Colors.indigo,高度:150.0),
),
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子:容器(颜色:Colors.blue,高度:150.0),
),
],
),
银表(
委托:SliverChildListDelegate(
[
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子:容器(颜色:Colors.pink,高度:100.0),
),
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子:容器(颜色:Colors.cyan,高度:100.0),
),
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子:容器(颜色:Colors.indigo,高度:100.0),
),
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子:容器(颜色:Colors.blue,高度:100.0),
),
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子容器(颜色:Colors.yellow,高度:100.0),
),
],
),
),
SliverFixedExtentList(
项目范围:150.0,
委托:SliverChildListDelegate(
[
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子容器(颜色:Colors.red,高度:150.0),
),
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子:容器(颜色:Colors.purple,高度:150.0),
),
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子容器(颜色:Colors.green,高度:150.0),
),
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子容器(颜色:Colors.orange,高度:150.0),
),
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子容器(颜色:Colors.yellow,高度:150.0),
),
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子:容器(颜色:Colors.pink,高度:150.0),
),
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子:容器(颜色:Colors.cyan,高度:150.0),
),
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子:容器(颜色:Colors.indigo,高度:150.0),
),
填充物(
填充:仅限边设置(左:24.0,右:24.0),
子:容器(颜色:Colors.blue,高度:150.0),
),
],
),
),
],
);
}
}
几个小时前,我在Flatter的代码库中添加了一个关于这一点的说明。