如何使其在flutter中滚动 import'package:screens/Login.dart'; 进口“包装:颤振/材料.省道”; 导入'dart:ui'作为前缀1; 类AppDrawer扩展了无状态小部件{ @覆盖小部件 构建(构建上下文) { 回程抽屉( 子:ListView( 儿童:[ 容器( 子:新堆栈( 儿童:[ 克利帕斯( 子:容器( 颜色:Colors.blue.shade900, ), clipper:getClipper(), ), 容器( 孩子:定位( 宽度:300.0, 顶部:MediaQuery.of(context.size.height/6.7, 子:列( 儿童:[ 容器( 宽度:100.0, 高度:100.0, 装饰:盒子装饰( 颜色:颜色,白色, 图像:装饰图像( 图:AssetImage('assets/app1.jpg'), 适合:BoxFit.cover ), 边界半径: 边界半径所有(半径圆形(100.0)), boxShadow:[ BoxShadow(模糊半径:20.0,颜色:Colors.black) ] //边框:边框。全部(颜色:Colors.black,宽度: 1.0,样式:BorderStyle.solid) ), ), 尺寸箱(高度:10), Text('Samuel',textAlign:textAlign.center, 样式:TextStyle( 字体大小:25.0, fontFamily:“Monserati”, fontWeight:fontWeight.bold ),), 尺寸箱(高度:5), Text('07031024787',textAlign:textAlign.center, 样式:TextStyle( 字体大小:12.0, fontFamily:“Monserati”, fontStyle:fontStyle.normal ),), 尺寸箱(高度:10), Text('您的许可证将于',textAlign:textAlign.center,'到期, 样式:TextStyle( 字体大小:12.0, fontFamily:“Monserati”, fontStyle:fontStyle.italic, 颜色:颜色。红色 ),) ], ), ), ), 定位( 顶部:MediaQuery.of(context.size.height/2.1, 宽度:300.0, 子:新列( 儿童:[ CustomListTile(Icons.dashboard,'Login',()=>{ Navigator.push(上下文,MaterialPage路由(生成器:(上下文){ 返回登录名(); })) }), CustomListTile(Icons.home,'我的个人资料',()=>{ Navigator.push(上下文,MaterialPage路由(生成器:(上下文){ 返回反馈(); })) }), CustomListTile(Icons.account_框,'关于',()=>{ Navigator.push(上下文,MaterialPage路由(生成器:(上下文){ 返回大约(); })) }), ], ), ) ], ), ), ], ), ); } } 类CustomListTile扩展了无状态控件{IconData icon;字符串文本;函数onTap; CustomListTile(this.icon、this.text、this.onTap); @重写小部件生成(BuildContext上下文){返回填充( 填充:仅限边集(左:15.0,顶:6.0),子项:容器( 装饰:盒子装饰( 边框:边框(底部:边框边(颜色:Colors.grey.shade400)), ), 孩子:InkWell( splashColor:Colors.blueAccent, onTap:onTap, 子:容器( 身高:40.0, 孩子:排( mainAxisAlignment:mainAxisAlignment.spaceBetween, 儿童:[ 划船( 儿童:[ 图标(图标,颜色:Colors.blue), 填充物( 填充:来自LTRB(8.0,0.0,8.0,0.0)的边缘设置, 子项:文本(文本,样式:文本样式( 字体大小:14.0, fontFamily:“Monserati” ),) , ) ], ), 图标(图标。向右箭头) ], ), ), ) , ), ); } }
在您的列表视图下必须添加属性收缩包装:true 例如:如何使其在flutter中滚动 import'package:screens/Login.dart'; 进口“包装:颤振/材料.省道”; 导入'dart:ui'作为前缀1; 类AppDrawer扩展了无状态小部件{ @覆盖小部件 构建(构建上下文) { 回程抽屉( 子:ListView( 儿童:[ 容器( 子:新堆栈( 儿童:[ 克利帕斯( 子:容器( 颜色:Colors.blue.shade900, ), clipper:getClipper(), ), 容器( 孩子:定位( 宽度:300.0, 顶部:MediaQuery.of(context.size.height/6.7, 子:列( 儿童:[ 容器( 宽度:100.0, 高度:100.0, 装饰:盒子装饰( 颜色:颜色,白色, 图像:装饰图像( 图:AssetImage('assets/app1.jpg'), 适合:BoxFit.cover ), 边界半径: 边界半径所有(半径圆形(100.0)), boxShadow:[ BoxShadow(模糊半径:20.0,颜色:Colors.black) ] //边框:边框。全部(颜色:Colors.black,宽度: 1.0,样式:BorderStyle.solid) ), ), 尺寸箱(高度:10), Text('Samuel',textAlign:textAlign.center, 样式:TextStyle( 字体大小:25.0, fontFamily:“Monserati”, fontWeight:fontWeight.bold ),), 尺寸箱(高度:5), Text('07031024787',textAlign:textAlign.center, 样式:TextStyle( 字体大小:12.0, fontFamily:“Monserati”, fontStyle:fontStyle.normal ),), 尺寸箱(高度:10), Text('您的许可证将于',textAlign:textAlign.center,'到期, 样式:TextStyle( 字体大小:12.0, fontFamily:“Monserati”, fontStyle:fontStyle.italic, 颜色:颜色。红色 ),) ], ), ), ), 定位( 顶部:MediaQuery.of(context.size.height/2.1, 宽度:300.0, 子:新列( 儿童:[ CustomListTile(Icons.dashboard,'Login',()=>{ Navigator.push(上下文,MaterialPage路由(生成器:(上下文){ 返回登录名(); })) }), CustomListTile(Icons.home,'我的个人资料',()=>{ Navigator.push(上下文,MaterialPage路由(生成器:(上下文){ 返回反馈(); })) }), CustomListTile(Icons.account_框,'关于',()=>{ Navigator.push(上下文,MaterialPage路由(生成器:(上下文){ 返回大约(); })) }), ], ), ) ], ), ), ], ), ); } } 类CustomListTile扩展了无状态控件{IconData icon;字符串文本;函数onTap; CustomListTile(this.icon、this.text、this.onTap); @重写小部件生成(BuildContext上下文){返回填充( 填充:仅限边集(左:15.0,顶:6.0),子项:容器( 装饰:盒子装饰( 边框:边框(底部:边框边(颜色:Colors.grey.shade400)), ), 孩子:InkWell( splashColor:Colors.blueAccent, onTap:onTap, 子:容器( 身高:40.0, 孩子:排( mainAxisAlignment:mainAxisAlignment.spaceBetween, 儿童:[ 划船( 儿童:[ 图标(图标,颜色:Colors.blue), 填充物( 填充:来自LTRB(8.0,0.0,8.0,0.0)的边缘设置, 子项:文本(文本,样式:文本样式( 字体大小:14.0, fontFamily:“Monserati” ),) , ) ], ), 图标(图标。向右箭头) ], ), ), ) , ), ); } },listview,flutter,widget,scrollview,Listview,Flutter,Widget,Scrollview,在您的列表视图下必须添加属性收缩包装:true 例如: import 'package:screens/Login.dart'; import 'package:flutter/material.dart'; import 'dart:ui' as prefix1; class AppDrawer extends StatelessWidget { @override Widget build(BuildContext context) { return Drawer(
import 'package:screens/Login.dart';
import 'package:flutter/material.dart';
import 'dart:ui' as prefix1;
class AppDrawer extends StatelessWidget {
@override Widget
build(BuildContext context)
{
return Drawer(
child: ListView(
children: <Widget>[
Container(
child: new Stack(
children: <Widget>[
ClipPath(
child: Container(
color: Colors.blue.shade900,
),
clipper: getClipper(),
),
Container(
child: Positioned(
width: 300.0,
top: MediaQuery.of(context).size.height/6.7,
child: Column(
children: <Widget>[
Container(
width: 100.0,
height: 100.0,
decoration: BoxDecoration(
color: Colors.white,
image: DecorationImage(
image: AssetImage('assets/app1.jpg'),
fit: BoxFit.cover
),
borderRadius:
BorderRadius.all(Radius.circular(100.0)),
boxShadow: [
BoxShadow(blurRadius: 20.0, color: Colors.black)
]
// border: Border.all(color: Colors.black, width:
1.0, style: BorderStyle.solid)
),
),
SizedBox(height: 10),
Text('Samuel',textAlign: TextAlign.center,
style: TextStyle(
fontSize: 25.0,
fontFamily: 'Monseratti',
fontWeight: FontWeight.bold
),),
SizedBox(height: 5),
Text('07031024787',textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12.0,
fontFamily: 'Monseratti',
fontStyle: FontStyle.normal
),),
SizedBox(height: 10),
Text('Your license will expire by ', textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12.0,
fontFamily: 'Monseratti',
fontStyle: FontStyle.italic,
color: Colors.red
),)
],
),
),
),
Positioned(
top: MediaQuery.of(context).size.height/2.1,
width: 300.0,
child: new Column(
children: <Widget>[
CustomListTile(Icons.dashboard, 'Login', ()=>{
Navigator.push(context, MaterialPageRoute(builder: (context){
return Login();
}))
}),
CustomListTile(Icons.home, 'My Profile', ()=>{
Navigator.push(context, MaterialPageRoute(builder: (context){
return FeedBack();
}))
}),
CustomListTile(Icons.account_box, 'About', ()=>{
Navigator.push(context, MaterialPageRoute(builder: (context){
return About();
}))
}),
],
),
)
],
),
),
],
),
);
} }
class CustomListTile extends StatelessWidget{ IconData icon; String text; Function onTap;
CustomListTile(this.icon, this.text, this.onTap);
@override Widget build(BuildContext context) { return Padding(
padding: EdgeInsets.only(left: 15.0,top: 6.0), child: Container(
decoration: BoxDecoration(
border: Border( bottom: BorderSide(color: Colors.grey.shade400)),
),
child: InkWell(
splashColor: Colors.blueAccent,
onTap: onTap,
child: Container(
height: 40.0,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
children: <Widget>[
Icon(icon, color: Colors.blue),
Padding(
padding: EdgeInsets.fromLTRB(8.0, 0.0, 8.0, 0.0),
child: Text(text, style: TextStyle(
fontSize: 14.0,
fontFamily: 'Monseratti'
),) ,
)
],
),
Icon(Icons.arrow_right)
],
),
),
) ,
),
);
} }
ListView(
收缩膜:对,
儿童:[
您可以使用:
ListView(
shrinkWrap: true,
children: <Widget>[
SingleChildScrollView(
子:容器(
子:列(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[]),
或
SingleChildScrollView(
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[]))),
Builder(
生成器:(上下文)=>ListView(
收缩膜:对,
反面:错,
儿童:[]);
Builder(
builder: (context) => ListView(
shrinkWrap: true,
reverse: false,
children: <Widget>[]));