### Example pubspec.yaml Entry Source: https://pub.dev/packages/connectivity_plus_linux/install This is an example of how the dependency will appear in your pubspec.yaml file after running the add command. ```yaml dependencies: connectivity_plus_linux: ^1.3.1 ``` -------------------------------- ### Connectivity Plus Example App Source: https://pub.dev/packages/connectivity_plus/example This is the main example application demonstrating the usage of the connectivity_plus package. It initializes connectivity checks, listens for changes, and displays the current connection status. ```dart // Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // ignore_for_file: public_member_api_docs import 'dart:async'; import 'dart:developer' as developer; import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( useMaterial3: true, colorSchemeSeed: const Color(0x9f4376f8), ), home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({Key? key, required this.title}) : super(key: key); final String title; @override State createState() => _MyHomePageState(); } class _MyHomePageState extends State { List _connectionStatus = [ConnectivityResult.none]; final Connectivity _connectivity = Connectivity(); late StreamSubscription> _connectivitySubscription; @override void initState() { super.initState(); initConnectivity(); _connectivitySubscription = _connectivity.onConnectivityChanged.listen(_updateConnectionStatus); } @override void dispose() { _connectivitySubscription.cancel(); super.dispose(); } // Platform messages are asynchronous, so we initialize in an async method. Future initConnectivity() async { late List result; // Platform messages may fail, so we use a try/catch PlatformException. try { result = await _connectivity.checkConnectivity(); } on PlatformException catch (e) { developer.log('Couldn\'t check connectivity status', error: e); return; } // If the widget was removed from the tree while the asynchronous platform // message was in flight, we want to discard the reply rather than calling // setState to update our non-existent appearance. if (!mounted) { return Future.value(null); } return _updateConnectionStatus(result); } Future _updateConnectionStatus(List result) async { setState(() { _connectionStatus = result; }); // ignore: avoid_print print('Connectivity changed: $_connectionStatus'); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Connectivity Plus Example'), elevation: 4, ), body: Column( mainAxisSize: MainAxisSize.min, children: [ const Spacer(flex: 2), Text( 'Active connection types:', style: Theme.of(context).textTheme.headlineMedium, ), const Spacer(), ListView( shrinkWrap: true, children: List.generate( _connectionStatus.length, (index) => Center( child: Text( _connectionStatus[index].toString(), style: Theme.of(context).textTheme.headlineSmall, ), )), ), const Spacer(flex: 2), ], ), ); } } ``` -------------------------------- ### Example pubspec.yaml Dependency Source: https://pub.dev/packages/connectivity_plus_macos/install This is an example of how the dependency will appear in your pubspec.yaml file after running the add command. ```yaml dependencies: connectivity_plus_macos: ^1.2.6 ``` -------------------------------- ### Import connectivity_plus_windows in Dart Source: https://pub.dev/packages/connectivity_plus_windows/install Import the package into your Dart code to start using its functionalities. ```dart import 'package:connectivity_plus_windows/connectivity_plus_windows.dart'; ``` -------------------------------- ### Import connectivity_plus_web in Dart Source: https://pub.dev/packages/connectivity_plus_web/install Import the package into your Dart code to start using its functionalities. ```dart import 'package:connectivity_plus_web/connectivity_plus_web.dart'; ``` -------------------------------- ### Import connectivity_plus_linux in Dart Source: https://pub.dev/packages/connectivity_plus_linux/install Import the package into your Dart code to start using its functionalities. Ensure you have added the dependency first. ```dart import 'package:connectivity_plus_linux/connectivity_plus_linux.dart'; ``` -------------------------------- ### Import connectivity_plus in Dart Source: https://pub.dev/packages/connectivity_plus/install Import the connectivity_plus package into your Dart files to start using its functionalities. ```dart import 'package:connectivity_plus/connectivity_plus.dart'; ``` -------------------------------- ### Check Current Connectivity Source: https://pub.dev/packages/connectivity_plus Use this snippet to get a list of currently available network connectivity types. Note that system behavior may vary, especially on Android when both Wi-Fi and mobile data are active. ```dart import 'package:connectivity_plus/connectivity_plus.dart'; final List connectivityResult = await (Connectivity().checkConnectivity()); // This condition is for demo purposes only to explain every connection type. // Use conditions which work for your requirements. if (connectivityResult.contains(ConnectivityResult.mobile)) { // Mobile network available. } else if (connectivityResult.contains(ConnectivityResult.wifi)) { // Wi-fi is available. // Note for Android: // When both mobile and Wi-Fi are turned on system will return Wi-Fi only as active network type } else if (connectivityResult.contains(ConnectivityResult.ethernet)) { // Ethernet connection available. } else if (connectivityResult.contains(ConnectivityResult.vpn)) { // Vpn connection active. // Note for iOS and macOS: // There is no separate network interface type for [vpn]. // It returns [other] on any device (also simulator) } else if (connectivityResult.contains(ConnectivityResult.bluetooth)) { // Bluetooth connection available. } else if (connectivityResult.contains(ConnectivityResult.satellite)) { // Carrier-provided satellite network available } else if (connectivityResult.contains(ConnectivityResult.other)) { // Connected to a network which is not in the above mentioned networks. } else if (connectivityResult.contains(ConnectivityResult.none)) { // No available network types } ``` -------------------------------- ### Add connectivity_plus_windows Dependency Source: https://pub.dev/packages/connectivity_plus_windows/install Run this command to add the package to your Flutter project's dependencies. This command automatically updates your pubspec.yaml file. ```bash $ flutter pub add connectivity_plus_windows ``` -------------------------------- ### Basic Flutter App Structure Source: https://pub.dev/packages/connectivity_plus_web/example This snippet shows a minimal Flutter application structure for integration testing purposes. It includes the necessary imports and a basic StatefulWidget. ```dart import 'package:flutter/material.dart'; void main() => runApp(MyApp()); /// App Testing class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State { @override Widget build(BuildContext context) { return Text('A Placeholder file for integration tests.'); } } ``` -------------------------------- ### Import connectivity_plus_platform_interface in Dart Source: https://pub.dev/packages/connectivity_plus_platform_interface/install Import the package into your Dart files to use its functionalities. ```dart import 'package:connectivity_plus_platform_interface/connectivity_plus_platform_interface.dart'; ``` -------------------------------- ### MIT License for connectivity_plus Source: https://pub.dev/packages/connectivity_plus/license This is the standard MIT license text for the connectivity_plus package. It outlines the terms of use, modification, and distribution. ```plaintext Copyright 2017 The Chromium Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ``` -------------------------------- ### Add connectivity_plus_platform_interface Dependency Source: https://pub.dev/packages/connectivity_plus_platform_interface/install Use this command to add the package to your Flutter project's pubspec.yaml file. ```bash $ flutter pub add connectivity_plus_platform_interface ``` -------------------------------- ### Add connectivity_plus_linux Dependency Source: https://pub.dev/packages/connectivity_plus_linux/install Run this command to add the connectivity_plus_linux package to your Flutter project. This command automatically updates your pubspec.yaml file. ```bash $ flutter pub add connectivity_plus_linux ``` -------------------------------- ### BSD 3-Clause License Source: https://pub.dev/packages/connectivity_plus_macos/license This snippet contains the full license text for the connectivity_plus_macos package. It outlines redistribution and modification permissions. ```plaintext // Copyright 2019 The Chromium Authors. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ``` -------------------------------- ### Add connectivity_plus_web Dependency Source: https://pub.dev/packages/connectivity_plus_web/install Use this command to add the package to your Flutter project's dependencies. It automatically updates your pubspec.yaml file. ```bash $ flutter pub add connectivity_plus_web ``` -------------------------------- ### MIT License for connectivity_plus_web Source: https://pub.dev/packages/connectivity_plus_web/license This is the standard MIT license text for the Flutter project authors. It outlines the terms under which the software can be used, modified, and distributed. ```plaintext Copyright 2016, the Flutter project authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ``` -------------------------------- ### BSD 3-Clause License Source: https://pub.dev/packages/connectivity_plus_linux/license This is the standard BSD 3-Clause license text for the connectivity_plus_linux package. It outlines the terms under which the software can be used, modified, and distributed. ```text // Copyright 2020 The Chromium Authors. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ``` -------------------------------- ### Undefined Method Error in NetworkInformationApiConnectivityPlugin Source: https://pub.dev/packages/connectivity_plus_web/score This error signifies that methods like 'setProperty' and 'allowInterop' are not recognized within the 'NetworkInformationApiConnectivityPlugin' class. This often points to incorrect usage of JavaScript interop or missing definitions for these methods. ```dart setProperty(_networkInformation, 'onchange', allowInterop((_) { ``` -------------------------------- ### Import connectivity_plus_macos in Dart Code Source: https://pub.dev/packages/connectivity_plus_macos/install Include this import statement in your Dart files to access the functionality provided by the connectivity_plus_macos plugin. ```dart import 'package:connectivity_plus_macos/connectivity_plus_macos.dart'; ``` -------------------------------- ### Add connectivity_plus_macos to Flutter Project Source: https://pub.dev/packages/connectivity_plus_macos/install Use this command to add the package as a dependency in your Flutter project. This command automatically updates your pubspec.yaml file. ```bash $ flutter pub add connectivity_plus_macos ``` -------------------------------- ### Add connectivity_plus Dependency Source: https://pub.dev/packages/connectivity_plus/install Add the connectivity_plus package to your Flutter project's dependencies by running this command in your terminal. ```bash $ flutter pub add connectivity_plus ``` -------------------------------- ### Process Exited Successfully Source: https://pub.dev/packages/connectivity_plus_linux/score/log.txt Indicates that a process executed by the score system has completed successfully with an exit code of 0. ```text ### Execution of process exited 0 STOPPED: 2026-05-28T14:18:05.284719Z ``` -------------------------------- ### Import dart:js_util Error Source: https://pub.dev/packages/connectivity_plus_web/score This error indicates that the 'dart:js_util' library is not found, which is necessary for interacting with JavaScript APIs in Flutter web applications. Ensure the correct Flutter SDK and web support are configured. ```dart import 'dart:js_util'; ``` -------------------------------- ### Listen for Connectivity Changes Source: https://pub.dev/packages/connectivity_plus Subscribe to stream changes in network connectivity types. This method ensures that only distinct values are emitted. Remember to cancel the subscription when it's no longer needed, typically in the dispose method of a widget. ```dart import 'package:connectivity_plus/connectivity_plus.dart'; import 'dart:async'; class MyWidget extends StatefulWidget { @override _MyWidgetState createState() => _MyWidgetState(); } class _MyWidgetState extends State { StreamSubscription>? subscription; @override void initState() { super.initState(); subscription = Connectivity().onConnectivityChanged.listen((List result) { // Received changes in available connectivity types! }); } // Be sure to cancel subscription after you are done @override void dispose() { subscription?.cancel(); super.dispose(); } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.