speed_checker_plugin 1.0.22 copy "speed_checker_plugin: ^1.0.22" to clipboard
speed_checker_plugin: ^1.0.22 copied to clipboard

Flutter plugin for SpeedChecker SDK

SpeedChecker Flutter Plugin #

pub package

Free speed test features for your own app #

SpeedChecker Flutter plugin allows developers to integrate speed test features into their own flutter apps. You can also try our apps on Google Play and App Store, they are powered by the latest Speedchecker SDK versions. More information about SpeedChecker SDKs

Features #

  • latency, download and upload speed of the user connection
  • robust measuring of cellular, wireless and even local network
  • testing details like the current speed and progress
  • additional information like network type and location (see KPI list below in FAQ)
  • included high-capacity servers provided and maintained by Speedchecker or custom servers
  • detailed statistics and reports by Speedchecker

Platform Support #

Android iOS
supported ✔️ supported ✔️

Requirements #

Android

  • minSdkVersion 21
  • Location permissions

By default, flutter projects have minSdkVersion set to 16. You need to change this to 21. You can find this setting in build. gradle file: Your_project_folder/android/app/build.gradle

    defaultConfig {
    applicationId "com.example.test_project"
        minSdkVersion flutter.minSdkVersion  //REPLACE "flutter.minSdkVersion" to 21 
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
     }

iOS

  • Xcode 13.3.1 or later
  • Swift 5
  • Development Target 11.0 or later

Installation #

1. Run in the terminal:

$ flutter pub add speed_checker_plugin

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  speed_checker_plugin: ^1.0.22

2. Import speed_checker_plugin in your Dart class.

import 'package:speed_checker_plugin/speed_checker_plugin.dart';

Permission requirements #

Free version of the plugin requires location permission to be able to perform a speed test. You need to handle location permission in your app level. When no location permission is given, the app will return in onError method the corresponding message, so you need to request both Foreground and Background location permissions in your app before starting the speed test. Check out our location policy

If you are a paid user, you should set license key before you start test. Please contact us and we will provide you with licenseKey for your app.

Usage #

1. Create an instance of 'SpeedCheckerPlugin' class, StreamSubscription object to listen events from SpeedCheckerPlugin and all variables you need to store speed test results

final _plugin = SpeedCheckerPlugin();
late StreamSubscription<SpeedTestResult> _subscription;
String _status = '';
int _ping = 0;
String _server = '';
String _connectionType = '';
double _currentSpeed = 0;
int _percent = 0;
double _downloadSpeed = 0;
double _uploadSpeed = 0;
String _ip = '';
String _isp = '';

2. Set license key (for paid clients).

if you have a license key, you can add your key as a String value in the app:

_plugin.setAndroidLicenseKey('your_license_key');
_plugin.setIosLicenseKey('your_license_key');

Licenses should be set before starting the test. Make sure your package name (for Android) or bundle id (for iOS) is the same as defined in your license agreement. You can use both methods simultaneously if you have licenses for both platforms

3. Start 'startSpeedTest' method in your class.

You can start this method on custom event, such as button click

_plugin.startSpeedTest();

Plugin supports starting speed test with custom server 'startSpeedTestWithServer'.

_plugin.startSpeedTestWithServer(
  const SpeedTestServer(
    domain: 'dig20ny.speedcheckerapi.com',
    downloadFolderPath: '/',
    uploadFolderPath: '/',
    city: 'New York 2',
    country: 'USA',
    countryCode: 'US',
    id: 104
  )
);

4. Listen to 'speedTestResultStream'. You can also handle errors and update UI accordingly. Don't forget to cancel subscription after stopping the test or on receiving error

_subscription = _plugin.speedTestResultStream.listen((result) {
  setState(() {
    _status = result.status;
    _ping = result.ping;
    _percent = result.percent;
    _currentSpeed = result.currentSpeed;
    _downloadSpeed = result.downloadSpeed;
    _uploadSpeed = result.uploadSpeed;
    _server = result.server;
    _connectionType = result.connectionType;
    _ip = result.ip;
    _isp = result.isp;
    
    //if you want to show errors in toast messages, use the Fluttertoast library or you can handle errors in different way. 
    if(result.error.isNotEmpty) {
      Fluttertoast.showToast(msg: result.error.toString());
    }
});
}, onDone: () {
  _subscription.cancel();
}, onError: (error) {
  _status = error.toString();
  _subscription.cancel();
});

});

5. If you need to stop speed test, you can call plugin's 'stopTest' method. It will immediately interrupt speed test

  void stopTest() {
  _plugin.stopTest();
  _subscription = _plugin.speedTestResultStream.listen((result) {
    setState(() {
      _status = "Speed test stopped";
      _ping = 0;
      _percent = 0;
      _currentSpeed = 0;
      _downloadSpeed = 0;
      _uploadSpeed = 0;
      _server = '';
      _connectionType = '';
      _ip = '';
      _isp = '';
    });
  }, onDone: () {
    _subscription.cancel();
  });

  }

6. Do not forget to close the stream to prevent memory leaks. It can be done by overriding 'dispose' method

@override
  void dispose() {
    _plugin.dispose();
    super.dispose();
}

Demo application #

Please check our demo application in Flutter which includes speed test functionality as well as speedometer UI.

License #

SpeedChecker is offering different types of licenses:

Items Free Basic Advanced
Speed Test Metrics Download / Upload / Latency Download / Upload / Latency / Jitter Download / Upload / Latency / Jitter
Accompanying Metrics Device / Network KPIs Device / Network KPIs Device / Network KPIs / Advanced Cellular KPIs
Test Customization - test duration, multi-threading, warm-up phase etc test duration, multi-threading, warm-up phase etc
Location Permission Required location permissions - -
Data Sharing Requirement Required data sharing - -
Measurement Servers - Custom measurement servers Custom measurement servers
Background and passive collection - - Background and Passive data collection
Cost FREE Cost: Enquire Cost: Enquire

FAQ #

Is the SDK free to use? #

Yes! But the SDK collects data on network performance from your app and shares it with Speedchecker and our clients. The free SDK version requires and enabled location. Those restrictions are not in the Basic and Advanced versions

Do you have also native SDKs? #

Yes, we have both Android and iOS SDKs.

Do you provide other types of tests? #

Yes! YouTube video streaming, Voice over IP and other tests are supported by our native SDK libraries. Check out our Android and iOS API documentation

Do you provide free support? #

No, we provide support only on Basic and Advanced plans

What are all the metrics or KPIs that you can get using our native SDKs? #

The free version of our plugin allows getting basic metrics which are described in this API documentation

Full list of our KPIs for Basic and Advanced versions

Do you host all infrastructure for the test? #

Yes, you do not need to run any servers. We provide and maintain a network of high-quality servers and CDNs to ensure the testing is accurate. If you wish to configure your own server, this is possible on Basic and Advanced plans.

How do you measure the speed? #

See our measurement methodology

What's next? #

Please contact us for more details and license requirements.