internet_speed_test 1.1.2+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 88

internet_speed_test #

Internet speed test plugin to integrate it in your app whenever you want.

Get started #

Add dependency #

dependencies:
  internet_speed_test: ^1.1.2+1

Example #


  import 'package:internet_speed_test/internet_speed_test.dart';

  final internetSpeedTest = InternetSpeedTest();

  internetSpeedTest.startDownloadTesting(
     onDone: (double transferRate, SpeedUnit unit) {
        // TODO: Change UI
     },
     onProgress: (double percent, double transferRate, SpeedUnit unit) {
        // TODO: Change UI
     },
     onError: (String errorMessage, String speedTestError) {
        // TODO: Show toast error
     },
   );



  internetSpeedTest.startUploadTesting(
     onDone: (double transferRate, SpeedUnit unit) {
       print('the transfer rate $transferRate');
       setState(() {
         // TODO: Change UI
       });
     },
     onProgress: (double percent, double transferRate, SpeedUnit unit) {
       print(
           'the transfer rate $transferRate, the percent $percent');
       setState(() {
         // TODO: Change UI
       });
     },
     onError: (String errorMessage, String speedTestError) {
       // TODO: Show toast error
     },
  );

Additional features #

You can also configure your test server URL


  import 'package:internet_speed_test/internet_speed_test.dart';

  final internetSpeedTest = InternetSpeedTest();

  internetSpeedTest.startDownloadTesting(
     onDone: (double transferRate, SpeedUnit unit) {
        // TODO: Change UI
     },
     onProgress: (double percent, double transferRate, SpeedUnit unit) {
        // TODO: Change UI
     },
     onError: (String errorMessage, String speedTestError) {
        // TODO: Show toast error
     },
     testServer: //Your test server URL goes here,
   );



  internetSpeedTest.startUploadTesting(
     onDone: (double transferRate, SpeedUnit unit) {
       print('the transfer rate $transferRate');
       setState(() {
         // TODO: Change UI
       });
     },
     onProgress: (double percent, double transferRate, SpeedUnit unit) {
       print(
           'the transfer rate $transferRate, the percent $percent');
       setState(() {
         // TODO: Change UI
       });
     },
     onError: (String errorMessage, String speedTestError) {
       // TODO: Show toast error
     },
     testServer: //Your test server URL goes here,
  );

If you don't provide a customized server URL we'll be using this URL for downloading http://ipv4.ikoula.testdebit.info/1M.iso

And this for uploading http://ipv4.ikoula.testdebit.info/

Contributors #

The major contributor that made this package better for the iOS platform is Akshat Sharma so a huge shoutout to him!

Platforms #

The package is working on both platforms iOS & Android!

Shoutout #

Shoutout to JSpeedTest

1.1.2+1 #

  • Fix upload timeout with iOS

1.1.2 #

  • Fix iOS download & upload issue

1.1.1 #

  • Fix iOS build issue

1.1.0 #

  • Adding the ability to customize your speed test server

1.0.2 #

  • Implement for iOS

1.0.1+1 #

  • Fix readme

1.0.1 #

  • Always return transfer rate with Mb/s instead of Kb/s

1.0.0 #

  • Initial release supporting download and upload internet speed test, working for Android only.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:internet_speed_test/internet_speed_test.dart';
import 'package:internet_speed_test/callbacks_enum.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final internetSpeedTest = InternetSpeedTest();

  double downloadRate = 0;
  double uploadRate = 0;
  String downloadProgress = '0';
  String uploadProgress = '0';

  String unitText = 'Mb/s';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                children: <Widget>[
                  Text('Progress $downloadProgress%'),
                  Text('Download rate  $downloadRate $unitText'),
                ],
              ),
              RaisedButton(
                child: Text('start testing'),
                onPressed: () {
                  internetSpeedTest.startDownloadTesting(
                    onDone: (double transferRate, SpeedUnit unit) {
                      print('the transfer rate $transferRate');
                      setState(() {
                        downloadRate = transferRate;
                        unitText = unit == SpeedUnit.Kbps ? 'Kb/s' : 'Mb/s';
                        downloadProgress = '100';
                      });
                    },
                    onProgress:
                        (double percent, double transferRate, SpeedUnit unit) {
                      print(
                          'the transfer rate $transferRate, the percent $percent');
                      setState(() {
                        downloadRate = transferRate;
                        unitText = unit == SpeedUnit.Kbps ? 'Kb/s' : 'Mb/s';
                        downloadProgress = percent.toStringAsFixed(2);
                      });
                    },
                    onError: (String errorMessage, String speedTestError) {
                      print(
                          'the errorMessage $errorMessage, the speedTestError $speedTestError');
                    },
                    testServer: 'https://speedtest.takamol.sy.prod.hosts.ooklaserver.net:8080/download?nocache=bc6eaf4b-8d4d-4756-9f77-9512655f6b2c&size=25000000&guid=ea24b1a6-eab7-4316-99d1-1971305e05d8',
                    fileSize: 20000000,
                  );
                },
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                children: <Widget>[
                  Text('Progress $uploadProgress%'),
                  Text('Upload rate  $uploadRate Kb/s'),
                ],
              ),
              RaisedButton(
                child: Text('start testing'),
                onPressed: () {
                  internetSpeedTest.startUploadTesting(
                    onDone: (double transferRate, SpeedUnit unit) {
                      print('the transfer rate $transferRate');
                      setState(() {
                        uploadRate = transferRate;
                        unitText = unit == SpeedUnit.Kbps ? 'Kb/s' : 'Mb/s';
                        uploadProgress = '100';
                      });
                    },
                    onProgress:
                        (double percent, double transferRate, SpeedUnit unit) {
                      print(
                          'the transfer rate $transferRate, the percent $percent');
                      setState(() {
                        uploadRate = transferRate;
                        unitText = unit == SpeedUnit.Kbps ? 'Kb/s' : 'Mb/s';
                        uploadProgress = percent.toStringAsFixed(2);
                      });
                    },
                    onError: (String errorMessage, String speedTestError) {
                      print(
                          'the errorMessage $errorMessage, the speedTestError $speedTestError');
                    },
                    testServer: 'https://speedtest.takamol.sy.prod.hosts.ooklaserver.net:8080/upload?nocache=a3fd0f07-a5f0-434c-900c-7aa5fd102858&guid=ea24b1a6-eab7-4316-99d1-1971305e05d8',
                    fileSize: 20000000,
                  );
                },
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  internet_speed_test: ^1.1.2+1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:internet_speed_test/internet_speed_test.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
75
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
88
Learn more about scoring.

We analyzed this package on Jul 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because:

  • package:internet_speed_test/internet_speed_test.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because:

  • package:internet_speed_test/internet_speed_test.dart that declares support for platforms: android, ios

Package does not support Flutter platform web

Because:

  • package:internet_speed_test/internet_speed_test.dart that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because:

  • package:internet_speed_test/internet_speed_test.dart that declares support for platforms: android, ios

Package not compatible with SDK dart

Because:

  • internet_speed_test that is a package requiring null.

Health suggestions

Format lib/internet_speed_test.dart.

Run flutter format to format lib/internet_speed_test.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
tuple ^1.0.3 1.0.3
Transitive dependencies
collection 1.14.12 1.14.13
matcher 0.12.8
meta 1.1.8 1.2.2
path 1.7.0
quiver 2.1.3
sky_engine 0.0.99
stack_trace 1.9.5
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test