net_permission_handler 0.0.3 copy "net_permission_handler: ^0.0.3" to clipboard
net_permission_handler: ^0.0.3 copied to clipboard

PlatformAndroid

Flutter plugin for checking connectivity (wifi/mobile) and get permission to the camera on Android.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:net_permission_handler/net_permission_handler.dart';

class ConnectionStatusWidget extends StatefulWidget {
  @override
  _ConnectionStatusWidgetState createState() => _ConnectionStatusWidgetState();
}

class _ConnectionStatusWidgetState extends State<ConnectionStatusWidget> {
  String _connectionStatus = 'Checking connection';

  @override
  void initState() {
    super.initState();
    _initConnectivityListener();
  }

  void _initConnectivityListener() {
    NetPermissionHandler.startNetworkStatusListener((status) {
      setState(() {
        _connectionStatus = status;
      });
    });
  }


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Connection Status'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text('Connection Status: $_connectionStatus'),
            SizedBox(height: 20),
            ElevatedButton(
              onPressed: () async {
                // Request camera permission
                bool cameraPermissionGranted = await NetPermissionHandler.requestCameraPermission();
                if (cameraPermissionGranted) {
                  // Handle camera permission granted
                } else {
                  // Handle camera permission denied
                }
              },
              child: Text('Request Camera Permission'),
            ),
          ],
        ),
      ),
    );
  }
}

void main() => runApp(MaterialApp(
  home: ConnectionStatusWidget(),
));
3
likes
130
points
40
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter plugin for checking connectivity (wifi/mobile) and get permission to the camera on Android.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, image_picker, meta, plugin_platform_interface

More

Packages that depend on net_permission_handler