import 'package:farm_tpf/app/themes.dart'; import 'package:farm_tpf/utils/const_string.dart'; import 'package:flutter/material.dart'; class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: AppTheme.of(context, listen: true).currentTheme, home: MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key); final String title; @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State { int _counter = 0; AppTheme _theme; @override void didChangeDependencies() { if (_theme == null) { _theme = AppTheme.of(context); } super.didChangeDependencies(); } void _incrementCounter() { setState(() { // This call to setState tells the Flutter framework that something has // changed in this State, which causes it to rerun the build method below // so that the display can reflect the updated values. If we changed // _counter without calling setState(), then the build method would not be // called again, and so nothing would appear to happen. _counter++; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.title), actions: [ IconButton( icon: Icon(Icons.flip, color: Colors.white), onPressed: _theme?.switchTheme, ), ], ), body: Center(child: Text(app_name))); } }