Show an Offline Message for No Internet in Flutter

By Mihir Pipermitwala · · 7 min read

⚡ TL;DR

You have to use the 'Connectivity Flutter Package' to achieve this feature on your App. This package helps to know whether your device is online or offline.

To implement an automatic internet connectivity message in your Flutter app, you’ll use the connectivity_plus package. This package allows you to determine the device’s connectivity status and react accordingly. Follow the steps below to add this functionality to your app.

To show an offline message in Flutter, listen to Connectivity().onConnectivityChanged from the connectivity_plus package and display a banner when the result is ConnectivityResult.none. Keep in mind that connectivity_plus only detects the network interface — a device can report Wi-Fi while the actual internet is down — so for a true online/offline check, pair it with the internet_connection_checker package. Also remember the Android INTERNET permission in your manifest.

Important caveat: connectivityplus tells you whether the device has a _network interface (Wi-Fi, Ethernet, or mobile data), not whether that interface can actually reach the internet. A Wi-Fi network behind a captive portal, or one with its router unplugged, still reports ConnectivityResult.wifi. Use connectivity_plus for fast, free interface changes, and combine it with internet_connection_checker (which pings real hosts) when you need to know if the internet is genuinely reachable. I show both below.

Step 1: Add connectivity_plus to Your pubspec.yaml

First, include the connectivity_plus package in your pubspec.yaml file (plus internet_connection_checker if you want the real reachability check):

Copy
dependencies:
  flutter:
    sdk: flutter
  connectivity_plus: ^6.1.4
  internet_connection_checker: ^1.0.0+1

On Android, also add the internet permission to android/app/src/main/AndroidManifest.xml:

Copy
<uses-permission android:name="android.permission.INTERNET" />

Step 2: Implement the Connectivity Checker

Below is a complete example of how to create a widget that monitors connectivity status and displays an offline message when there is no internet connection.

Copy
import 'dart:async';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:flutter/material.dart';

class CheckConnection extends StatefulWidget {
  
  _CheckConnectionState createState() => _CheckConnectionState();
}

class _CheckConnectionState extends State<CheckConnection> {
  StreamSubscription? internetConnection;
  bool isOffline = false;
  //set variable for Connectivity subscription listener

  
  void initState() {
    internetConnection =
        Connectivity().onConnectivityChanged.listen((connectivityResult) {
      if (connectivityResult.contains(ConnectivityResult.none)) {
        //there is no any connection
        setState(() {
          isOffline = true;
        });
      } else if (connectivityResult.contains(ConnectivityResult.mobile) ||
          connectivityResult.contains(ConnectivityResult.wifi)) {
        //connection is from Wifi or Mobile
        setState(() {
          isOffline = false;
        });
      }
    });
    super.initState();
  }

  
  void dispose() {
    internetConnection?.cancel();
    //cancel internet connection subscription after you are done
    super.dispose();
  }

  
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text(
          "Check Connection",
        ),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: [
            Container(
              child: errorMessage(
                "No Internet Connection Available",
                isOffline,
              ),
              //to show internet connection message on isOffline = true.
            ),
            Container(
              margin: const EdgeInsets.all(
                30,
              ),
              width: double.infinity,
              child: const Center(
                child: Text(
                  "Check Connections",
                  style: TextStyle(
                    fontSize: 20,
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }

  Widget errorMessage(
    String text,
    bool show,
  ) {
    //error message widget.
    if (show == true) {
      //if error is true then show error message box
      return Container(
        padding: const EdgeInsets.all(
          10.00,
        ),
        margin: const EdgeInsets.only(
          bottom: 10.00,
        ),
        color: Colors.red,
        child: Row(children: [
          Container(
            margin: const EdgeInsets.only(
              right: 6.00,
            ),
            child: const Icon(
              Icons.info,
              color: Colors.white,
            ),
          ), // icon for error message

          Text(
            text,
            style: const TextStyle(
              color: Colors.white,
            ),
          ),
          //show error message text
        ]),
      );
    } else {
      //if error is false, return empty container.
      return Container();
    }
  }
}

Note how the errorMessage widget works in the Column above: because isOffline is false at startup, errorMessage returns an empty Container that collapses to zero size. The moment the listener fires with ConnectivityResult.none, setState flips isOffline to true and the same slot re-renders as the red banner. That’s why the banner appears in place at the top of the column rather than pushing your content around unpredictably — keep it as the first child of the Column if you want the message always at the top, and the layout shift stays predictable.

A Full-App Offline Banner with MaterialBanner

Instead of reserving a slot in one screen, you can wrap your entire app in a builder that shows a banner above every page. This pattern listens to connectivity in a small widget and uses a MaterialBanner so the message overlays whatever screen the user is on:

Copy
import 'dart:async';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:flutter/material.dart';

void main() => runApp(const OfflineBannerApp());

class OfflineBannerApp extends StatefulWidget {
  const OfflineBannerApp({super.key});

  
  State<OfflineBannerApp> createState() => _OfflineBannerAppState();
}

class _OfflineBannerAppState extends State<OfflineBannerApp> {
  late final StreamSubscription<List<ConnectivityResult>> _subscription;
  bool _isOffline = false;

  
  void initState() {
    super.initState();
    _subscription = Connectivity().onConnectivityChanged.listen((results) {
      final offline = results.contains(ConnectivityResult.none);
      if (offline != _isOffline) {
        setState(() => _isOffline = offline);
      }
    });
  }

  
  void dispose() {
    _subscription.cancel();
    super.dispose();
  }

  
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Builder(
          builder: (context) {
            if (_isOffline) {
              WidgetsBinding.instance.addPostFrameCallback((_) {
                ScaffoldMessenger.of(context).showMaterialBanner(
                  MaterialBanner(
                    backgroundColor: Colors.red,
                    content: const Text(
                      'No Internet Connection Available',
                      style: TextStyle(color: Colors.white),
                    ),
                    actions: [
                      TextButton(
                        onPressed: () =>
                            ScaffoldMessenger.of(context).hideCurrentMaterialBanner(),
                        child: const Text('Dismiss'),
                      ),
                    ],
                  ),
                );
              });
            } else {
              ScaffoldMessenger.of(context).hideCurrentMaterialBanner();
            }
            return const Center(child: Text('Your app content goes here'));
          },
        ),
      ),
    );
  }
}

The addPostFrameCallback matters: showMaterialBanner can’t be called during the build phase, so we schedule it for right after the frame renders. For the stricter “real internet” check, replace the connectivity listener’s body with await InternetConnectionChecker().hasConnection; (from internet_connection_checker) and use that boolean instead — or debounce it behind the connectivity stream so you only ping when an interface actually goes up or down.

Conclusion

By following the above steps, you can seamlessly integrate an internet connectivity checker into your Flutter app. The connectivity_plus package helps you listen for connectivity changes and update the UI accordingly to inform the user when the device is offline. This enhances the user experience by providing immediate feedback on the network status.

References

FAQ

How do I show an offline message in Flutter?

Add the connectivity_plus package, listen to its onConnectivityChanged stream, and when the results contain ConnectivityResult.none, set a state flag that renders a red banner or MaterialBanner saying no internet connection is available. Remember to cancel the stream subscription in dispose, and add the Android INTERNET permission to your manifest so checks work on Android devices.

Does connectivity_plus actually tell you if the internet is working in Flutter?

No — connectivity_plus only reports the network interface, such as Wi-Fi or mobile data, not real reachability. A router with no internet or a captive portal still reports wifi. For a genuine online check, pair it with the internet_connection_checker package, which pings real hosts and returns a boolean you can drive your offline banner from.

What permission is needed to check internet connectivity in a Flutter Android app?

The Android INTERNET permission must be declared in android/app/src/main/AndroidManifest.xml with a uses-permission tag. Without it, connectivity checks and any network requests fail on Android even though the same code works on iOS or desktop. It is a normal-level permission, so no runtime permission dialog is required from the user.

How can I show an offline banner across every screen in Flutter?

Wrap your app in a builder that listens to connectivity changes and uses ScaffoldMessenger’s showMaterialBanner, which overlays the banner above whatever screen is visible. Call showMaterialBanner inside addPostFrameCallback because it cannot run during the build phase, and call hideCurrentMaterialBanner when connectivity returns so the banner dismisses itself automatically.

Mihir Pipermitwala

Written by Mihir Pipermitwala

Senior Full Stack Consultant & Mobile Engineering Specialist building user-focused applications in healthcare with Flutter, Dart and React Native. I write about what I actually build and test — every tutorial here comes from real project work.

More about Mihir →
Scroll down to load comments...
Related Blogs
Go JSON v2: A Practical Migration Guide to encoding/json/v2

Go JSON v2: A Practical Migration Guide to encoding/json/v2

Migrate a Go REST API to encoding/json/v2 in 7 steps: struct tags, omitempty, unknown fields, error handling, and jsontext streaming, plus a v1 vs v2 comparison.

GOTUTORIALDEVELOPER TOOLS

November 12, 2026

Add an MCP Server to Your Flutter/Dart Tooling

Add an MCP Server to Your Flutter/Dart Tooling

Integrate a Model Context Protocol (MCP) server into your Flutter/Dart workflow. Step-by-step setup with Claude Code and real-world use cases.

AI TOOLSMCPFLUTTERDARTDEVELOPER TOOLS

October 06, 2026

Flutter On-Device LLM: Run Gemma & Llama Locally (2026)

Flutter On-Device LLM: Run Gemma & Llama Locally (2026)

Run on-device LLMs in Flutter using gemma_flutter and MediaPipe LLM Inference. No API keys, no internet — real-time AI on Android and iOS.

FLUTTERAI MLON DEVICE LLMGEMMALLAMA

September 24, 2026

How to Change minSdkVersion in Flutter: 2 Simple Approaches

How to Change minSdkVersion in Flutter: 2 Simple Approaches

Step-by-step guide to change the minSdkVersion in Flutter for Android. Learn how to configure local.properties or build.gradle for both new and old Flutter versions.

ANDROIDFLUTTERFLUTTER DEVELOPMENTMIN SDK VERSION

July 20, 2023

Related Tutorials
Essential Git Skills: How to Delete Remote Branches

Essential Git Skills: How to Delete Remote Branches

Keep your repository clean and organized. This guide walks you through how to delete both local and remote branches in Git, step by step.

BITBUCKETDELETE LOCAL BRANCHDELETE REMOTE BRANCHGITGIT BRANCH CLEANUP AUTOMATION

June 12, 2024

A Comprehensive Guide to Flutter Buttons: Choosing the Right One for Your App

A Comprehensive Guide to Flutter Buttons: Choosing the Right One for Your App

Complete guide to Flutter Button widgets. Learn how to use ElevatedButton, TextButton, OutlinedButton, IconButton, CupertinoButton, and FAB with examples.

CUPERTINO BUTTONELEVATED BUTTONFLOATING ACTION BUTTONFLUTTERFLUTTER BUTTON

April 17, 2024

Show an Offline Message for No Internet in Flutter

Show an Offline Message for No Internet in Flutter

You have to use the 'Connectivity Flutter Package' to achieve this feature on your App. This package helps to know whether your device is online or offline.

CONNECTIVITY PLUSDEPENDENCIESFLUTTERFLUTTER DEVELOPMENTFLUTTER PACKAGES

April 09, 2024

Mastering TabBar & TabBarView in Flutter: A Complete Guide

Mastering TabBar & TabBarView in Flutter: A Complete Guide

Implement TabBar and TabBarView in Flutter step by step — customize tab indicators, enable scrollable tabs, and change tabs programmatically.

CODINGDEFAULT TAB CONTROLLERFLUTTERLEARN TO CODETAB CONTROLLER

July 26, 2023

Related Recommended Services
Visual Studio Code for the Web

Visual Studio Code for the Web

Build with Visual Studio Code, anywhere, anytime, in your browser.

IDEVISUAL STUDIOVISUAL STUDIO CODEWEB
Renovate | Automated Dependency Updates

Renovate | Automated Dependency Updates

Renovate Bot keeps source code dependencies up-to-date using automated Pull Requests.

AUTOMATED DEPENDENCY UPDATESBUNDLERCOMPOSERGITHUBGO MODULES
Best XML Formatter and XML Beautifier

Best XML Formatter and XML Beautifier

Online XML Formatter will format xml data, helps to validate, and works as XML Converter. Save and Share XML.

XMLXML BEAUTIFIERXML CONVERTERXML FORMATXML FORMATTER
Kubecost | Kubernetes cost monitoring and management

Kubecost | Kubernetes cost monitoring and management

Kubecost started in early 2019 as an open-source tool to give developers visibility into Kubernetes spend. We maintain a deep commitment to building and supporting dedicated solutions for the open source community.

CLOUDKUBECOSTKUBERNETESOPEN SOURCESELF HOSTED
Related Recommended Stories
How GitHub reduced testing time for iOS apps with new runner features

How GitHub reduced testing time for iOS apps with new runner features

Learn how GitHub used macOS and Apple Silicon runners for GitHub Actions to build, test, and deploy our iOS app faster.

IOSGITHUBTESTINGRUNNER
5 ways to transform your workflow using GitHub Copilot and MCP

5 ways to transform your workflow using GitHub Copilot and MCP

Learn how to streamline your development workflow with five different MCP use cases.

AGENT MODECODING AGENTCOPILOTFIGMAGITHUB
One weird trick for powerful Git aliases

One weird trick for powerful Git aliases

Advanced Git Aliases

ALIASALIAS TEMPLATEATLASSIANBITBUCKETGIT
Awesome Python

Awesome Python

An opinionated list of awesome Python frameworks, libraries, software and resources

AWESOMEAWESOME PYTHONCOLLECTIONSGITHUBPYTHON
Related Recommended Tools
Find out what websites are built with - Wappalyzer

Find out what websites are built with - Wappalyzer

Find out the technology stack of any website. Create lists of websites and contacts by the technologies they use.

ADD ONSANALYTICSAPP STOREAPPLEBOOKING
Sourcetree | Free Git GUI for Mac and Windows

Sourcetree | Free Git GUI for Mac and Windows

A Git GUI that offers a visual representation of your repositories. Sourcetree is a free Git client for Windows and Mac.

GITGITHUBGITLABATLASSIANBITBUCKET
Related Recommended Videos