2023-04-19 13:46:29 +00:00
|
|
|
import 'package:color_blindness/color_blindness.dart';
|
|
|
|
import 'package:flutter/foundation.dart';
|
2023-01-20 01:37:35 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2023-04-19 13:46:29 +00:00
|
|
|
const _seedColor = Colors.indigo;
|
|
|
|
final _lightScheme = ColorScheme.fromSeed(
|
|
|
|
seedColor: _seedColor,
|
|
|
|
brightness: Brightness.light,
|
|
|
|
);
|
|
|
|
|
|
|
|
final _darkScheme = ColorScheme.fromSeed(
|
|
|
|
seedColor: _seedColor,
|
|
|
|
brightness: Brightness.dark,
|
|
|
|
);
|
|
|
|
|
|
|
|
ThemeData buildTheme({
|
|
|
|
required Brightness brightness,
|
|
|
|
ColorBlindnessType blindnessType = ColorBlindnessType.none,
|
|
|
|
}) {
|
|
|
|
final baseScheme =
|
|
|
|
brightness == Brightness.light ? _lightScheme : _darkScheme;
|
|
|
|
late final ColorScheme scheme;
|
|
|
|
|
|
|
|
if (!kReleaseMode && blindnessType != ColorBlindnessType.none) {
|
|
|
|
scheme = colorBlindnessColorScheme(baseScheme, blindnessType);
|
|
|
|
} else {
|
|
|
|
scheme = baseScheme;
|
|
|
|
}
|
2023-01-20 01:37:35 +00:00
|
|
|
|
2023-04-19 13:46:29 +00:00
|
|
|
return ThemeData(
|
|
|
|
colorScheme: scheme,
|
|
|
|
brightness: brightness,
|
2023-02-27 21:53:26 +00:00
|
|
|
useMaterial3: true,
|
|
|
|
);
|
2023-01-20 01:37:35 +00:00
|
|
|
}
|