屏幕颤振条件渲染

我正在尝试在应用程序打开时实现屏幕的有条件显示。

在main.dart中

return Materialapp(
  ...
  home: WelcomePage()
  ...
);

在WelcomePage.dart中

isLoggedin() async {
  prefs = await SharedPreferences.getInstance();
  if (prefs.getString('username') == null) {
    Navigator.of(context).pushAndRemoveUntil(
      MaterialPageRoute(builder: (BuildContext context) => LoginPage()),
      (Route<dynamic> route) => false);
  }
}

Issue: - The user will open the app, after the splash screen, the WelcomePage screen will show momentarily then redirects the user to Login screen.

This code does what I needed, but what I really want. What I want is the app will not show the WelcomePage screen if the user has no saved preference in the app, instead, there is a code that checks whether the app will show the Login screen or the WelcomePage screen.