From 37eca8c85fe562ced0e98f900e61392a304f1a7a Mon Sep 17 00:00:00 2001 From: Jeff Peiffer Date: Tue, 20 Feb 2024 17:54:04 -0500 Subject: [PATCH] Flutter 3.19 --- json_theme/CHANGELOG.md | 6 +- json_theme/lib/src/codec/theme_decoder.dart | 73 +++++++++++-------- json_theme/lib/src/codec/theme_encoder.dart | 22 +++++- json_theme/lib/src/schema/all.dart | 1 + json_theme/lib/src/schema/schemas.dart | 1 + json_theme/lib/src/schema/schemas/enums.dart | 1 + .../enums/overflow_box_fit_schema.dart | 19 +++++ json_theme/pubspec.yaml | 18 ++--- json_theme/test/json_theme_test.dart | 30 +++++++- 9 files changed, 127 insertions(+), 44 deletions(-) create mode 100644 json_theme/lib/src/schema/schemas/enums/overflow_box_fit_schema.dart diff --git a/json_theme/CHANGELOG.md b/json_theme/CHANGELOG.md index 84b4dec..5022e76 100644 --- a/json_theme/CHANGELOG.md +++ b/json_theme/CHANGELOG.md @@ -1,6 +1,8 @@ -## [6.4.0+1] - February 20, 2024 +## [6.4.1] - February 20th, 2024 -* Automated dependency updates +* Dependency updates +* Added `OverflowBoxFit` +* Update for Flutter 3.19 ## [6.4.0] - November 17th, 2023 diff --git a/json_theme/lib/src/codec/theme_decoder.dart b/json_theme/lib/src/codec/theme_decoder.dart index 52f55b5..4cce0d9 100644 --- a/json_theme/lib/src/codec/theme_decoder.dart +++ b/json_theme/lib/src/codec/theme_decoder.dart @@ -5,7 +5,7 @@ import 'dart:ui'; import 'package:flutter/cupertino.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/semantics.dart'; +import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:json_class/json_class.dart'; import 'package:json_theme_annotation/json_theme_annotation.dart'; @@ -9093,6 +9093,46 @@ class ThemeDecoder { return result; } + /// Decodes the [value] to a [OverflowBoxFit]. Supported values are: + /// * `deferToChild` + /// * `max` + static OverflowBoxFit? decodeOverflowBoxFit( + dynamic value, { + bool validate = true, + }) { + OverflowBoxFit? result; + + if (value is OverflowBoxFit) { + result = value; + } else if (value != null) { + _checkSupported( + 'OverflowBoxFit', + [ + 'deferToChild', + 'max', + ], + value, + ); + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/overflow_box_fit', + value: value, + validate: validate, + )); + + switch (value) { + case 'deferToChild': + result = OverflowBoxFit.deferToChild; + break; + + case 'max': + result = OverflowBoxFit.max; + break; + } + } + + return result; + } + /// Decodes the [value] to a [PageTransitionsBuilder]. Supported values are: /// * `cupertino` /// * `fadeUpwards` @@ -13422,11 +13462,7 @@ class ThemeDecoder { validate: validate, )); result = ThemeData( - // accentColor: @deprecated - // accentColorBrightness: @deprecated - // accentIconTheme: @deprecated - // accentTextTheme: @deprecated - // androidOverscrollIndicator: @deprecated + // adaptations: @unencodable, actionIconTheme: decodeActionIconThemeData( value['actionIconThemeData'], validate: false, @@ -13438,7 +13474,6 @@ class ThemeDecoder { applyElevationOverlayColor: JsonClass.maybeParseBool( value['applyElevationOverlayColor'], ), - // backgroundColor: @deprecated, badgeTheme: decodeBadgeThemeData( value['badgeTheme'], validate: false, @@ -13468,9 +13503,6 @@ class ThemeDecoder { value['buttonBarTheme'], validate: false, ), - - // buttonColor: @deprecated - buttonTheme: decodeButtonThemeData( value['buttonTheme'], validate: false, @@ -13507,9 +13539,6 @@ class ThemeDecoder { value['cupertinoOverrideTheme'], validate: false, ), - - // cursorColor: @deprecated - datePickerTheme: decodeDatePickerThemeData( value['datePickerThemeData'], validate: false, @@ -13554,21 +13583,15 @@ class ThemeDecoder { value['expansionTileTheme'], validate: false, ), - - // errorColor: @deprecated, // extensions: @unencodable, - filledButtonTheme: decodeFilledButtonThemeData( value['filledButtonTheme'], validate: false, ), - - // fixTextFieldOutlineLabel: @deprecated floatingActionButtonTheme: decodeFloatingActionButtonThemeData( value['floatingActionButtonTheme'], validate: false, ), - focusColor: decodeColor( value['focusColor'], validate: false, @@ -13660,9 +13683,6 @@ class ThemeDecoder { value['primaryColor'], validate: false, ), - - // primaryColorBrightness: @deprecated - primaryColorDark: decodeColor( value['primaryColorDark'], validate: false, @@ -13715,8 +13735,6 @@ class ThemeDecoder { value['segmentedButtonTheme'], validate: false, ), - // selectedRowColor: @deprecated - shadowColor: decodeColor( value['shadowColor'], validate: false, @@ -13749,10 +13767,6 @@ class ThemeDecoder { value['textButtonTheme'], validate: false, ), - - // textSelectionColor: @deprecated, - // textSelectionHandleColor: @deprecated, - textSelectionTheme: decodeTextSelectionThemeData( value['textSelectionTheme'], validate: false, @@ -13783,9 +13797,6 @@ class ThemeDecoder { validate: false, ), useMaterial3: JsonClass.maybeParseBool(value['useMaterial3']), - - // useTextSelectionTheme: @deprecated, - visualDensity: decodeVisualDensity( value['visualDensity'], validate: false, diff --git a/json_theme/lib/src/codec/theme_encoder.dart b/json_theme/lib/src/codec/theme_encoder.dart index 767f364..5c165ec 100644 --- a/json_theme/lib/src/codec/theme_encoder.dart +++ b/json_theme/lib/src/codec/theme_encoder.dart @@ -4,7 +4,7 @@ import 'dart:ui'; import 'package:flutter/cupertino.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/semantics.dart'; +import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:json_theme_annotation/json_theme_annotation.dart'; @@ -4947,6 +4947,26 @@ class ThemeEncoder { return _stripDynamicNull(result); } + /// Encodes the [value] to a [String]. Supported values are: + /// * `deferToChild` + /// * `max` + static String? encodeOverflowBoxFit(OverflowBoxFit? value) { + String? result; + + if (value != null) { + switch (value) { + case OverflowBoxFit.deferToChild: + result = 'deferToChild'; + break; + + case OverflowBoxFit.max: + result = 'max'; + break; + } + } + return _stripDynamicNull(result); + } + /// Encodes the [value] to a [String]. Supported values are: /// * `cupertino` /// * `fadeUpwards` diff --git a/json_theme/lib/src/schema/all.dart b/json_theme/lib/src/schema/all.dart index 7b65d19..60dbdb0 100644 --- a/json_theme/lib/src/schema/all.dart +++ b/json_theme/lib/src/schema/all.dart @@ -40,6 +40,7 @@ export 'schemas/enums/max_length_enforcement_schema.dart'; export 'schemas/enums/navigation_destination_label_behavior_schema.dart'; export 'schemas/enums/navigation_rail_label_type_schema.dart'; export 'schemas/enums/notched_shape_schema.dart'; +export 'schemas/enums/overflow_box_fit_schema.dart'; export 'schemas/enums/page_transitions_builder_schema.dart'; export 'schemas/enums/pan_axis_schema.dart'; export 'schemas/enums/pointer_device_kind_schema.dart'; diff --git a/json_theme/lib/src/schema/schemas.dart b/json_theme/lib/src/schema/schemas.dart index 3c36a30..488393c 100644 --- a/json_theme/lib/src/schema/schemas.dart +++ b/json_theme/lib/src/schema/schemas.dart @@ -139,6 +139,7 @@ class Schemas { OrdinalSortKeySchema.id: OrdinalSortKeySchema.schema, OutlinedBorderSchema.id: OutlinedBorderSchema.schema, OutlinedButtonThemeDataSchema.id: OutlinedButtonThemeDataSchema.schema, + OverflowBoxFitSchema.id: OverflowBoxFitSchema.schema, PanAxisSchema.id: PanAxisSchema.schema, PageTransitionsBuilderSchema.id: PageTransitionsBuilderSchema.schema, PageTransitionsThemeSchema.id: PageTransitionsThemeSchema.schema, diff --git a/json_theme/lib/src/schema/schemas/enums.dart b/json_theme/lib/src/schema/schemas/enums.dart index 0ab9de5..ddbca10 100644 --- a/json_theme/lib/src/schema/schemas/enums.dart +++ b/json_theme/lib/src/schema/schemas/enums.dart @@ -45,6 +45,7 @@ class Enums { NavigationRailLabelTypeSchema.id, NavigationDestinationLabelBehaviorSchema.id, NotchedShapeSchema.id, + OverflowBoxFitSchema.id, PageTransitionsBuilderSchema.id, PanAxisSchema.id, PointerDeviceKindSchema.id, diff --git a/json_theme/lib/src/schema/schemas/enums/overflow_box_fit_schema.dart b/json_theme/lib/src/schema/schemas/enums/overflow_box_fit_schema.dart new file mode 100644 index 0000000..86f5caa --- /dev/null +++ b/json_theme/lib/src/schema/schemas/enums/overflow_box_fit_schema.dart @@ -0,0 +1,19 @@ +import 'package:json_theme/json_theme_schemas.dart'; + +class OverflowBoxFitSchema { + static const id = + 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/overflow_box_fit.json'; + + static final schema = { + r'$schema': 'http://json-schema.org/draft-07/schema#', + r'$id': id, + r'$comment': + 'https://api.flutter.dev/flutter/rendering/OverflowBoxFit.html', + 'title': 'OverflowBoxFit', + 'type': 'string', + 'oneOf': SchemaHelper.enumSchema([ + 'deferToChild', + 'max', + ]), + }; +} diff --git a/json_theme/pubspec.yaml b/json_theme/pubspec.yaml index f6c8796..b5ee07a 100644 --- a/json_theme/pubspec.yaml +++ b/json_theme/pubspec.yaml @@ -1,18 +1,18 @@ 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.4.0+1' +version: '6.4.1' -environment: +environment: sdk: '>=3.2.0 <4.0.0' -analyzer: - exclude: +analyzer: + exclude: - 'lib/generated/**' - 'lib/**/*.g.dart' -dependencies: - flutter: +dependencies: + flutter: sdk: 'flutter' json_class: '^3.0.0+12' json_schema: '^5.1.3' @@ -20,19 +20,19 @@ dependencies: logging: '^1.2.0' meta: '^1.10.0' -dev_dependencies: +dev_dependencies: analyzer: '^6.4.1' build: '^2.4.1' build_runner: '^2.4.8' code_builder: '^4.10.0' flutter_lints: '^3.0.1' - flutter_test: + flutter_test: sdk: 'flutter' json_theme_codegen: '^1.1.2+9' recase: '^4.1.0' source_gen: '^1.5.0' -ignore_updates: +ignore_updates: - 'archive' - 'async' - 'boolean_selector' diff --git a/json_theme/test/json_theme_test.dart b/json_theme/test/json_theme_test.dart index 5b688ea..ff19892 100644 --- a/json_theme/test/json_theme_test.dart +++ b/json_theme/test/json_theme_test.dart @@ -4,7 +4,7 @@ import 'dart:ui'; import 'package:flutter/cupertino.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/semantics.dart'; +import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:json_class/json_class.dart'; @@ -7387,6 +7387,34 @@ void main() { ); }); + test('OverflowBoxFit', () { + expect(ThemeDecoder.decodeOverflowBoxFit(null), null); + expect(ThemeEncoder.encodeOverflowBoxFit(null), null); + + expect( + ThemeDecoder.decodeOverflowBoxFit(OverflowBoxFit.deferToChild), + OverflowBoxFit.deferToChild, + ); + + expect( + ThemeDecoder.decodeOverflowBoxFit('deferToChild'), + OverflowBoxFit.deferToChild, + ); + expect( + ThemeDecoder.decodeOverflowBoxFit('max'), + OverflowBoxFit.max, + ); + + expect( + ThemeEncoder.encodeOverflowBoxFit(OverflowBoxFit.deferToChild), + 'deferToChild', + ); + expect( + ThemeEncoder.encodeOverflowBoxFit(OverflowBoxFit.max), + 'max', + ); + }); + test('PageTransitionsBuilder', () { expect(ThemeDecoder.decodePageTransitionsBuilder(null), null); expect(ThemeEncoder.encodePageTransitionsBuilder(null), null);