themes.dart 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import 'package:flutter/material.dart';
  2. ///优先使用Theme中的颜色,如果Theme中颜色不满足需求再使用colorScheme中的颜色
  3. ///primaryColor是主颜色,确定色系
  4. ///primaryColorLight为主颜色的浅色变种
  5. ///primaryColorDark为主颜色的深色变种
  6. ///errorColor为错误色和警告色
  7. ///
  8. ///colorScheme:
  9. ///primary为主颜色(和primaryColor保持一致或相近颜色)
  10. ///secondary为次级颜色(和primaryColor保持一致或同一色系)
  11. ///error为错误色(和errorColor保持一致)
  12. ///onPrimary为以primaryColor为背景的字体颜色(多为按钮的默认颜色)
  13. ///onSurface为Text组件的默认颜色
  14. ///brightness为模式
  15. /// (会影响状态栏以及webview的背景)[ActivityViewPage],[PhonePage],[NewsPage]
  16. ///
  17. /// 以上为必须需要的颜色,其余未列举出的颜色可自由发挥
  18. ///
  19. class Themes {
  20. static Map<String, ThemeData> get values =>
  21. {'默认主题': defaultTheme, '蓝色主题': lightTheme, '夜间主题': darkTheme};
  22. static final ThemeData defaultTheme = ThemeData(
  23. primaryColor: const Color(0xFF038873),
  24. primaryColorLight: Colors.green,
  25. primaryColorDark: const Color(0xFF026F5C),
  26. indicatorColor: Colors.green,
  27. errorColor: const Color(0xffb00020),
  28. toggleableActiveColor: const Color(0xFF038873),
  29. colorScheme: ColorScheme(
  30. primary: const Color(0xFF038873),
  31. secondary: const Color(0xFF038873),
  32. surface: Colors.white,
  33. background: Colors.white,
  34. error: const Color(0xffb00020),
  35. onPrimary: Colors.white,
  36. onSecondary: Colors.white,
  37. onSurface: Colors.black,
  38. onBackground: Colors.black,
  39. onError: Colors.white,
  40. brightness: Brightness.light,
  41. primaryVariant: const Color(0xFF038873),
  42. secondaryVariant: const Color(0xFF038873),
  43. ),
  44. );
  45. static final ThemeData lightTheme = ThemeData.light();
  46. static final ThemeData darkTheme =
  47. ThemeData.dark().copyWith(brightness: Brightness.dark);
  48. }