Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type NavigatorState not found #871

Closed
AlexStroia opened this issue Dec 1, 2021 · 4 comments
Closed

Type NavigatorState not found #871

AlexStroia opened this issue Dec 1, 2021 · 4 comments

Comments

@AlexStroia
Copy link

AlexStroia commented Dec 1, 2021

Hi, I'm getting the following error:

lib/presentation/routes/app_router.gr.dart:14:26: Error: Type 'NavigatorState' not found.
  _$AppRouter([GlobalKey<NavigatorState>? navigatorKey]) : super(navigatorKey);
                         ^^^^^^^^^^^^^^
lib/presentation/routes/app_router.gr.dart:14:16: Error: Type 'GlobalKey' not found.
  _$AppRouter([GlobalKey<NavigatorState>? navigatorKey]) : super(navigatorKey);
               ^^^^^^^^^
lib/presentation/routes/app_router.gr.dart:14:16: Error: Expected 0 type arguments.
  _$AppRouter([GlobalKey<NavigatorState>? navigatorKey]) : super(navigatorKey);
               ^
lib/presentation/routes/app_router.gr.dart:14:26: Error: 'NavigatorState' isn't a type.
  _$AppRouter([GlobalKey<NavigatorState>? navigatorKey]) : super(navigatorKey);
                         ^^^^^^^^^^^^^^
lib/presentation/routes/app_router.gr.dart:14:16: Error: 'GlobalKey' isn't a type.
  _$AppRouter([GlobalKey<NavigatorState>? navigatorKey]) : super(navigatorKey);
               ^^^^^^^^^

My AppRouter code is:
import 'package:auto_route/annotations.dart';
import 'package:auto_route/auto_route.dart';
import 'package:fithub/presentation/pages/forgot_password/forgot_password_page.dart';
import 'package:fithub/presentation/pages/register/register_page.dart';
import 'package:fithub/presentation/pages/sign_in/sign_in_page.dart';
part 'app_router.gr.dart';

const registerPath = "/register";
const forgotPasswordPath = "/forgot-password";
const signupPath = "/singup";

@MaterialAutoRouter(
  
  replaceInRouteName: 'Page,Route', routes: <AutoRoute>[
  AutoRoute(page: SignInPage, path: signupPath),
  AutoRoute(page: RegisterPage, path: registerPath, initial: true),
  AutoRoute(page: ForgotPasswordPage, path: forgotPasswordPath)
])

class AppRouter extends _$AppRouter{}        

My MaterialApp.router code is:

class FithubApp extends StatelessWidget {
  final _appRouter = AppRouter();

  FithubApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp.router(
      debugShowCheckedModeBanner: false,
      routerDelegate: _appRouter.delegate(),
      routeInformationProvider: _appRouter.routeInfoProvider(),
      routeInformationParser: _appRouter.defaultRouteParser(),
      title: 'Fithub',
      theme: appTheme(),
    );
  }
}

Spend the last two days trying to figure out what is happening. I'm running flutter 2.5.1

@carlosfiori
Copy link

Hi, try add this import in your AppRouter file
import 'package:flutter/material.dart';

@Djihanegh
Copy link

I'am getting the same error too

@sunderee
Copy link

Could you please update the documentation with this? Because I feel like that's a pretty important thing for people to know, and not have to second-guess it, and/or browse GitHub issues from almost half a year ago.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants