title: Flutter: The getter isn't defined for the type
body: <p>I am stuck at page routing.</p>
  
  <p>Here is the code from main.dart</p>
  
  <pre><code>import 'package: test/routes/router.gr.dart';
  import 'package:flutter/material.dart';
  import 'package:test/splash_screen.dart';
  import 'package:test/home_screen.dart';
  
  void main() =&gt; runApp(MyApp());
  class MyApp extends StatelessWidget {
        @override
        Widget build(BuildContext context) {
          return MaterialApp(
            theme: ThemeData(
              primarySwatch: Colors.blue,
            ),
            debugShowCheckedModeBanner: false,
            initialRoute: Router.homeScreenRoute,
            onGenerateRoute: Router.onGenerateRoute,
            navigatorKey: Router.navigatorKey,
  
          );
        }
      }
  </code></pre>
  
  <p>Here is the router.gr.dart file generated from auto-router.</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:flutter/cupertino.dart';
  import 'package:auto_route/auto_route.dart';
  import 'package:test/home_screen.dart';
  import 'package:test/viewownprofile.dart';
  import 'package:test/view_other_profile.dart';
  
  abstract class Routes {
    static const homeScreenRoute = '/';
    static const viewownProfile = '/viewown-profile';
    static const viewotherProfile = '/viewother-profile';
    static const all = {
      homeScreenRoute,
      viewownProfile,
      viewotherProfile,
    };
  }
  
  class Router extends RouterBase {
    @override
    Set&lt;String&gt; get allRoutes =&gt; Routes.all;
  
    @Deprecated('call ExtendedNavigator.ofRouter&lt;Router&gt;() directly')
    static ExtendedNavigatorState get navigator =&gt;
        ExtendedNavigator.ofRouter&lt;Router&gt;();
  
    @override
    Route&lt;dynamic&gt; onGenerateRoute(RouteSettings settings) {
      switch (settings.name) {
        case Routes.homeScreenRoute:
          return MaterialPageRoute&lt;dynamic&gt;(
            builder: (context) =&gt; HomeScreen(),
            settings: settings,
          );
        case Routes.viewownProfile:
          return MaterialPageRoute&lt;dynamic&gt;(
            builder: (context) =&gt; ViewOwnProfile(),
            settings: settings,
          );
        case Routes.viewotherProfile:
          return MaterialPageRoute&lt;dynamic&gt;(
            builder: (context) =&gt; ViewOtherProfile(),
            settings: settings,
          );
        default:
          return unknownRoutePage(settings.name);
      }
    }
  }
  </code></pre>
  
  <p>Here is the code for Homescreen.dart.</p>
  
  <pre><code>import 'package:flutter/material.dart';
  
  class HomeScreen extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return Scaffold(
          appBar: AppBar (title: Text('Home')),
          body: Center(
            child: Card(
              color: Colors.grey[300],
              elevation: 10.0,
              child: Container(
                  height: 100.0,
                  width: 100.0,
                  alignment: Alignment.center,
                  child: Text(
                    'Welcome Home!',
                    textAlign: TextAlign.center,
                    style: TextStyle(
                      fontSize: 20.0
                    ),
                  )
              ),
            ),
          )
      );
    }
  }
  </code></pre>
  
  <p>I am getting error in main.dart file. Below is the error.</p>
  
  <pre><code>The getter 'homeScreenRoute' isn't defined for the type 'Router'.
  Try importing the library that defines 'homeScreenRoute', correcting the name to the name of an existing getter, or defining a getter or field named 'homeScreenRoute'.
  </code></pre>
  
  <p>Similar error for <strong>onGenerateRoute</strong> and <strong>navigatorKey</strong>.</p>