Skip to content

[Bug]: PlatformException: NetworkManager::StartListen when using onConnectivityChanged on WindowsΒ #3713

@MrRoy121

Description

@MrRoy121

Platform

Windows 11 (also occurs on Windows 10)

Plugin

connectivity_plus

Version

7.0.0

Flutter SDK

3.35.7

Steps to reproduce

  1. Create a new Flutter project with Windows support: flutter create -p windows my_app
  2. Add connectivity_plus: ^6.0.5 to pubspec.yaml
  3. Run flutter pub get
  4. Replace lib/main.dart with the code sample below
  5. Run on Windows: flutter run -d windows
  6. Observe the PlatformException being thrown in the console

The error occurs immediately when the app tries to listen to connectivity changes.

Code Sample

**main.dart:**

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

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Connectivity Test',
      home: const ConnectivityTestScreen(),
    );
  }
}

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

  @override
  State<ConnectivityTestScreen> createState() => _ConnectivityTestScreenState();
}

class _ConnectivityTestScreenState extends State<ConnectivityTestScreen> {
  late StreamSubscription<List<ConnectivityResult>> _connectivitySubscription;
  String _status = 'Initializing...';

  @override
  void initState() {
    super.initState();
    _setupConnectivityListener();
  }

  void _setupConnectivityListener() {
    try {
      print('πŸ”΅ Setting up connectivity listener...');
      _connectivitySubscription = Connectivity().onConnectivityChanged.listen(
        (List<ConnectivityResult> result) {
          setState(() {
            _status = 'Connected: ${result.toString()}';
          });
          print('βœ… Connectivity changed: $result');
        },
        onError: (error) {
          print('❌ Error in connectivity stream: $error');
          setState(() {
            _status = 'Error: $error';
          });
        },
      );
      print('βœ… Listener setup successful');
    } catch (e) {
      print('❌ Exception during setup: $e');
      setState(() {
        _status = 'Setup failed: $e';
      });
    }
  }

  @override
  void dispose() {
    _connectivitySubscription.cancel();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Connectivity Plus Test')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text('Status: $_status'),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: () async {
                final result = await Connectivity().checkConnectivity();
                print('Single check result: $result');
              },
              child: const Text('Check Connectivity (Single)'),
            ),
          ],
        ),
      ),
    );
  }
}

Logs

πŸ”΅ Setting up connectivity listener...
======== Exception caught by services library ======================================================
The following PlatformException was thrown while activating platform stream on channel dev.fluttercommunity.plus/connectivity_status:
PlatformException(0, NetworkManager::StartListen, null, null)

When the exception was thrown, this was the stack: 
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7)
#1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:367:18)
<asynchronous suspension>
#2      EventChannel.receiveBroadcastStream.<anonymous closure> (package:flutter/src/services/platform_channel.dart:712:11)
<asynchronous suspension>
#3      Stream.handleError.<anonymous closure> (dart:async/stream.dart:923:13)
<asynchronous suspension>

====================================================================================================

Flutter Doctor

PS C:\Users\RAHMAN\StudioProjects\sms> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.35.7, on Microsoft Windows [Version 10.0.26200.7019], locale en-US)
[√] Windows Version (11 Home Single Language 64-bit, 25H2, 2009)
[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.14.9 (July 2025))
[√] Android Studio (version 2025.1.3)
[√] VS Code (version 1.105.1)
[√] Connected device (4 available)
[√] Network resources

! Doctor found issues in 1 category.
PS C:\Users\RAHMAN\StudioProjects\sms>

Checklist before submitting a bug

  • I searched issues in this repository and couldn't find such bug/problem
  • I Google'd a solution and I couldn't find it
  • I searched on StackOverflow for a solution and I couldn't find it
  • I read the README.md file of the plugin
  • I'm using the latest version of the plugin
  • All dependencies are up to date with flutter pub upgrade
  • I did a flutter clean
  • I tried running the example project

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions