...
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'haha',
theme: ThemeData(
fontFamily: 'Iransans',
primaryColor: Palette.primaryColor,
canvasColor: Palette.primaryColor, //my custom color
accentColor: Palette.accentColor),
initialRoute: "/",
routes: {
"/": (context) => Directionality(
textDirection: TextDirection.rtl, child: SplashPage()),
...
and in SplashPage, I navigate from here to login page
@override
Widget build(BuildContext context) {
Future.delayed(const Duration(seconds: 4), () {
Navigator.pushNamed(context,"/login" /*,arguments: "free"*/);
});
return const Scaffold(
backgroundColor: Palette.white,
body: Center(
child:
SizedBox(height: 60, width: 60, child: CircularProgressIndicator()),
),
);
}
here is my TextField in LoginPage. the page that doesn't work but when navigating here from MainPage directly everything is well
Scaffold(
backgroundColor: Palette.primaryColor,
body: SingleChildScrollView(
child: Column(
children: <Widget>[
TextField(
autofocus: true,
textAlign: TextAlign.center,
//controller: _textFieldControllerUserName,
keyboardType: TextInputType.name,
),
],
),
),
);
flutter keeps pages in a stack and the whole thing in the stack is working :( build method runs even when the page is in backStack, so I moved my navigator to initState()
class SplashPageState extends State<SplashPage> {
@override
void initState() {
super.initState();
Future.delayed(const Duration(seconds: 4), () {
_navigateLoginPage(context);
});
}
@override
Widget build(BuildContext context) {
return const Scaffold(
backgroundColor: Palette.white,
body: Center(
child:
SizedBox(height: 60, width: 60, child: CircularProgressIndicator()),
),
);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With