pub package

Get current internet conenction information from within the Flutter application.

Platform Support

Android iOS MacOS Web Linux Windows
✔️ ✔️ ✔️ ✔️ ✔️ ✔️


If you like our work, please consider supporting us for coffees and future developments. You can sponsor us by clicking the below link to proceed.


Import package:connection_info/connection_info.dart, instantiate ConnectionController and listen to the stream for internet connection status or check directly using the isConnected() async method.

Note: ConnectionState will conflict with package dart:async, so we import connection state as follows:

import 'package:connection_info/models/connection_state.dart'
    as connection_state;

1. ConnectionController

The ConnectionController class has one constructor. By default, the serverUrl is set to, repeatInterval to check for internet connection is set to 1 second and showErrorInDebugMode is set to false.


    {String serverUrl = '',
    Duration repeatInterval = const Duration(seconds: 1),
    bool showErrorInDebugMode = false,

The ConnectionController has one public stream named stream that will return a ConnectionState object both on data and error state. Similarly, we can use Future<ConnectionState> isConnected() async method of ConnectionController class to check the current status of the internet.

The idea here is, we only want to know whether there is internet or not. Not, how internet is provided to us. So, we only check if there is internet or not at any given time periodically using repeatInterval.

2. ConnectionState

The ConnectionState is a wrapper around a bool. It returns the current state of the internet connection. At any time, it is either true or false.


ConnectionState(bool isConnected: false)


class NetworkConnectionTestScreen extends StatefulWidget {
  const NetworkConnectionTestScreen({Key? key}) : super(key: key);

  State<NetworkConnectionTestScreen> createState() =>

class _NetworkConnectionTestScreenState
    extends State<NetworkConnectionTestScreen> {
  StreamSubscription? connectionSubscription;

  bool _isConnected = true;
  void initState() {

    ConnectionController _controller = ConnectionController(
      serverUrl: '',
      repeatInterval: const Duration(seconds: 1),
      showErrorInDebugMode: false,

    connectionSubscription = {

      if (event is connection_state.ConnectionState) {
        setState(() {
          _isConnected = event.isConnected;

  void dispose() {

  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(child: Text('Has Internet: $_isConnected')),