Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- 반석천
- Flutter Example
- ListView.builder
- node.js
- Image.network
- Column Widget
- WillPopScope
- InkWell
- CrossAxisAlignment
- Networking
- Snackbar
- MainAxisAlignment
- Flutter 앱 배포
- Scaffold
- Flutter Tutorial
- Load Image
- flutter
- Flutter 예제
- sqlite
- HTTP
- Flutter 강좌
- AppBar
- FutureBuilder
- Row Widget
- ListTile
- listview
- Hello World
- Row
- navigator
- Cached Image
Archives
- Today
- Total
꿈꾸는 시스템 디자이너
Flutter Example - Screen Management | Kept On Screen 본문
Tutorial/Flutter with App
Flutter Example - Screen Management | Kept On Screen
독행소년 2019. 9. 27. 12:401. Add this to pubspec.yaml file
dependencies:
screen: ^0.0.5
2. Add the following permissions to Android Manifest file
<uses-permission android:name="android.permission.WAKE_LOCK" />
3. Source Code
import 'package:flutter/material.dart';
import 'package:screen/screen.dart';
ManageScreenDemoState pageState;
class ManageScreenDemo extends StatefulWidget {
@override
ManageScreenDemoState createState() {
pageState = ManageScreenDemoState();
return pageState;
}
}
class ManageScreenDemoState extends State<ManageScreenDemo> {
double _brightness;
bool _enableKeptOn;
@override
void initState() {
super.initState();
getBrightness();
getIsKeptOnScreen();
}
void getBrightness() async {
double value = await Screen.brightness;
setState(() {
_brightness = double.parse(value.toStringAsFixed(1));
});
}
void getIsKeptOnScreen() async {
bool value = await Screen.isKeptOn;
setState(() {
_enableKeptOn = value;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Manage Screen Demo")),
body: Column(
children: <Widget>[
// Notice
Container(
margin: const EdgeInsets.all(10),
padding: const EdgeInsets.all(10),
alignment: Alignment(0,0),
height: 50,
decoration: BoxDecoration(color: Colors.orange),
child: Text(
"Do this example on a real phone, not an emulator.",
style: TextStyle(color: Colors.white),
),
),
// Brightness Settings
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text("Brightness:"),
(_brightness == null)
? CircularProgressIndicator()
: Slider(
value: _brightness,
min: 0,
max: 1.0,
divisions: 10,
onChanged: (newValue) {
setState(() {
_brightness = newValue;
});
// set screen's brightness
Screen.setBrightness(_brightness);
},
),
Text(_brightness.toString()),
],
),
),
// Kept-On Settings
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text("Kept on Screen:"),
Text(_enableKeptOn.toString()),
(_enableKeptOn == null)
? CircularProgressIndicator()
: Switch(
value: _enableKeptOn,
onChanged: (flag) {
Screen.keepOn(flag);
getIsKeptOnScreen();
},
)
],
),
)
],
),
);
}
}
▶ Go to Table of Contents | 강의 목차로 이동
※ This example is also available in the Flutter Code Examples app. | 본 예제는 Flutter Code Examples 앱에서도 제공됩니다.
'Tutorial > Flutter with App' 카테고리의 다른 글
Flutter Example - ListView | Create ListView with builder (2) | 2019.09.27 |
---|---|
Flutter Example - ListView | basic (0) | 2019.09.27 |
Flutter Example - WillPopScope | Handel back button pressed (0) | 2019.09.27 |
Flutter Example - AlertDialog (0) | 2019.09.27 |
Flutter Example - Navigation & routing | Return data from a screen (0) | 2019.09.27 |
Comments