Masterarbeit Richard Stern. Flutter App, sich mit einem Bluetooth-Gerät verbindet und Berührungen auf einem Sensor visualisiert.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.dart 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import 'package:flutter/material.dart';
  2. import 'package:screen/screen.dart';
  3. void main() => runApp(new MyApp());
  4. class MyApp extends StatefulWidget {
  5. @override
  6. _MyAppState createState() => new _MyAppState();
  7. }
  8. class _MyAppState extends State<MyApp> {
  9. bool _isKeptOn = false;
  10. double _brightness = 1.0;
  11. @override
  12. initState() {
  13. super.initState();
  14. initPlatformState();
  15. }
  16. initPlatformState() async {
  17. bool keptOn = await Screen.isKeptOn;
  18. double brightness = await Screen.brightness;
  19. setState((){
  20. _isKeptOn = keptOn;
  21. _brightness = brightness;
  22. });
  23. }
  24. @override
  25. Widget build(BuildContext context) {
  26. return new MaterialApp(
  27. home: new Scaffold(
  28. appBar: new AppBar(title: new Text('Screen plugin example')),
  29. body: new Center(
  30. child: new Column(
  31. children: <Widget>[
  32. new Row(
  33. mainAxisAlignment: MainAxisAlignment.center,
  34. children: <Widget>[
  35. new Text("Screen is kept on ? "),
  36. new Checkbox(value: _isKeptOn, onChanged: (bool b){
  37. Screen.keepOn(b);
  38. setState((){_isKeptOn = b; });
  39. })
  40. ]
  41. ),
  42. new Text("Brightness :"),
  43. new Slider(value : _brightness, onChanged : (double b){
  44. setState((){_brightness = b;});
  45. Screen.setBrightness(b);
  46. })
  47. ]
  48. )
  49. ),
  50. ),
  51. );
  52. }
  53. }