Line data Source code
1 : import "package:flutter/material.dart" as material; 2 : import "package:flutter/widgets.dart"; 3 : import "package:flutter_gen/gen_l10n/app_localizations.dart"; 4 : 5 : /// テーマのモード 6 : enum ThemeMode { system, light, dark } 7 : 8 0 : final convertTheme = { 9 : ThemeMode.system: material.ThemeMode.system, 10 : ThemeMode.light: material.ThemeMode.light, 11 : ThemeMode.dark: material.ThemeMode.dark 12 : }; 13 : 14 : /// テーマのモードの表示名 15 0 : String themeDisplayName( 16 : {required final BuildContext context, required final ThemeMode mode}) { 17 : switch (mode) { 18 0 : case ThemeMode.system: 19 0 : return AppLocalizations.of(context)!.themeSystem; 20 0 : case ThemeMode.light: 21 0 : return AppLocalizations.of(context)!.themeLight; 22 0 : case ThemeMode.dark: 23 0 : return AppLocalizations.of(context)!.themeDark; 24 : default: 25 : return "UNKNOWN"; 26 : } 27 : }