搜索插件、代码仓与 APP 分类

data_usage 封面
插件详情v1.0.3

data_usage

一个用于在移动设备上获取数据使用情况的 Flutter 插件

AndroidiOS
近 30 天下载
65
喜欢数
22
Pub 分数
120

安装插件

flutter pub add data_usage

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

data_usage 包是一个 Flutter 插件,可让开发者在 Android 和 iOS 设备上获取实时数据使用统计信息。它提供对蜂窝网络和 Wi-Fi 数据消耗的访问,帮助用户监控其网络使用情况。该插件专为跨平台兼容性设计,可轻松集成到 Flutter 应用中,设置简单。该插件利用原生设备 API 以确保数据收集的准确性,非常适合专注于网络管理、计费或用户意识的应用程序。其轻量级设计确保了高效性能,且不会影响应用的响应速度。

适合场景

  • 监控移动数据使用情况
  • 构建网络使用情况仪表板
  • 在应用程序中集成数据警报
  • 支持计费或配额系统
  • 创建网络健康监控工具

主要特点

  • 跨平台支持(Android 和 iOS)
  • 实时数据使用情况检索
  • 最小设置和集成
  • 准确的原生 API 访问
  • 轻量且高效

适合对象

  • 网络监控应用
  • 移动实用工具
  • 计费和配额跟踪
  • 面向用户的数据显示仪表板
  • 网络分析的开发工具

使用建议

  • 需要在两个平台上具备相应的权限
  • 数据准确性可能因设备制造商而异
  • 仅限基本数据使用指标
  • 可能需要后台执行权限
  • 网页或桌面平台不可用

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Data Usage

Data Usage gets Mobile/Wifi data usage values from mobile devices, on android it will fetch the data per app but due to current limitations on ios it can only give the total/complete values of overall data used.

Screen Shots

Usage for Android

  • Initialize plugin and requests for permission
  • Request Data usage stats
  DataUsageModel.init() // Only Required for Android
  List<DataUsageModel> dataUsage = await DataUsage.dataUsageAndroid(
     withAppIcon: true, // if false `DataUsageModel.appIconBytes` will be null
     dataUsageType: DataUsageType.wifi, // DataUsageType.wifi | DataUsageType.mobile
     oldVersion: false // will be true for Android versions lower than 23 (MARSHMELLOW)
   );

This would return:

   [   ...,
      DataUsageModel({
            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

  IOSDataUsageModel dataUsage = await DataUsage.dataUsageIOS();

This would return:

  IOSDataUsageModel({
     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
  });

Contribution

Lots of PR's would be needed to make this plugin standard, as for iOS there's a permanent limitation for getting the exact data usage, there's only one way arount it and it's super complex.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。