我在学习编码时构建了一些颤动的应用程序,并在过去修复了 SingleChildScrollView 的“溢出”问题。这个问题是不同的,我在这里或其他地方找不到修复程序。
我相信这个问题是由于在“屏幕”中有一个“表格”。
屏幕“golf_cart_reg_new.dart”有 appBar 和提交或取消按钮。
'golf_cart_reg_new_form.dart' 具有 TextFormFields 和验证。溢出错误似乎在形式而不是屏幕上。我在所有我能想到的地方都尝试了 SingleChildScrollView ,没有任何改变。
我也确定我的代码很臃肿,但我又在学习。
我将在下面发布两个屏幕的代码。任何帮助,将不胜感激。
----这是下面的屏幕代码----
import 'package:WelakaOne/logic/golf_cart_new_form.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:WelakaOne/appbar/app_bar_title.dart';
import 'package:WelakaOne/drawer/drawer.dart';
import 'package:WelakaOne/drawer/end_drawer.dart';
import 'package:WelakaOne/logic/custom_colors.dart';
import 'golf_cart_reg_home.dart';
class GolfCartNewScreen extends StatefulWidget {
@override
_GolfCartNewScreenState createState() => _GolfCartNewScreenState();
}
class _GolfCartNewScreenState extends State<GolfCartNewScreen> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
systemOverlayStyle: SystemUiOverlayStyle.dark,
backgroundColor: CustomColors.WelakaOneBlack,
title: AppBarTitle(),
leading: Builder(
builder: (context) {
return IconButton(
onPressed: () {
Scaffold.of(context).openDrawer();
},
icon: Icon(Icons.menu),
);
},
),
actions: <Widget>[
Builder(
builder: (context) {
return IconButton(
onPressed: () {
Scaffold.of(context).openEndDrawer();
},
icon: Icon(Icons.person),
);
},
),
],
),
drawer: new MyDrawer(),
endDrawer: new MyEndDrawer(),
body: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [
CustomColors.WelakaOneBlack,
CustomColors.WelakaOneBlueDark,
],
begin: FractionalOffset(0.0, 0.0),
end: FractionalOffset(1.6, 1.0),
stops: [0.3, 1.0],
tileMode: TileMode.clamp,
),
),
child: Container(
child: Center(
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.fromLTRB(0, 15, 0, 0),
child: Text(
'GOLF CART',
style: TextStyle(
color: CustomColors.WelakaOneYellow,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
Container(
padding: EdgeInsets.fromLTRB(0, 0, 0, 0),
child: Text(
'NEW REGISTRATION',
style: TextStyle(
color: CustomColors.WelakaOneYellow,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
SizedBox(height: 30),
Container(
padding: EdgeInsets.fromLTRB(30, 0, 30, 0),
child: GolfCartNewForm(),
),
SizedBox(height: 30),
Container(
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
onPressed: () {
Navigator.push(
context,
new MaterialPageRoute(
builder: (context) => new GolfCartHomeScreen(),
),
);
},
child: const Text(
'CANCEL',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: CustomColors.WelakaOneBlueDark,
),
),
style: ElevatedButton.styleFrom(
primary: CustomColors.WelakaOneWhite,
fixedSize: const Size(220, 40),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50),
),
),
),
],
),
),
),
],
),
),
),
),
);
}
}
---- 这是下面的表格 ----
import 'package:WelakaOne/logic/golf_cart_new_form.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:WelakaOne/appbar/app_bar_title.dart';
import 'package:WelakaOne/drawer/drawer.dart';
import 'package:WelakaOne/drawer/end_drawer.dart';
import 'package:WelakaOne/logic/custom_colors.dart';
import 'golf_cart_reg_home.dart';
class GolfCartNewScreen extends StatefulWidget {
@override
_GolfCartNewScreenState createState() => _GolfCartNewScreenState();
}
class _GolfCartNewScreenState extends State<GolfCartNewScreen> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
systemOverlayStyle: SystemUiOverlayStyle.dark,
backgroundColor: CustomColors.WelakaOneBlack,
title: AppBarTitle(),
leading: Builder(
builder: (context) {
return IconButton(
onPressed: () {
Scaffold.of(context).openDrawer();
},
icon: Icon(Icons.menu),
);
},
),
actions: <Widget>[
Builder(
builder: (context) {
return IconButton(
onPressed: () {
Scaffold.of(context).openEndDrawer();
},
icon: Icon(Icons.person),
);
},
),
],
),
drawer: new MyDrawer(),
endDrawer: new MyEndDrawer(),
body: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [
CustomColors.WelakaOneBlack,
CustomColors.WelakaOneBlueDark,
],
begin: FractionalOffset(0.0, 0.0),
end: FractionalOffset(1.6, 1.0),
stops: [0.3, 1.0],
tileMode: TileMode.clamp,
),
),
child: Container(
child: Center(
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.fromLTRB(0, 15, 0, 0),
child: Text(
'GOLF CART',
style: TextStyle(
color: CustomColors.WelakaOneYellow,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
Container(
padding: EdgeInsets.fromLTRB(0, 0, 0, 0),
child: Text(
'NEW REGISTRATION',
style: TextStyle(
color: CustomColors.WelakaOneYellow,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
SizedBox(height: 30),
Container(
padding: EdgeInsets.fromLTRB(30, 0, 30, 0),
child: GolfCartNewForm(),
),
SizedBox(height: 30),
Container(
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
onPressed: () {
Navigator.push(
context,
new MaterialPageRoute(
builder: (context) => new GolfCartHomeScreen(),
),
);
},
child: const Text(
'CANCEL',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: CustomColors.WelakaOneBlueDark,
),
),
style: ElevatedButton.styleFrom(
primary: CustomColors.WelakaOneWhite,
fixedSize: const Size(220, 40),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50),
),
),
),
],
),
),
),
],
),
),
),
),
);
}
}