screen_keep_on 0.1.1

Flutter Android iOS

A Flutter plugin to keep screen on. AndroidX migrated.

example/lib/main.dart

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

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

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

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

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

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    bool _isOn = await ScreenKeepOn.isOn;

    setState(() {
      isOn = _isOn;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Screen Keep On Example'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text('Screen Keep On : $isOn\n'),
              Container(height: 10.0,),
              Checkbox(value: isOn, onChanged: (bool on){
                ScreenKeepOn.turnOn(on);
                setState((){isOn = on; });
              })
            ],
          ),
//          child: Text('Screen Keep On : $isOn\n'),
        ),
      ),
    );
  }
}
2
likes
80
pub points
70%
popularity

A Flutter plugin to keep screen on. AndroidX migrated.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

songyi0207@gmail.com

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on screen_keep_on