power 0.1.0 copy "power: ^0.1.0" to clipboard
power: ^0.1.0 copied to clipboard

outdated

A Flutter plugin to access device power related information.

Power #

A Flutter plugin to access device power related information.

Usage #

To use this plugin, add power as a dependency in your pubspec.yaml file.

  dependencies:
    flutter:
      sdk: flutter
    power:

Example #

void main() {
  runApp(MyApp());
}

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

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

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

  Future<void> initPowerState() async {
    bool lowPowerMode;

    try {
      lowPowerMode = await Power.isLowPowerMode;
    } on PlatformException {
      lowPowerMode = false;
    }

    if (!mounted) return;

    setState(() {
      _lowPowerMode = lowPowerMode;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Power example app'),
        ),
        body: Center(
          child: Text('Low power mode is ${_lowPowerMode ? 'on' : 'off'}'),
        ),
      ),
    );
  }
}

Features #

  • Get low power mode
  • Get charging status
  • Get battery level
  • Build widgets in response to power changes
  • Disable animations in low power mode
7
likes
0
pub points
83%
popularity

Publisher

unverified uploader

A Flutter plugin to access device power related information.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on power