Easy Material White Theme
in pubspec.yaml
dependencies:
flutter_fast_ui_white:
git:
url: https://github.com/organic-nailer/flutter_fast_ui_white
ref: v0.3
void main() {
initializeDateFormatting("ja_JP");
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return FastThemeScope(
accentColor: Colors.green,
themeMode: ThemeMode.system,
builder: (context, lightTheme, darkTheme, mode) {
return MaterialApp(
title: 'Fast White Theme',
theme: lightTheme,
darkTheme: darkTheme,
themeMode: mode,
home: SampleListPage(),
);
});
}
}
void main() {
runApp(FastTheme(
accentColor: Colors.pink,
child: MyApp(),
));
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: FastTheme.of(context).theme,
home: SampleListPage(),
);
}
}
- FastAppBar
- FastTextField
FastTheme.of(context).changeTheme(Brightness brightness);
FastTheme.of(context).changeAccent(MaterialColor color);
テーマ変更に対応した独自のカラーを設定可能
1.abstract class CustomColors
を継承したclassを作成
class MyCustomColors extends CustomColors<MyColors> {
final MaterialColor _accent;
MyCustomColors(this._accent)
: super({
MyColors.paleBackground: SwitchableColor(
light: _accent.shade200, dark: _accent.shade800.withAlpha(50)),
MyColors.paleNonColoredBackground:
SwitchableColor(light: Color(0xFFEBEBEB), dark: Color(0xFF1F1F1F))
});
}
enum MyColors { paleNonColoredBackground, paleBackground }
2.FastThemeScope
に追加
FastThemeScope(
...
customColors: MyCustomColors(Colors.green),
...
);
3.FastTheme.of(context)
からアクセス
FastTheme.of(context).getCustomColor<MyColors>(MyColors.paleBackground);