import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { bool _isDarkMode = false; @override Widget build(BuildContext context) { return MaterialApp( theme: _isDarkMode ? ThemeData.dark() : ThemeData.light(), home: Scaffold( appBar: AppBar( title: Text('Dark Mode Example'), ), body: Center( child: Text('Hello World'), ), floatingActionButton: FloatingActionButton( onPressed: () { setState(() { _isDarkMode = !_isDarkMode; }); }, child: Icon(_isDarkMode ? Icons.wb_sunny : Icons.brightness_3), ), ), ); } }
この色変更の部分をリスト化すれば、アプリでよくあるような色変更を簡単にできる気がする