Dart 颤振路径口吃
我正试图将我的项目从Java/Android studio转移到Flatter,但当我试图更改“活动”时,我遇到了一个口吃/延迟问题 当我按下“注册”按钮时,我想切换到注册屏幕,但当我这样做时,会出现口吃,动画从屏幕中间开始。使用“后退”按钮返回时也是如此 我昨天开始学习颤振,所以如果你有任何关于我如何改进布局的建议,那也会有很大帮助!:)Dart 颤振路径口吃,dart,flutter,Dart,Flutter,我正试图将我的项目从Java/Android studio转移到Flatter,但当我试图更改“活动”时,我遇到了一个口吃/延迟问题 当我按下“注册”按钮时,我想切换到注册屏幕,但当我这样做时,会出现口吃,动画从屏幕中间开始。使用“后退”按钮返回时也是如此 我昨天开始学习颤振,所以如果你有任何关于我如何改进布局的建议,那也会有很大帮助!:) void main()=>runApp(新的MyApp()); 类MyApp扩展了无状态小部件{ @凌驾 小部件构建(构建上下文){ 返回新材料PP( 路线
void main()=>runApp(新的MyApp());
类MyApp扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
返回新材料PP(
路线:{
“/SignUp”:(BuildContext)=>newsignup()
},
家:新脚手架(
正文:新建WelcomePage(),
)
);
}
}
类WelcomePage扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
退回新货柜(
填充:常数边集全部(32.0),
子:新列(
mainAxisAlignment:mainAxisAlignment.center,
儿童:[
新行(
儿童:[
新扩展(
子容器:新容器(
身高:60.0,
边距:仅限常量边集(右:5.0),
孩子:新升起的按钮(
按下按钮:_sign,
颜色:Colors.blueAccent,
子项:常量文本(“登录”),
textColor:Colors.white,
),
)
),
新扩展(
子容器:新容器(
身高:60.0,
边距:仅限常量边集(左:5.0),
孩子:新升起的按钮(
onPressed:(){Navigator.of(context.pushNamed(“/SignUp”);},
颜色:Colors.blueAccent,
子项:常量文本(“注册”),
textColor:Colors.white,
),
)
)
],
),
新行(
儿童:[
新扩展(
子容器:新容器(
身高:60.0,
边距:仅限常量边集(顶部:10.0),
孩子:新升起的按钮(
按下按钮:_谷歌签名,
颜色:Colors.blueAccent,
子项:const Text('Google登录'),
textColor:Colors.white,
),
)
)
],
)
],
),
);
}
void\u注册(BuildContext上下文){
}
无效(签名){
}
void(谷歌签名){
}
}
类注册扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
归还新脚手架(
appBar:new appBar(标题:新文本(“注册”),),
主体:新容器(
填充:常数边集全部(32.0),
子:新列(
mainAxisAlignment:mainAxisAlignment.center,
儿童:[
新行(
儿童:[
新扩展(
子容器:新容器(
孩子:新文本字段(
装饰:新的输入装饰(
labelText:“电子邮件”,
),
键盘类型:TextInputType.emailAddress,
)
)
)
],
),
新行(
儿童:[
新扩展(
子容器:新容器(
孩子:新文本字段(
装饰:新的输入装饰(
labelText:“密码”,
),
蒙昧文字:对,
)
)
)
],
),
],
),
),
);
}
}
我已经尝试了您的示例代码,现在运行良好
我追踪了GitHub中报告的bug,似乎问题已经解决了
另外,我在YouTube上发现了这个有趣的话题,每当你在Flitter应用程序中遇到性能问题时。也许你遇到了?这是在真实的设备上使用的
--release
吗?是的,它使用的是--release和Oneplus 3,这不应该是问题,因为动画是从屏幕的1/2开始的。这里也有类似的投诉,导致Github出现问题:
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,
)
)
)
],
),
],
),
),
);
}
}