flutter_keepscreenon 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 67

flutter_keepscreenon #

pub package

A package can help you to keep the device's screen on programmatically without any permission.

Getting Started #

Installation #

Add this to your pubspec.yaml (or create it):

dependencies:
  flutter_keepscreenon: any

Then run the flutter tooling:

flutter packages get

Example #

try {
  await FlutterKeepscreenon.keepScreenOn(true);
} on PlatformException catch (e) {
  print(e);
}

Details in example/ folder.

CHANGELOG #

[0.1.1] #

  • Upgrade kotlin version.

[0.1.0] #

  • Add keepScreenOn and mark activateKeepScreenOn and deactivateKeepScreenOn as deprecated.
  • Add docs.

[0.0.3] #

  • Upgrade to dart2

[0.0.2+1] #

  • Format code

[0.0.2] #

  • Update ios platform code

[0.0.1+1] #

  • Add license

[0.0.1] #

  • Initial release

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_keepscreenon/flutter_keepscreenon.dart';

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

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

class _MyAppState extends State<MyApp> {
  bool activeFlag = false;
  String errMsg = '';

  toggleFlag() async {
    try {
      if (activeFlag)
        await FlutterKeepscreenon.keepScreenOn(false);
      else
        await FlutterKeepscreenon.keepScreenOn(true);
      setState(() => activeFlag = !activeFlag);
    } on PlatformException catch (e) {
      print(e);
      setState(() => errMsg = e.message);
    }

    if (!mounted) return;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Flutter_keepscreenon plugin example app'),
        ),
        body: Center(
            child: Container(
          height: 100.0,
          child: Column(
            children: <Widget>[
              Switch(
                onChanged: (bool value) => toggleFlag(),
                value: activeFlag,
              ),
              Text(
                activeFlag ? 'It\'s on!' : 'It\'s off!',
              ),
              Text(
                errMsg,
              ),
            ],
          ),
        )),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_keepscreenon: ^0.1.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_keepscreenon/flutter_keepscreenon.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
42
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
67
Learn more about scoring.

We analyzed this package on Apr 1, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Maintenance suggestions

Package is getting outdated. (-20 points)

The package was last published 62 weeks ago.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8