Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: ignore deprecated use of 'ButtonBarThemeData' and fix unit tests #216

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions json_theme/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [6.5.1+2] - September 4th, 2024

* Fix unit tests and ignore deprecated member of 'ButonBarThemeData' which is deprecated since v3.21.0-10.0.pre.

## [6.5.1+1] - August 7th, 2024

* Add missing case AutovalidateMode.onUnfocus in encoder
Expand Down
21 changes: 10 additions & 11 deletions json_theme/lib/src/codec/theme_decoder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ class ThemeDecoder {
'always',
'disabled',
'onUserInteraction',
'onUnfocus',
],
value,
);
Expand All @@ -522,17 +523,9 @@ class ThemeDecoder {
value: value,
validate: validate,
));
switch (value) {
case 'always':
result = AutovalidateMode.always;
break;
case 'disabled':
result = AutovalidateMode.disabled;
break;
case 'onUserInteraction':
result = AutovalidateMode.onUserInteraction;
break;
}

result = AutovalidateMode.values
.firstWhere((e) => e.toString() == 'AutovalidateMode.$value');
}
}

Expand Down Expand Up @@ -2040,6 +2033,7 @@ class ThemeDecoder {
return result;
}

// ignore: deprecated_member_use
/// Decodes the given [value] to an [ButtonBarThemeData]. This expects the
/// given [value] to follow the structure below:
///
Expand All @@ -2064,12 +2058,15 @@ class ThemeDecoder {
/// * [decodeMainAxisAlignment]
/// * [decodeMainAxisSize]
/// * [decodeVerticalDirection]
// ignore: deprecated_member_use
static ButtonBarThemeData? decodeButtonBarThemeData(
dynamic value, {
bool validate = true,
}) {
// ignore: deprecated_member_use
ButtonBarThemeData? result;

// ignore: deprecated_member_use
if (value is ButtonBarThemeData) {
result = value;
} else if (value != null) {
Expand All @@ -2078,6 +2075,7 @@ class ThemeDecoder {
value: value,
validate: validate,
));
// ignore: deprecated_member_use
result = ButtonBarThemeData(
alignment: decodeMainAxisAlignment(
value['alignment'],
Expand Down Expand Up @@ -12186,6 +12184,7 @@ class ThemeDecoder {
value['brightness'],
validate: false,
),
// ignore: deprecated_member_use
buttonBarTheme: decodeButtonBarThemeData(
value['buttonBarTheme'],
validate: false,
Expand Down
2 changes: 2 additions & 0 deletions json_theme/lib/src/codec/theme_encoder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,7 @@ class ThemeEncoder {
/// * [encodeMainAxisSize]
/// * [encodeVerticalDirection]
static Map<String, dynamic>? encodeButtonBarThemeData(
// ignore: deprecated_member_use
ButtonBarThemeData? value,
) {
Map<String, dynamic>? result;
Expand Down Expand Up @@ -7082,6 +7083,7 @@ class ThemeEncoder {
),
'bottomSheetTheme': encodeBottomSheetThemeData(value.bottomSheetTheme),
'brightness': encodeBrightness(value.brightness),
// ignore: deprecated_member_use
'buttonBarTheme': encodeButtonBarThemeData(value.buttonBarTheme),
'buttonTheme': encodeButtonThemeData(value.buttonTheme),
'canvasColor': encodeColor(value.canvasColor),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class AutovalidateModeSchema {
'always',
'disabled',
'onUserInteraction',
'onUnfocus',
]),
};
}
2 changes: 1 addition & 1 deletion json_theme/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 'json_theme'
description: 'A library to dynamically generate a ThemeData object from a JSON file or dynamic map object'
homepage: 'https://github.com/peiffer-innovations/json_theme'
version: '6.5.1+1'
version: '6.5.1+2'

environment:
sdk: '>=3.2.0 <4.0.0'
Expand Down
4 changes: 3 additions & 1 deletion json_theme/test/json_theme_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ void main() {
},
'image': {
'alignment': 'center',
'filterQuality': 'low',
'filterQuality': 'medium',
'image': {
'bytes': base64Image,
'scale': 1.0,
Expand Down Expand Up @@ -1440,6 +1440,7 @@ void main() {
expect(ThemeDecoder.decodeButtonBarThemeData(null), null);
expect(ThemeEncoder.encodeButtonBarThemeData(null), null);

// ignore: deprecated_member_use
const entry = ButtonBarThemeData(
alignment: MainAxisAlignment.spaceEvenly,
buttonAlignedDropdown: true,
Expand Down Expand Up @@ -10184,6 +10185,7 @@ void main() {
bottomSheetTheme: const BottomSheetThemeData(
backgroundColor: Color(0xff000000),
),
// ignore: deprecated_member_use
buttonBarTheme: const ButtonBarThemeData(buttonHeight: 3.0),
buttonTheme: const ButtonThemeData(buttonColor: Color(0xffbbbbbb)),
canvasColor: const Color(0xffcccccc),
Expand Down