I am setting up AccountKit on a basic App Template that I have been working on. The example I have used is the one provided by the AccountKit Plugin for Flutter.
Now, this works fine till now.
What I do is, I use an OnTap on my login screen in order to take the user to Plugin's Example Implementation (account-kit.dart on my file).
onTap: () {
Navigator.of(context).push(
// MaterialPageRoute(builder: (context) => MessagesScreen()),
MaterialPageRoute(builder: (context) => AccountKit()),
);
},
Then, inside the account-kit.dart page, there is a widget generated - which has a button that must be clicked in order to execute the Future<void> login() async{...} method.
This creates the issue, that my users now see an unnecessary screen between shifting from my login to flutter. Its like this:
- My Login Screen
- Example App's Login Screen
- AccountKit's Login (necessary)
- Back to Example App's Login Screen
- Naviagtion to MessagesScreen()
This is a little clumsy, so I am looking forward to getting rid of Step 2 and Step 4 altogether.
So it will mean that I will click login button on LoginScreen(). Then be taken to accountkit.dart's login() method and that will execute, and it will directly take me to the MessagesScreen().
But, if I do not return anything on the Widget build(BuildContext context) {} and only execute login() inside that, I face errors.
So, what is the best approach to get rid of these unnecessary elements on this screen?
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
body: new Center(
child: RaisedButton(
padding: EdgeInsets.all(0.0),
color: _state == 2 ? Colors.green : Colors.blue,
elevation: 2.0,
splashColor: Colors.blueGrey,
child: buildButtonChild(),
onPressed: _isInitialized ? this.login : null,
),
),
),
);
}
Widget buildButtonChild() {
if (_state == 0) {
return Text(
'Login',
style: TextStyle(color: Colors.white, fontSize: 16.0),
);
} else if (_state == 1) {
return SizedBox(
height: 24.0,
width: 24.0,
child: CircularProgressIndicator(
value: null,
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
));
} else {
return Icon(Icons.check, color: Colors.white);
}
}
You may find the full code of the related three pages down at THIS GIT GIST.
The image below shows the unnecessary screens that are being loaded. I just want those to not appear (the 2nd and 3rd screen with the extra login button).

this is the function that initiate accountkit
now in your on pressed for the login button call this function