Mohamed Alaa
Mohamed Alaa

Reputation: 141

Flutter Navigation routes not run smoothly

I am using Navigator.pushNamed(context, '/RegisterScreen'); to Navigate to Register Screen but it not run smoothly , It seems that the first screen under the second one for about half a second on navigation

Upvotes: 4

Views: 2427

Answers (3)

Renaut Mestdagh
Renaut Mestdagh

Reputation: 3

Putting the Widget in a Scaffold solved this for me.

Before:

Navigator(
  onGenerateRoute: (settings) {
    if (settings.name == '/...') {
      return MaterialPageRoute(   
        builder: (context) => NestedScrollView(..)
      );
    }
  }
)

After:

Navigator(
  onGenerateRoute: (settings) {
    if (settings.name == '/...') {
      return MaterialPageRoute(   
        builder: (context) => Scaffold(
          body: NestedScrollView(..)
        ),
      );
    }
  }
)

Upvotes: 0

Paulo Alves
Paulo Alves

Reputation: 41

I was experiencing this lag as well, running debug mode on chrome. Despite not having any lag on debug mode in a emulator.

Running chrome on profile mode, as @Lunedor suggested, seems to eliminate all these performance issues.

Upvotes: -2

Lunedor
Lunedor

Reputation: 1514

push or pushNamed doesn't close current screen if you want to new screen get replace(not on) your current screen you need to use pushReplacement or pushReplacementNamed method

so try below code and check methods in flutter documents to get the whole idea about navigation:

Navigator.pushReplacementNamed(context, '/RegisterScreen');

Upvotes: 1

Related Questions