Skip to main content ppwriters

#30DaysMasterFlutter

Day 19

Navigator 2.0 and the Go Router

Learn about Navigator 2.0, the newest version of the Navigator widget in Flutter that simplifies app navigation and supports deep linking. Also learn about the Go Router, an officially supported Dart package that provides a declarative approach to routing in Flutter apps.

Project - Quotes App 2.0

Copy and update the quotes app from day 15 to use Go Router.

By the end of this day you will know how to use Navigator 2.0 and the Go Router effectively in your Flutter app and provide a seamless and intuitive user experience.

Tips

  • Make sure to review the basics of Navigation from day 15 before diving into Navigator 2.0 and the Go Router.

  • Learn about declarative routing: Navigator 2.0 and the Go Router are both based on the declarative routing approach, which simplifies the process of navigating between screens in your app.

  • Understand the differences between Navigator 2.0 and the Go Router: Both approaches have their own benefits and limitations, so it’s important to understand the differences and choose the one that best fits your needs.

  • Example implementing basic navigation with the Go Router

class MyApp extends StatelessWidget {
  
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'MyApp',
      home: GoRouter(
        routes: [
          GoRoute(
            path: '/',
            pageBuilder: (context, state) => HomePage(),
          ),
          GoRoute(
            path: '/second',
            pageBuilder: (context, state) => SecondPage(),
          ),
        ],
      ),
    );
  }
}

Resources

Enjoying? Tell your friends.

#30DaysMasterFlutter

Learn the basics of Flutter and Dart in 30 days! We provide a roadmap, resources, and project ideas to help you along your journey.

back to 30 Days to Master Flutter

Join our community on Discord to connect with fellow learners, share your progress, and get help with any questions you may have throughout the #30DaysMasterFlutter challenge. Join now and get started on your journey to mastering Dart and Flutter!

join now