-
-
Notifications
You must be signed in to change notification settings - Fork 105
/
flex_scheme_data.dart
91 lines (80 loc) · 2.98 KB
/
flex_scheme_data.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import 'package:flutter/foundation.dart';
import 'flex_scheme_color.dart';
// ignore_for_file: comment_references
/// Immutable data class that holds [name] and [description] string scheme
/// descriptions, [light] and [dark], [FlexSchemeColor] definitions.
///
/// The [FlexSchemeData] bundles together a [FlexSchemeColor] pair suitable
/// for light and dark theme mode, that can used by the FlexColorScheme.light
/// and FlexColorScheme.dark factories to create a FlexColorScheme and
/// corresponding [ThemeData] from it.
///
/// This class can also be used to make a map with [FlexScheme] enum or some
/// other usable lookup value as key, and [FlexSchemeData] as values, that you
/// can then use as input to define multiple theme options for FlexColorScheme
/// based themes.
///
/// A predefined example of a [FlexScheme] and [FlexSchemeData] maps are
/// available in [FlexColor.schemes] and [FlexColor.schemesWithCustom].
@immutable
class FlexSchemeData with Diagnosticable {
/// Default constructor, used to make an immutable FlexSchemeData object.
///
/// Contains [name], [description] plus [light] and [dark] scheme colors.
const FlexSchemeData({
required this.name,
required this.description,
required this.light,
required this.dark,
});
/// A short name for the [FlexSchemeData] based color scheme.
final String name;
/// A longer description of the [FlexSchemeData] based color scheme.
final String description;
/// The light scheme colors used by this [FlexSchemeData].
final FlexSchemeColor light;
/// The dark scheme colors used by this [FlexSchemeData].
final FlexSchemeColor dark;
/// Copy the object with one or more provided properties changed.
FlexSchemeData copyWith({
final String? name,
final String? description,
final FlexSchemeColor? light,
final FlexSchemeColor? dark,
}) {
return FlexSchemeData(
name: name ?? this.name,
description: description ?? this.description,
light: light ?? this.light,
dark: dark ?? this.dark,
);
}
/// Override the equality operator.
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
if (other.runtimeType != runtimeType) return false;
return other is FlexSchemeData &&
other.name == name &&
other.description == description &&
other.light == light &&
other.dark == dark;
}
/// Override for hashcode, dart.ui Jenkins based.
@override
int get hashCode => Object.hash(
name,
description,
light,
dark,
);
/// Flutter debug properties override, includes toString.
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(StringProperty('name', name));
properties.add(StringProperty('description', description));
properties.add(DiagnosticsProperty<FlexSchemeColor>('light', light));
properties.add(DiagnosticsProperty<FlexSchemeColor>('dark', dark));
}
}