导航到特定屏幕后,无法使用Firebase注销

时间:2020-06-09 19:56:14

标签: firebase flutter google-cloud-firestore

即使从主屏幕注销,也可以导航到其他屏幕,然后返回主屏幕注销,但是从主屏幕开始评估时,您将进入“ assessment_list”,然后返回主屏幕屏幕上,注销不起作用。我该如何解决?

主屏幕

actions: [
              ...
                items: [
                  DropdownMenuItem(
                    child: Container(
                      child: Row(
                        children: [
                          const Icon(Icons.exit_to_app),
                          const Text('Logout'),
                          const SizedBox(width: 8),
                        ],
                      ),
                    ),
                    value: 'logout',
                  ),
                ],
                onChanged: (itemIdentifier) {
                  if (itemIdentifier == 'logout') {
                    FirebaseAuth.instance.signOut();
                  }
...

                  RaisedButton(
                  child: Text(
                    'Start Assessment'
                  ),
                  onPressed: () {
                    navigateToAssessmentList(context);
                  },
                ),

    ...

Future navigateToAssessmentList(context) async {
  Navigator.push(
      context, MaterialPageRoute(builder: (context) => AssessmentList()));
}

评估列表

 child: RaisedButton(
                padding: EdgeInsets.all(10),
                color: const Color(0xfff4f4f4),
                child: Text(
                  'Back To Home',
                ),
                onPressed: () {
                  Navigator.of(context).push(MaterialPageRoute(
                      builder: (context) => BottomNavBarController()));
                }),

1 个答案:

答案 0 :(得分:1)

您正在堆栈中再次推送同一页面。请替换以下行

Navigator.of(context).push(MaterialPageRoute(
    builder: (context) => BottomNavBarController()));

与此

Navigator.pop(context)