internet_permission 2.0.1
internet_permission: ^2.0.1 copied to clipboard
A Flutter plugin that automatically adds internet permissions to all platforms (Android, iOS, macOS, Windows, Linux, Web). One command setup: dart run internet_permission:setup
Internet Permission ๐ #
A Flutter plugin that automatically adds internet permissions for all platforms!
One command โ all platforms configured! โก
โจ Features #
- ๐ Automatic setup โ Just run:
dart run internet_permission:setup - ๐ฑ Supports 6 platforms โ Android, iOS, macOS, Windows, Linux, Web
- ๐ Safe โ Creates backup files before making changes
- โก Fast โ Setup completes in seconds
- ๐ฏ Easy โ No additional configuration needed
๐ Quick Start #
1๏ธโฃ Install #
flutter pub add internet_permission
2๏ธโฃ Setup (Automatic!) #
dart run internet_permission:setup
That's all! โ
๐ What Does It Add? #
๐ฑ Android #
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
๐ iOS #
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
๐ป macOS #
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
๐ช Windows #
โ Default permission (no setup needed)
๐ง Linux #
โ Default permission (no setup needed)
๐ Web #
โ Default permission (no setup needed)
๐ป Usage #
Check Internet Connection #
import 'package:internet_permission/internet_permission.dart';
final permission = InternetPermission();
// Check if internet is available
bool isConnected = await permission.isConnected();
print('Internet: ${isConnected ? "โ
Connected" : "โ No connection"}');
// Get connection type
String connectionType = await permission.getConnectionType();
print('Type: $connectionType'); // wifi, mobile, ethernet, vpn, none
Full Example #
import 'package:flutter/material.dart';
import 'package:internet_permission/internet_permission.dart';
class InternetChecker extends StatefulWidget {
@override
_InternetCheckerState createState() => _InternetCheckerState();
}
class _InternetCheckerState extends State<InternetChecker> {
final _permission = InternetPermission();
String _status = 'Checking...';
@override
void initState() {
super.initState();
_checkInternet();
}
Future<void> _checkInternet() async {
final connected = await _permission.isConnected();
final type = await _permission.getConnectionType();
setState(() {
_status = connected
? 'โ
Internet: $type'
: 'โ No internet';
});
}
@override
Widget build(BuildContext context) {
return Column(
children: [
Text(_status, style: TextStyle(fontSize: 20)),
ElevatedButton(
onPressed: _checkInternet,
child: Text('Check Again'),
),
],
);
}
}
๐ฑ Setup Script Output #
$ dart run internet_permission:setup
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ Internet Permission Setup v2.0.0 โ
โ ๐ฑ For all platforms โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Project: /path/to/your/project
๐ง Configuring platforms...
๐ฑ Android: โ
Added (INTERNET, ACCESS_NETWORK_STATE)
๐ iOS: โ
Added (NSAppTransportSecurity)
๐ป macOS: โ
Added (network.client, network.server)
๐ช Windows: โ
Default permissions
๐ง Linux: โ
Default permissions
๐ Web: โ
Default permissions
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
6/6 platforms successfully configured!
๐ Next steps:
1. flutter clean
2. flutter pub get
3. flutter run
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฏ API Reference #
isConnected() โ Future<bool> #
Checks if the device has an active internet connection.
bool connected = await InternetPermission().isConnected();
getConnectionType() โ Future<String> #
Returns the current connection type.
Possible values: wifi, mobile, ethernet, vpn, none
String type = await InternetPermission().getConnectionType();
hasInternetPermission() โ Future<bool> #
Checks if internet permissions are properly configured.
bool hasPermission = await InternetPermission().hasInternetPermission();
getPlatformVersion() โ Future<String?> #
Gets the device platform version.
String? version = await InternetPermission().getPlatformVersion();
๐ง Manual Setup (If Needed) #
๐ฑ Android (manual) #
Edit android/app/src/main/AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application>
<!-- ... -->
</application>
</manifest>
๐ iOS (manual) #
Edit ios/Runner/Info.plist:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
๐ป macOS (manual) #
Edit macos/Runner/DebugProfile.entitlements and Release.entitlements:
<dict>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
</dict>
๐งช Testing #
In Example Project #
cd example
dart run internet_permission:setup
flutter run
In a New Project #
flutter create my_app
cd my_app
flutter pub add internet_permission
dart run internet_permission:setup
flutter run -d macos
โ ๏ธ Important Notes #
- Backup Files โ The script creates
.backupfiles before making changes - Repeatable โ Safe to run multiple times; skips already configured platforms
- Production โ For iOS/macOS, use HTTPS connections in production
- Web โ CORS must be configured on your server
- Backward Compatibility โ Old command
setup_permissionsstill works
๐ Troubleshooting #
Script Not Working? #
flutter clean
flutter pub get
dart run internet_permission:setup
Platform Missing? #
Some platforms may not exist in your project by default โ this is normal.
Permissions Not Added? #
If automatic setup fails, follow the manual setup instructions above.
๐ฆ Version History #
2.0.1 โ 2025-12-06 ๐ #
- โจ NEW: Support for all 6 platforms
- ๐ Simplified command:
dart run internet_permission:setup - ๐จ Improved terminal UI
- โก Faster execution
1.0.5 โ 2025-12-05 #
- Automatic setup script
- Android & iOS support
๐ค Contributing #
Pull requests are welcome! Feel free to contribute to this project.
๐ License #
MIT License
๐ Links #
๐จโ๐ป Author #
AbubakrFlutter
- ๐ง Email: [email protected]
- ๐ GitHub: @AbubakrFlutter
โญ If you find this plugin useful, please leave a star on GitHub!