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 .backup files 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_permissions still 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

๐Ÿ‘จโ€๐Ÿ’ป Author

AbubakrFlutter


โญ If you find this plugin useful, please leave a star on GitHub!