network_usage

Data Usage is currently under maintained. This a refactored lib for Data Usage

Getting Started

  • This package fix the following error when building Android
    Class 'DataUsagePlugin' is not abstract and does not implement abstract member public abstract fun onRequestPermissionsResult(p0: Int, p1: Array<(out) String!>, p2: IntArray): Boolean defined in io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener
    
    

Usage for Android

  • Initialize plugin and requests for permission

  • Request Data usage stats

      NetworkUsageModel.init() // Only Required for Android
      List<NetworkUsageModel> networkUsage = await MethodChannelNetworkUsage.networkUsageAndroid(
           withAppIcon: true,
           dataUsageType: NetworkUsageType.wifi,
           oldVersion: false // will be true for Android versions lower than 23 (MARSHMELLOW)
         );
    

This would return:

   [   ...,
       NetworkUsageModel({
            String appName; //App's Name
            String packageName; // App's package name
            Uint8List appIconBytes; // Icon in bytes
            int received; // Amount of data Received
            int sent; // Amount of data sent/transferred
      })
   ]

For more explanation

Usage for iOS

Request for Total data usage on iOS devices

  IOSNetworkUsageModel  networkIOSUsage = await MethodChannelNetworkUsage.networkUsageIOS();

This would return:

  IOSNetworkUsageModel({
     int wifiCompelete, // Total Amount of wifi data (received + sent)
     int wifiReceived, // Amount of wifi data Received
     int wifiSent, // Amount of data sent/transferred
     int wwanCompelete, // Total Amount of mobile data (received + sent)
     int wwanReceived, // Amount of mobile data Received
     int wwanSent // Amount of data sent/transferred
  });