gpt4 book ai didi

dart - Flutter 路由卡顿

转载 作者:行者123 更新时间:2023-12-03 03:06:12 27 4
gpt4 key购买 nike

我正在尝试将我的项目从 Java/Android studio 转移到 flutter,但是当我尝试更改“Activity”时出现卡顿/滞后问题...

我一按下“注册”按钮就想转换到注册屏幕,但是当我这样做时出现卡顿,动画从屏幕中间开始。当我使用后退按钮导航回来时也是如此。

我昨天开始学习 flutter,所以如果你有任何关于如何改进我的布局的提示,那也会有很大帮助! :)

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
routes: <String, WidgetBuilder>{
"/SignUp": (BuildContext context) => new SignUp()
},
home: new Scaffold(
body: new WelcomePage(),
)
);
}
}

class WelcomePage extends StatelessWidget{
@override
Widget build (BuildContext context){
return new Container(
padding: const EdgeInsets.all(32.0),
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Row(
children: <Widget>[
new Expanded(
child: new Container(
height: 60.0,
margin: const EdgeInsets.only(right: 5.0),
child: new RaisedButton(
onPressed: _SignIn,
color: Colors.blueAccent,
child: const Text('Sign In'),
textColor: Colors.white,

),
)
),
new Expanded(
child: new Container(
height: 60.0,
margin: const EdgeInsets.only(left: 5.0),
child: new RaisedButton(
onPressed: (){Navigator.of(context).pushNamed("/SignUp");},
color: Colors.blueAccent,
child: const Text('Sign Up'),
textColor: Colors.white,
),
)
)
],
),
new Row(
children: <Widget>[
new Expanded(
child: new Container(
height: 60.0,
margin: const EdgeInsets.only(top: 10.0),
child: new RaisedButton(
onPressed: _GoogleSignIn,
color: Colors.blueAccent,
child: const Text('Google Sign In'),
textColor: Colors.white,
),
)
)
],
)
],
),
);
}

void _signUp(BuildContext context){

}

void _signIn(){

}

void _googleSignIn(){

}

}


class SignUp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text("SignUp"),),
body: new Container(
padding: const EdgeInsets.all(32.0),
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Row(
children: <Widget>[
new Expanded(
child: new Container(
child: new TextField(
decoration: new InputDecoration(
labelText: "Email",
),
keyboardType: TextInputType.emailAddress,

)
)
)
],
),
new Row(
children: <Widget>[
new Expanded(
child: new Container(
child: new TextField(
decoration: new InputDecoration(
labelText: "Password",
),
obscureText: true,
)
)
)
],
),
],
),
),
);
}
}

最佳答案

我已经尝试了您的示例代码,现在工作正常。

enter image description here

我已在 GitHub 中追踪报告的错误,问题似乎已解决。

此外,我发现 YouTube 上的这个主题很有趣,Flutter Europe: Optimizing your Flutter App每当您在 Flutter 应用中遇到性能问题时。

关于dart - Flutter 路由卡顿,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49145258/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com