Flutter Network Type Plugin

Pub Version GitHub license GitHub stars

A Flutter plugin to determine the network type and measure network speed.


  • Detects the network type (e.g., 4G, 3G, 2G).
  • Measures network speed and confirms if the network type is correctly detected.


Add flutter_network_type_plugin as a dependency in your pubspec.yaml file:

    sdk: flutter
  flutter_network_type_plugin: ^0.2.1

Then run flutter pub get to install the package.



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

void main() {

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

  Widget build(BuildContext context) {
    return MaterialApp(
      home: NetworkCheck(),

class NetworkCheck extends StatefulWidget {
  _NetworkCheckState createState() => _NetworkCheckState();

class _NetworkCheckState extends State<NetworkCheck> {
  String _networkType = 'Unknown';

  void initState() {

  Future<void> _getNetworkType() async {
    String networkType;
    try {
      networkType = await FlutterNetworkTypePlugin.getNetworkType(
        url: 'https://www.google.com', // User-defined URL
        speedThreshold: 5.0, // User-defined speed threshold in Mbps
    } on PlatformException catch (e) {
      networkType = "Failed to get network type: '${e.message}'.";
    setState(() {
      _networkType = networkType;

  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Network Check'),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text('Network Type: $_networkType'),
      floatingActionButton: FloatingActionButton(
        onPressed: _getNetworkType,
        tooltip: 'Refresh',
        child: Icon(Icons.refresh),



Fetches the network type. Optionally, you can provide a URL to test the speed and a speed threshold to confirm the network type.

url (String, optional): The URL to use for the speed test. speedThreshold (double, optional): The speed threshold in Mbps to confirm the network type. maxRetries (int, optional): The maximum number of retries for the speed test. Default is 0. retryDelay (double, optional): The delay between retries in seconds. Default is 1.0. timeout (double, optional): The timeout for the speed test in seconds. Default is 5.0.


Run the tests to ensure everything is working correctly:

flutter test flutter drive --target=test_driver/app.dart Contributing Contributions are welcome! Please see CONTRIBUTING.md for details.


This project is licensed under the MIT License - see the LICENSE file for details.


If you encounter any issues or have questions, feel free to open an issue on GitHub.


Developed by Nurshat - nurshat170@gmail.com

Happy coding!