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.

66 lines
1.7KB

  1. import 'package:farm_tpf/app/themes.dart';
  2. import 'package:farm_tpf/utils/const_string.dart';
  3. import 'package:flutter/material.dart';
  4. class MyApp extends StatelessWidget {
  5. // This widget is the root of your application.
  6. @override
  7. Widget build(BuildContext context) {
  8. return MaterialApp(
  9. title: 'Flutter Demo',
  10. theme: AppTheme.of(context, listen: true).currentTheme,
  11. home: MyHomePage(title: 'Flutter Demo Home Page'),
  12. );
  13. }
  14. }
  15. class MyHomePage extends StatefulWidget {
  16. MyHomePage({Key key, this.title}) : super(key: key);
  17. final String title;
  18. @override
  19. _MyHomePageState createState() => _MyHomePageState();
  20. }
  21. class _MyHomePageState extends State<MyHomePage> {
  22. int _counter = 0;
  23. AppTheme _theme;
  24. @override
  25. void didChangeDependencies() {
  26. if (_theme == null) {
  27. _theme = AppTheme.of(context);
  28. }
  29. super.didChangeDependencies();
  30. }
  31. void _incrementCounter() {
  32. setState(() {
  33. // This call to setState tells the Flutter framework that something has
  34. // changed in this State, which causes it to rerun the build method below
  35. // so that the display can reflect the updated values. If we changed
  36. // _counter without calling setState(), then the build method would not be
  37. // called again, and so nothing would appear to happen.
  38. _counter++;
  39. });
  40. }
  41. @override
  42. Widget build(BuildContext context) {
  43. return Scaffold(
  44. appBar: AppBar(
  45. title: Text(widget.title),
  46. actions: [
  47. IconButton(
  48. icon: Icon(Icons.flip, color: Colors.white),
  49. onPressed: _theme?.switchTheme,
  50. ),
  51. ],
  52. ),
  53. body: Center(child: Text(app_name)));
  54. }
  55. }