Flutter 如何修复没有';卷轴
我正在制作一个表单,但我无法使其可滚动,它只在“窗口”的边缘上工作,但不在表单内部,我使用finalX=TextFormField创建了此表单,因为这是我在提交前验证信息的唯一方法,这是我的代码: 我所有的Q都是这样的:final usuarioForm=TextFormField( final usuarioForm = TextFormField( controller: _idusuarioController, validator: (value) { if (value.isEmpty) return 'Llenar campo de Usuario'; return null; }, style: TextStyle(fontSize: 17.0, color: Colors.deepOrangeAccent), decoration: InputDecoration( icon: Icon(Icons.person), labelText: 'Usuario', ), ); 控制器:\ IDU控制器, 验证器:(值){ 如果(value.isEmpty)返回“Llenar campo de Usuario”; 返回null; }, 样式:TextStyle(fontSize:17.0,颜色:Colors.deepOrangeAccent), 装饰:输入装饰( 图标:图标(Icons.person), 标签文字:“Usuario”, ), ); 我的表格是这样的: final vuelosForm = Form( key: _formKey, child: ListView( shrinkWrap: true, scrollDirection: Axis.vertical, padding: EdgeInsets.all(10), children: [ usuarioForm, ], ), ); return Scaffold( key: _scaffoldKey, resizeToAvoidBottomPadding: false, appBar: AppBar( title: Text('Vuelos'), backgroundColor: Colors.deepOrangeAccent, ), body: Container( child: ListView( shrinkWrap: true, padding: EdgeInsets.fromLTRB(10.0, 0.0, 10.0, 0.0), children: [ Center( child: Card( elevation: 18.0, child: Container( padding: EdgeInsets.all(10.0), child: Column( children: [ vuelosForm, ], ), ), ), ), ], ), ), ); 最终vuelosForm=表格( 键:_formKey, 子:ListView( 收缩膜:对, 滚动方向:轴垂直, 填充:边缘设置。全部(10), 儿童:[ 通常情况下, ], ), ); 我的脚手架是这样的: final vuelosForm = Form( key: _formKey, child: ListView( shrinkWrap: true, scrollDirection: Axis.vertical, padding: EdgeInsets.all(10), children: [ usuarioForm, ], ), ); return Scaffold( key: _scaffoldKey, resizeToAvoidBottomPadding: false, appBar: AppBar( title: Text('Vuelos'), backgroundColor: Colors.deepOrangeAccent, ), body: Container( child: ListView( shrinkWrap: true, padding: EdgeInsets.fromLTRB(10.0, 0.0, 10.0, 0.0), children: [ Center( child: Card( elevation: 18.0, child: Container( padding: EdgeInsets.all(10.0), child: Column( children: [ vuelosForm, ], ), ), ), ), ], ), ), ); 返回脚手架( 钥匙:_scaffoldKey, resizeToAvoidBottomPadding:false, appBar:appBar( 标题:文本(“Vuelos”), 背景颜色:Colors.deeporangeacent, ), 主体:容器( 子:ListView( 收缩膜:对, 填充:来自LTRB(10.0,0.0,10.0,0.0)的边缘设置, 儿童:[ 居中( 孩子:卡片( 标高:18.0, 子:容器( 填充:所有边缘设置(10.0), 子:列( 儿童:[ vuelosForm, ], ), ), ), ), ], ), ), );Flutter 如何修复没有';卷轴,flutter,dart,scroll,Flutter,Dart,Scroll,我正在制作一个表单,但我无法使其可滚动,它只在“窗口”的边缘上工作,但不在表单内部,我使用finalX=TextFormField创建了此表单,因为这是我在提交前验证信息的唯一方法,这是我的代码: 我所有的Q都是这样的:final usuarioForm=TextFormField( final usuarioForm = TextFormField( controller: _idusuarioController, validator: (value) { if (value.isEmpty
显然,我还有更多的问题,但我不会将它们粘贴到这里,因为这将是大量的代码。在您的代码中,您使用Listview包装了column小部件,因此我只删除了
Listview
小部件,只需使用SingleChildScrollView
包装column即可滚动
Container(
child: Card(
elevation: 18.0,
child: Container(
padding: EdgeInsets.all(10.0),
child: SingleChildScrollView(
child: Column(
children: [
vuelosForm,
],
),
)l̥
),
),
),
添加到回答中,如果您想建立一个表单,请使用带有SingleChildScrollView的包
这个包通过删除构建表单、验证字段、对更改作出反应以及收集最终用户输入所需的样板文件,帮助在颤振中创建大型表单
在pubspec.ymal文件中添加依赖项,如:
dependencies:
flutter_form_builder: ^3.8.2
添加依赖项后,运行以下命令:
flutter pub get
在.dart文件中导入包:
import 'package:flutter_form_builder/flutter_form_builder.dart';
您可以添加为输入小部件
现在,您可以将FormBuilder
用作代码中的小部件:
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(formName, style: TextStyle(fontWeight: FontWeight.bold),),
),
body: Container(
child: Center(
child: Container(
child: SingleChildScrollView(
child: Column(
children: <Widget>[
FormBuilder(
key: _fbKey,
autovalidate: _autoValidate,
child: Column(
children: bind your form fields,
)
)
],
),
),
),
),
),
);
}
@覆盖
小部件构建(构建上下文){
返回脚手架(
appBar:appBar(
标题:文本(formName,样式:TextStyle(fontWeight:fontWeight.bold)),
),
主体:容器(
儿童:中心(
子:容器(
子:SingleChildScrollView(
子:列(
儿童:[
造模工(
键:fbKey,
自动验证:_自动验证,
子:列(
子项:绑定表单字段,
)
)
],
),
),
),
),
),
);
}
看起来您使用的是两个列表视图
,您可以远程控制其中一个。我已经尝试过了,但不起作用,或者我不知道如何正确操作我仍然不明白为什么您需要两个列表视图
,但是您是否可以尝试将大小设置为表单
?这是我的想法:因为我需要验证字段中的文本,我需要将所有字段分开,然后加入最后的x=Form();要使用键:\ u formKey。它需要一个列表视图来显示我的“问题”。此表单需要位于脚手架部分中,主体>子对象>子对象>子对象。是否尝试从最终的x=TextFormField为列表视图设置大小?获取一个大小,当它的子对象较大时,它可以滚动。