我已经为新的Messenger游戏的登录页面和注册页面编写了此代码。
https://github.com/wileecoyote2point0/math_game
在模拟器中,我收到错误消息:底部被无限像素溢出
有人可以引导我朝正确的方向前进吗?
我尝试实现滚动视图,并尝试了MainAxisSize.Min
但似乎无法使其正常工作。
答案 0 :(得分:0)
您已经使用了所有刚性容器,行和列。与其使用固定大小的容器,不如使用固定大小的容器,以使其适合所需的大小。 在这里,您只需要简单地将Expanded Widget放在Container Widget之外。 工作应用的链接为Working App Image
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'signup.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
theme: new ThemeData(primarySwatch: Colors.purple),
home: new LoginPage(),
routes: <String, WidgetBuilder>{
'/signup': (BuildContext context) => new SignupPage()
});
}
}
class LoginPage extends StatefulWidget {
@override
State createState() => new LoginPageState();
}
class LoginPageState extends State<LoginPage>
with SingleTickerProviderStateMixin {
Animation<double> _iconAnimation;
AnimationController _iconAnimationController;
@override
void initState() {
super.initState();
_iconAnimationController = AnimationController(
vsync: this,
duration: new Duration(milliseconds: 500),
);
_iconAnimation = new CurvedAnimation(
parent: _iconAnimationController, curve: Curves.easeOut);
_iconAnimation.addListener(() => this.setState(() {}));
_iconAnimationController.forward();
}
@override
Widget build(BuildContext context) {
return new Scaffold(
backgroundColor: Colors.tealAccent,
body: new Stack(
fit: StackFit.expand,
children: <Widget>\[
new Image(
image: new AssetImage("assets/nevroner3.jpg"),
fit: BoxFit.cover,
color: Colors.black87,
colorBlendMode: BlendMode.darken,
),
new Theme(
data: new ThemeData(
brightness: Brightness.dark,
inputDecorationTheme: new InputDecorationTheme(
labelStyle:
new TextStyle(color: Colors.tealAccent, fontSize: 20.0),
),
),
isMaterialAppTheme: true,
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>\[
new Image(
image: new AssetImage("assets/math_logo3.png"),
),
Expanded(
child: new Container(
padding: EdgeInsets.all(20.0),
child: new Form(
autovalidate: true,
child: new Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>\[
new TextFormField(
decoration: new InputDecoration(
labelText: "Enter Email",
fillColor: Colors.white,
),
keyboardType: TextInputType.emailAddress,
),
new TextFormField(
decoration: new InputDecoration(
labelText: "Enter Password",
fillColor: Colors.white,
),
obscureText: true,
keyboardType: TextInputType.text,
),
new Padding(
padding: const EdgeInsets.only(top: 20.0),
),
new MaterialButton(
color: Colors.teal,
textColor: Colors.white,
child: new Text("Login"),
onPressed: () => {}),
SizedBox(height: 50.0),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>\[
Text(
"New to Math Messenger ?",
style: TextStyle(
color: Colors.grey,
decoration: TextDecoration.underline),
)
\],
),
SizedBox(height: 20.0),
InkWell(
onTap: () {
Navigator.of(context).pushNamed('/signup');
},
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>\[
Text(
"Register",
style: TextStyle(
color: Colors.tealAccent,
decoration: TextDecoration.underline,
),
),
\],
),
\],
),
),
),
)
\],
),
),
\],
),
);
}
}][1]