我是颤振和编程的新手。我开发了一个 flutter 模板 (github.com/mitesh77/Best-Flutter-UI-Templates) 并为其添加了一个启动屏幕。现在我想检查用户是否未登录,启动画面将不会加载并且用户会看到登录页面。我在新项目中尝试了这个(flutter-examples.com/flutter-online-user-registration-using-php-mysql-server)并且对我来说效果很好。但如何将其添加到下面的代码中。
代码:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await SystemChrome.setPreferredOrientations(<DeviceOrientation>[DeviceOrientation.portraitUp, DeviceOrientation.portraitDown])
.then((_) => runApp(MyApp()));
}
/* This is First Screen */
class FirstRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new SplashScreen(
seconds: 5,
navigateAfterSeconds: new AfterSplash(),
title: new Text('Hello',
style: new TextStyle(
fontWeight: FontWeight.w700,
fontFamily: 'IranYekan',
fontSize: 30.0
),),
image: new Image.asset('assets/images/splashImage.png'),
backgroundColor: Colors.white,
styleTextUnderTheLoader: new TextStyle(),
photoSize: 110.0,
onClick: ()=>print("Flutter Egypt"),
loaderColor: Colors.blue
);
}
}
class AfterSplash extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('First Route'),
),
body: Center(
child: RaisedButton(
child: Text('Open route'),
onPressed: () {
// Navigate to second route when tapped.
Navigator.push(context, MaterialPageRoute(builder: (context) => NavigationHomeScreen()),
);
},
),
),
);
}
}
潇湘沐