首页 > 解决方案 > 导航到其他路线后如何处理主题?

问题描述

当我在其中使用导航时,将选择上一页主题。即使在导航到新页面后,我的上一页主题也会自动选择。我只想删除以前登录的用户主题数据。或者干脆和页面组件一起转到另一个页面。我正在颤振上创建一个多页应用程序。


    return ThemeSwitchingArea(
      child: Builder(
        builder: (context) {
          return Scaffold(
            body:  _isLoading
                ? Container(
              color: Colors.white70.withOpacity(0.3),
              width: MediaQuery.of(context).size.width, //70.0,
              height: MediaQuery.of(context).size.height, //70.0,
              child: new Padding(
                  padding: const EdgeInsets.all(5.0),
                  child: new Center(child: new CircularProgressIndicator())),
            )
                : Column(
              children: <Widget>[
                SizedBox(height: kSpacingUnit.w * 5),
                header,
                Expanded(
                  child: ListView(
                    children: <Widget>[
                      ProfileListItem(
                        icon: LineAwesomeIcons.question_circle,
                        text: 'Help & Support',
                      ),
                      Container(
                        height: kSpacingUnit.w * 5.5,
                        margin: EdgeInsets.symmetric(
                          horizontal: kSpacingUnit.w * 4,
                        ).copyWith(
                          bottom: kSpacingUnit.w * 2,
                        ),
                        padding: EdgeInsets.symmetric(
                          horizontal: kSpacingUnit.w * 2,
                        ),
                        decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(kSpacingUnit.w * 3),
                          color: Theme.of(context).backgroundColor,
                        ),
                        child: InkWell(
                          child: Row(
                            children: <Widget>[
                              Icon(
                                LineAwesomeIcons.alternate_sign_out,
                                size: kSpacingUnit.w * 2.5,
                              ),
                              SizedBox(width: kSpacingUnit.w * 1.5),
                              Text(
                                "Logout",
                                style: kTitleTextStyle.copyWith(
                                  fontWeight: FontWeight.w500,
                                ),
                              ),
                              Spacer(),
                                Icon(
                                  LineAwesomeIcons.angle_right,
                                  size: kSpacingUnit.w * 2.5,
                                ),
                            ],
                          ),
                            onTap: () async {
                              super.dispose();
                              SharedPreferences preferences = await SharedPreferences.getInstance();
                              await preferences.clear();
                              Navigator.of(context).pop();
                              Navigator.of(context)
                                  .push(MaterialPageRoute(builder: (__) => WelcomeScreen()));
                            }
                        ),
                      ),
                    ],
                  ),
                )
              ],
            ),
            bottomNavigationBar: BottomNavigation(email: _emailController.text,),
          );
        },
      ),
    );
  }
  @override
  void dispose() {
    print("Disposing second route");
    super.deactivate();
  }
}
***

标签: flutterflutter-layoutflutter-animationflutter-navigationflutter-theme

解决方案


推荐阅读