wifi_binder 0.0.1
wifi_binder: ^0.0.1 copied to clipboard
A Flutter plugin to **force network traffic over Wi-Fi only**
Berikut adalah isi lengkap README.md
untuk plugin Flutter wifi_binder
, termasuk deskripsi, setup, penggunaan, dan troubleshooting:
πΆ wifi_binder #
A Flutter plugin to force network traffic over Wi-Fi only, even when mobile data is turned on. Useful for connecting to local-only Wi-Fi devices such as dashcams, IoT devices, or local servers.
π This plugin currently supports Android only, and is written in Kotlin.
β¨ Features #
- β Bind process-level networking to Wi-Fi
- π Unbind to resume normal routing (use both mobile and Wi-Fi)
- β‘ Works without turning off mobile data manually
- π Android only (iOS not supported)
π Getting Started #
1. Add the Plugin to Your Project #
Download or clone this repository and place it inside a packages/
directory, or any location in your project.
Update your pubspec.yaml
:
dependencies:
wifi_binder:
path: ./packages/wifi_binder
2. Import and Use in Code #
import 'package:wifi_binder/wifi_binder.dart';
/// Forces all traffic through the currently connected Wi-Fi
await WifiBinder.bindWifiOnly();
/// Unbinds the network and restores default behavior
await WifiBinder.unbindNetwork();
π± Android Setup #
1. Permissions #
In your AndroidManifest.xml
(usually under android/app/src/main/
), add:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
2. Minimum SDK #
In android/app/build.gradle
, set:
minSdkVersion 23
β Example Use Case #
If you're building a dashcam viewer app:
- The app connects to dashcam Wi-Fi (e.g.,
192.168.0.1
) - Mobile data is still ON (by default Android routes requests via mobile)
- With this plugin, your video stream or requests are forced to use Wi-Fi
β Limitations #
- πΈ Android only
- πΈ Not intended for background tasks or multi-process routing
- πΈ May not work if user switches Wi-Fi after binding (call
bindWifiOnly()
again) - β οΈ Ensure the Wi-Fi connection is already established before calling bind
π§ͺ Testing #
Use on a real Android device connected to a Wi-Fi network with no internet access (e.g., dashcam hotspot). Ensure mobile data is active to validate that the plugin correctly routes over Wi-Fi.
π§ Troubleshooting #
Problem | Solution |
---|---|
Network still using mobile data | Ensure bindWifiOnly() is called after Wi-Fi is connected |
setProcessDefaultNetwork deprecated |
The plugin uses bindProcessToNetwork automatically for Android β₯ 23 |
iOS not supported | iOS doesnβt allow custom network binding at this level |
App crash on start | Check minSdkVersion >= 23 and permissions are granted |
π Plugin Structure #
wifi_binder/
βββ lib/
β βββ wifi_binder.dart
βββ android/
β βββ src/main/kotlin/... (Kotlin logic)
βββ pubspec.yaml
βββ README.md
π License #
This project is licensed under the MIT License.
Jika kamu ingin README ini dalam Bahasa Indonesia atau ingin dipublikasikan ke pub.dev, tinggal beri tahu saja.