permissions_plugin 1.0.0 copy "permissions_plugin: ^1.0.0" to clipboard
permissions_plugin: ^1.0.0 copied to clipboard

outdated

plugin for managment permission on runtime ejecution

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:permissions_plugin/permissions_plugin.dart';


void main() => runApp(MyInitApp());

class MyInitApp extends StatelessWidget {
  // This widget is the root of your application.

  @override
  Widget build(BuildContext context) {
    //initPlatformState();
    return MaterialApp(
      title: 'Ecample permission',
      //showPerformanceOverlay: true,
      //showSemanticsDebugger: true,
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.green,
      ),
      initialRoute: '/',
      routes: {
        '/': (context) => MyApp(),
        '/login': (context) => MyApp()
      },
      //home: MyApp(),
    );
  }
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  Map<Permission, PermissionState> _platformVersion;

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    Map<Permission, PermissionState> platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      // String imei = await ImeiPlugin.getImei;
      platformVersion = await PermissionsPlugin.requestPermissions([
            Permission.ACCESS_FINE_LOCATION,
      ]);
    } on PlatformException {
      debugPrint("Error");
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return  Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('Running on:'),
        ),
    );
  }
}
15
likes
20
pub points
76%
popularity

Publisher

unverified uploader

plugin for managment permission on runtime ejecution

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on permissions_plugin