1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] Url path not changing when navigating back to previous page in flutter web

Discussão em 'Mobile' iniciado por Stack, Outubro 30, 2024 às 17:33.

  1. Stack

    Stack Membro Participativo

    I am working on a flutter app. i have set up router in the app with named routes. on going to my home page it shows as locahost:1234/#/home. and the path is correct. but from there when a navigate back to previouse page it still showing the same path locahost:1234/#/home. the path url is not changing on navigating back. if any one has an idea? my router file is as follows:

    /* ADD REPOSITORY TO APP ROUTER */
    /* ADD REPOSITORY TO APP ROUTER */
    Repository repository;
    AppRouter() {
    repository = new Repository(apiService: ApiService());
    }

    Route generateRoute(RouteSettings settings) {
    switch (settings.name) {
    case "/":
    return MaterialPageRoute(
    settings: RouteSettings(name: '/'),
    builder: (_) => MultiBlocProvider(providers: [
    BlocProvider<HomeCubit>(
    create: (BuildContext context) {
    return HomeCubit(repository: repository);
    },
    ),
    BlocProvider<SearchCubit>(
    create: (BuildContext context) =>
    SearchCubit(repository: repository),
    ),
    BlocProvider<UserCubit>(
    create: (BuildContext context) {
    return UserCubit(repository: repository);
    },
    )
    ], child:userToken==null?SplashScreen():NavScreen()
    // SplashScreen()
    ));
    case "/getstarted":
    return MaterialPageRoute(
    settings: RouteSettings(name: '/getstarted'),
    builder: (_) => BlocProvider(
    create: (BuildContext context) =>
    ProfileCubit(repository: repository),
    child: OnboardingScreen()));
    //return MaterialPageRoute(builder: (_) => VideoDetailScreen());
    case "/register":
    return MaterialPageRoute(
    settings: RouteSettings(name: '/register'),
    builder: (_) => MultiBlocProvider(providers: [
    BlocProvider<HomeCubit>(
    create: (BuildContext context) {
    return HomeCubit(repository: repository);
    },
    ),
    BlocProvider<SearchCubit>(
    create: (BuildContext context) =>
    SearchCubit(repository: repository),
    ),
    BlocProvider<UserCubit>(
    create: (BuildContext context) =>
    UserCubit(repository: repository),
    )
    ], child: RegisterScreen()));
    case '/home':
    return MaterialPageRoute(
    settings: RouteSettings(name: '/home'),
    builder: (_) => BlocProvider(
    create: (BuildContext context) =>
    HomeCubit(repository: repository),
    child: NavScreen()));
    case '/signin':
    return MaterialPageRoute(
    builder: (_) => BlocProvider(
    create: (BuildContext context) =>
    UserCubit(repository: repository),
    child: SigninScreen()),
    settings: RouteSettings(name: '/signin'));
    default:
    return MaterialPageRoute(builder: (_) {
    return Scaffold(
    body: Center(
    child: Text('Error! No route Found...',
    style: TextStyle(color: Colors.white,fontWeight:FontWeight.bold),),
    ),
    );
    }
    );
    }
    }
    }

    Continue reading...

Compartilhe esta Página