my_theme.dart 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_riverpod/flutter_riverpod.dart';
  3. final appThemeProvider = StateProvider<bool>((ref) => true);
  4. ThemeData myTheme(BuildContext context, bool isDarkTheme) {
  5. if (isDarkTheme) {
  6. return ThemeData.dark();
  7. } else {
  8. return ThemeData.light();
  9. }
  10. }
  11. // import 'package:flutter/material.dart';
  12. // import 'package:flutter_riverpod/flutter_riverpod.dart';
  13. // AppColors colors(context) => Theme.of(context).extension<AppColors>()!;
  14. // final appThemeProvider = StateProvider<bool>((ref) => true);
  15. // ThemeData getAppTheme(BuildContext context, bool isDarkTheme) {
  16. // //return isDarkTheme ? ThemeData.dark() : ThemeData.light();
  17. // return (isDarkTheme ? ThemeData.dark() : ThemeData.light()).copyWith(
  18. // extensions: <ThemeExtension<AppColors>>[
  19. // AppColors(
  20. // color1: isDarkTheme ? Colors.blue : Colors.green,
  21. // color2: isDarkTheme ? Colors.pink : Colors.blue,
  22. // color3: isDarkTheme ? Colors.yellow : Colors.red,
  23. // ),
  24. // ],
  25. // scaffoldBackgroundColor: isDarkTheme ? Colors.black : Colors.white,
  26. // textTheme: Theme.of(context)
  27. // .textTheme
  28. // .copyWith(
  29. // titleSmall:
  30. // Theme.of(context).textTheme.titleSmall?.copyWith(fontSize: 12),
  31. // )
  32. // .apply(
  33. // bodyColor: isDarkTheme ? Colors.white : Colors.black,
  34. // displayColor: Colors.grey,
  35. // ),
  36. // switchTheme: SwitchThemeData(
  37. // thumbColor: MaterialStateProperty.all(
  38. // isDarkTheme ? Colors.orange : Colors.purple),
  39. // ),
  40. // listTileTheme: ListTileThemeData(
  41. // iconColor: isDarkTheme ? Colors.orange : Colors.purple),
  42. // appBarTheme: AppBarTheme(
  43. // //backgroundColor: isDarkTheme ? Colors.black : Colors.white,
  44. // iconTheme:
  45. // IconThemeData(color: isDarkTheme ? Colors.white : Colors.black54)),
  46. // );
  47. // }
  48. // @immutable
  49. // class AppColors extends ThemeExtension<AppColors> {
  50. // final Color? color1;
  51. // final Color? color2;
  52. // final Color? color3;
  53. // const AppColors({
  54. // required this.color1,
  55. // required this.color2,
  56. // required this.color3,
  57. // });
  58. // @override
  59. // AppColors copyWith({
  60. // Color? color1,
  61. // Color? color2,
  62. // Color? color3,
  63. // }) {
  64. // return AppColors(
  65. // color1: color1 ?? this.color1,
  66. // color2: color2 ?? this.color2,
  67. // color3: color3 ?? this.color3,
  68. // );
  69. // }
  70. // @override
  71. // AppColors lerp(ThemeExtension<AppColors>? other, double t) {
  72. // if (other is! AppColors) {
  73. // return this;
  74. // }
  75. // return AppColors(
  76. // color1: Color.lerp(color1, other.color1, t),
  77. // color2: Color.lerp(color2, other.color2, t),
  78. // color3: Color.lerp(color3, other.color3, t),
  79. // );
  80. // }
  81. // }