Internet Availability

A Flutter package which check the internet availability and push a new page on top of the current route if internet is not available. Once the internet is available that page will automatically pop to previous route.

Note: The package will only work with go_router



Getting started

flutter pub add internet_availability
flutter pub get


  • In your routes list add one more route
      path: NoInternetPage.routeName,
      builder: (context, state) => const NoInternetPage(),

The route should not be a nested route. You can provide any value to path property and even your own Widget to builder property.

  • add redirect and refreshListenable property of GoRouter and paste below code
redirect: (context, state) {
    switch (InternetAvailabilityConfig.showNoInternetPage()) {
      case true:
        InternetAvailabilityConfig.prevRoute = state.subloc;
        return NoInternetPage.routeName; //page route path
      case false:
        return InternetAvailabilityConfig.prevRoute;
        return null;
refreshListenable: RefreshStream(,

Note: For go_router version lower than 5.0 use GoRouterRefreshStream and redirect will only take state as an argument.

refreshListenable: GoRouterRefreshStream(,

Additional Information

check the example repository of the project for complete code.