changed primary color usage to fix the color bug in dark mode
Changed Theme.of(context).primaryColor to Theme.of(contex).colorScheme.primary to make dark mode work properly.
This commit is contained in:
@@ -3,4 +3,5 @@ enum ThemeType {
|
||||
green,
|
||||
orange,
|
||||
blue,
|
||||
yellow,
|
||||
}
|
||||
|
@@ -38,16 +38,17 @@ class AppThemes {
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';import 'theme_type.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'theme_type.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
class AppThemes {
|
||||
static ThemeData getLightTheme(ThemeType type) {
|
||||
|
||||
class AppThemes {
|
||||
static ThemeData getLightTheme(ThemeType type) {
|
||||
print('inside get light theme');
|
||||
final Color seedColor = _getSeedColor(type);
|
||||
final colorScheme = ColorScheme.fromSeed(
|
||||
final Color seedColor = _getSeedColor(type);
|
||||
final colorScheme = ColorScheme.fromSeed(
|
||||
seedColor: seedColor,
|
||||
brightness: Brightness.light,
|
||||
);
|
||||
@@ -64,27 +65,28 @@ class AppThemes {
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
static ThemeData getDarkTheme(ThemeType type) {
|
||||
print('inside get dark theme');
|
||||
final Color seedColor = _getSeedColor(type);
|
||||
log(seedColor.toString());
|
||||
final colorScheme = ColorScheme.fromSeed(
|
||||
seedColor: seedColor,
|
||||
brightness: Brightness.dark,
|
||||
// Define custom background and surface colors for better contrast
|
||||
// background: const Color(0xFF121212), // A common dark theme background c
|
||||
// surface: const Color(0xFF1E1E1E), // A slightly lighter surface color
|
||||
);
|
||||
|
||||
return ThemeData.from(
|
||||
colorScheme: colorScheme,
|
||||
useMaterial3: true,
|
||||
textTheme: GoogleFonts.rubikTextTheme(
|
||||
ThemeData(brightness: Brightness.dark).textTheme,
|
||||
),
|
||||
);
|
||||
|
||||
// .copyWith(
|
||||
static ThemeData getDarkTheme(ThemeType type) {
|
||||
print('inside get dark theme');
|
||||
final Color seedColor = _getSeedColor(type);
|
||||
log(seedColor.toString());
|
||||
final colorScheme = ColorScheme.fromSeed(
|
||||
seedColor: seedColor,
|
||||
brightness: Brightness.dark,
|
||||
// Define custom background and surface colors for better contrast
|
||||
// background: const Color(0xFF121212), // A common dark theme background c
|
||||
// surface: const Color(0xFF1E1E1E), // A slightly lighter surface color
|
||||
);
|
||||
|
||||
return ThemeData.from(
|
||||
colorScheme: colorScheme,
|
||||
useMaterial3: true,
|
||||
textTheme: GoogleFonts.rubikTextTheme(
|
||||
ThemeData(brightness: Brightness.dark).textTheme,
|
||||
),
|
||||
);
|
||||
|
||||
// .copyWith(
|
||||
// Explicitly set scaffold background color
|
||||
// scaffoldBackgroundColor: colorScheme.background,
|
||||
// // Customize card theme for dark mode
|
||||
@@ -114,8 +116,9 @@ class AppThemes {
|
||||
// selectedItemColor: colorScheme.primary,
|
||||
// unselectedItemColor: colorScheme.onSurface.withOpacity(0.6),
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
// );
|
||||
}
|
||||
|
||||
static Color _getSeedColor(ThemeType type) {
|
||||
switch (type) {
|
||||
case ThemeType.green:
|
||||
@@ -125,8 +128,9 @@ class AppThemes {
|
||||
case ThemeType.blue:
|
||||
return Colors.blue;
|
||||
case ThemeType.violet:
|
||||
default:
|
||||
return Colors.deepPurple;
|
||||
case ThemeType.yellow:
|
||||
return Colors.yellow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user