root_access 1.0.4 copy "root_access: ^1.0.4" to clipboard
root_access: ^1.0.4 copied to clipboard

PlatformAndroid

Flutter plugin to request root access in Android device. This plugin is Android exclusive only.

example/lib/main.dart

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

import 'package:root_access/root_access.dart';

void main() => runApp(new MyApp());

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

class _MyAppState extends State<MyApp> {
  bool _rootAccess = false;

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

  Future<void> initRootRequest() async {
    bool rootAccess = await RootAccess.requestRootAccess;

    // 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(() {
      _rootAccess = rootAccess;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('Root access granted: $_rootAccess\n'),
        ),
      ),
    );
  }
}
19
likes
140
pub points
83%
popularity

Publisher

verified publisheramitkhairnar.dev

Flutter plugin to request root access in Android device. This plugin is Android exclusive only.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on root_access