lecle_screen_manager 0.0.1+1 lecle_screen_manager: ^0.0.1+1 copied to clipboard
A Flutter plugin to manage the device's screen on Android and iOS.
import 'package:flutter/material.dart';
import 'package:lecle_screen_manager/lecle_screen_manager.dart';
void main() => runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
bool _isKeptOn = false;
double _brightness = 1.0;
@override
initState() {
super.initState();
initPlatformState();
}
initPlatformState() async {
bool keptOn = await LecleScreenManager.isKeptOn;
double brightness = await LecleScreenManager.brightness;
setState(() {
_isKeptOn = keptOn;
_brightness = brightness;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar:
AppBar(title: const Text('Lecle Screen Manager plugin example')),
body: Center(
child: Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text("Screen is kept on?"),
Checkbox(
value: _isKeptOn,
onChanged: (b) async {
if (b != null) {
setState(() {
_isKeptOn = b;
});
await LecleScreenManager.keepOn(b);
}
})
],
),
const Text("Brightness:"),
Slider(
value: _brightness,
onChanged: (b) async {
setState(() {
_brightness = b;
});
await LecleScreenManager.setBrightness(b);
},
)
],
),
),
),
);
}
}