как только я заполняю форму и отправляю ее в Firebase, код перемещает меня на мою домашнюю страницу, но как только я нажимаю кнопку «Назад» на моем телефоне с Android, он отправляет пользователя на предыдущую страницу формы со всеми доступными ранее заполненными данными. Я устал использовать WillPopScope функцию, чтобы отключить кнопку назад моего телефона Android, но нет ответа ..
Я также создал функцию, используя willpopscope , и вызвал ее в основном, но безрезультатно.
@override
Widget build(BuildContext context) {
return new WillPopScope(
onWillPop: () async =>false,
child: new Scaffold(
appBar: new AppBar(
title: new Text('Welcome'),
actions: <Widget>[
_onbackpressed(), //tried disabling the back button by calling this fucntion
new FlatButton(
child: new Text('Logout',
style: new TextStyle(fontSize: 17.0, color: Colors.white)),
onPressed: _signOut)
],
),
body: _showTodoList(),
floatingActionButton: FloatingActionButton(
onPressed: () {
signupPage(context);
},
tooltip: 'Increment',
child: Icon(Icons.add),
)
),
);
}
//extra funtion to disable the back button-
_onbackpressed(){
return new WillPopScope(
onWillPop: () async =>false,
child: new Container(width: 0.0,height: 0.0,),
);
}
//function used to send the user form to server
RaisedButton(
elevation: 7.0,
child: Text('Upload'),
textColor: Colors.white,
color: Colors.blue,
onPressed: () {
final StorageReference firebaseStorageRef =
FirebaseStorage.instance.ref().child(Username);
final StorageUploadTask task =
firebaseStorageRef.putFile(_image);
success(context);
},
),
//where success is a fuction
success(BuildContext context){
Navigator.of(context)
.push(MaterialPageRoute(builder:(context)=>Redirect() ));
}