diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index dbdbefd..c143267 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -27,7 +27,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Flutter uses: subosito/flutter-action@v2 diff --git a/.github/workflows/publish_annotation.yml b/.github/workflows/publish_annotation.yml index 703cbe4..451cb74 100644 --- a/.github/workflows/publish_annotation.yml +++ b/.github/workflows/publish_annotation.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Validate uses: peiffer-innovations/actions-flutter-validate@v1 diff --git a/.github/workflows/publish_codegen.yml b/.github/workflows/publish_codegen.yml index 5508c10..3ff3984 100644 --- a/.github/workflows/publish_codegen.yml +++ b/.github/workflows/publish_codegen.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Validate uses: peiffer-innovations/actions-flutter-validate@v1 diff --git a/.github/workflows/publisher.yml b/.github/workflows/publisher.yml index cd14271..3686587 100644 --- a/.github/workflows/publisher.yml +++ b/.github/workflows/publisher.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Flutter uses: subosito/flutter-action@v2 @@ -32,7 +32,7 @@ jobs: path: json_theme - name: Checkout Schemas - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: peiffer-innovations/flutter_json_schemas token: ${{ secrets.REPO_TOKEN }} diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 03a446c..ec35bc9 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Validate uses: peiffer-innovations/actions-flutter-validate@v1 with: diff --git a/.github/workflows/update_dependencies.yml b/.github/workflows/update_dependencies.yml index 9b8692a..382997b 100644 --- a/.github/workflows/update_dependencies.yml +++ b/.github/workflows/update_dependencies.yml @@ -11,7 +11,7 @@ jobs: steps: - name: Dependencies - uses: peiffer-innovations/actions-dart-dependency-updater@v1.0.18 + uses: peiffer-innovations/actions-dart-dependency-updater@v1 with: merge: true paths: annotation @@ -25,7 +25,7 @@ jobs: steps: - name: Dependencies - uses: peiffer-innovations/actions-dart-dependency-updater@v1.0.18 + uses: peiffer-innovations/actions-dart-dependency-updater@v1 with: merge: true paths: codegen @@ -39,7 +39,7 @@ jobs: steps: - name: Dependencies - uses: peiffer-innovations/actions-dart-dependency-updater@v1.0.18 + uses: peiffer-innovations/actions-dart-dependency-updater@v1 with: merge: true paths: json_theme,json_theme/example diff --git a/annotation/pubspec.yaml b/annotation/pubspec.yaml index d35b7cb..ba5a5a0 100644 --- a/annotation/pubspec.yaml +++ b/annotation/pubspec.yaml @@ -3,19 +3,19 @@ description: 'Simple package holding the annotations needed by the JsonTheme cod homepage: 'https://github.com/peiffer-innovations/json_theme' version: '1.0.3+7' -environment: +environment: sdk: '>=3.0.0 <4.0.0' -analyzer: - exclude: +analyzer: + exclude: - 'lib/generated/**' - 'lib/**/*.g.dart' -dev_dependencies: - flutter_lints: '^3.0.2' +dev_dependencies: + flutter_lints: '^4.0.0' test: '^1.25.5' -ignore_updates: +ignore_updates: - 'archive' - 'async' - 'boolean_selector' diff --git a/codegen/pubspec.yaml b/codegen/pubspec.yaml index 35b0cb0..2caa1c8 100644 --- a/codegen/pubspec.yaml +++ b/codegen/pubspec.yaml @@ -3,15 +3,15 @@ description: 'A library to generate the mapping of decoders to the class names t homepage: 'https://github.com/peiffer-innovations/json_theme' version: '1.1.2+14' -environment: +environment: sdk: '>=3.0.0 <4.0.0' -analyzer: - exclude: +analyzer: + exclude: - 'lib/generated/**' - 'lib/**/*.g.dart' -dependencies: +dependencies: analyzer: '^6.4.1' build: '^2.4.1' build_runner: '^2.4.9' @@ -20,15 +20,15 @@ dependencies: recase: '^4.1.0' source_gen: '^1.5.0' -dev_dependencies: - flutter_lints: '^3.0.2' - test: '^1.25.4' +dev_dependencies: + flutter_lints: '^4.0.0' + test: '^1.25.5' -dependency_overrides: - json_theme_annotation: +dependency_overrides: + json_theme_annotation: path: '../annotation' -ignore_updates: +ignore_updates: - 'archive' - 'async' - 'boolean_selector' diff --git a/json_theme/CHANGELOG.md b/json_theme/CHANGELOG.md index 8d54573..41b53f6 100644 --- a/json_theme/CHANGELOG.md +++ b/json_theme/CHANGELOG.md @@ -1,3 +1,8 @@ +## [6.5.0] - May 14th, 2024 + +* Swapped MaterialStateProperty with WidgetStateProperty in preperation for other Flutter 3.22 work. + + ## [6.4.1+5] - April 30, 2024 * Automated dependency updates diff --git a/json_theme/example/macos/Podfile.lock b/json_theme/example/macos/Podfile.lock index 92122f4..3dd1996 100644 --- a/json_theme/example/macos/Podfile.lock +++ b/json_theme/example/macos/Podfile.lock @@ -16,8 +16,8 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 - path_provider_foundation: eaf5b3e458fc0e5fbb9940fb09980e853fe058b8 + path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7 -COCOAPODS: 1.12.1 +COCOAPODS: 1.15.2 diff --git a/json_theme/example/macos/Runner.xcodeproj/project.pbxproj b/json_theme/example/macos/Runner.xcodeproj/project.pbxproj index 57be845..7d261c7 100644 --- a/json_theme/example/macos/Runner.xcodeproj/project.pbxproj +++ b/json_theme/example/macos/Runner.xcodeproj/project.pbxproj @@ -203,7 +203,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = "The Flutter Authors"; TargetAttributes = { 33CC10EC2044A3C60003C045 = { diff --git a/json_theme/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/json_theme/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index ad089fa..bfbc9cb 100644 --- a/json_theme/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/json_theme/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ =3.3.0 <4.0.0' -dependencies: - flutter: +dependencies: + flutter: sdk: 'flutter' form_validation: '^3.1.1+5' google_fonts: '^6.2.1' intl: '^0.19.0' - json_theme: + json_theme: path: '../' - meta: '^1.10.0' + meta: '1.12.0' -dev_dependencies: - flutter_lints: '^3.0.2' - flutter_test: +dev_dependencies: + flutter_lints: '^4.0.0' + flutter_test: sdk: 'flutter' -flutter: +flutter: uses-material-design: true - assets: + assets: - 'assets/themes/' - fonts: + fonts: - family: 'lato' - fonts: + fonts: - asset: 'assets/fonts/Lato-Regular.ttf' - family: 'metal' - fonts: + fonts: - asset: 'assets/fonts/MetalMania-Regular.ttf' - family: 'MaterialIcons' - fonts: + fonts: - asset: 'assets/fonts/MaterialIcons-Regular.ttf' -ignore_updates: +ignore_updates: - 'archive' - 'async' - 'boolean_selector' diff --git a/json_theme/lib/json_theme.dart b/json_theme/lib/json_theme.dart index 74d7709..a26903b 100644 --- a/json_theme/lib/json_theme.dart +++ b/json_theme/lib/json_theme.dart @@ -2,4 +2,4 @@ export 'json_theme_schemas.dart'; // export 'src/codec/theme_decoder.dart'; export 'src/codec/theme_encoder.dart'; -export 'src/model/json_material_state_property.dart'; +export 'src/model/json_widget_state_property.dart'; diff --git a/json_theme/lib/src/codec/theme_decoder.dart b/json_theme/lib/src/codec/theme_decoder.dart index 806e860..db22a2f 100644 --- a/json_theme/lib/src/codec/theme_decoder.dart +++ b/json_theme/lib/src/codec/theme_decoder.dart @@ -10,7 +10,7 @@ import 'package:flutter/services.dart'; import 'package:json_class/json_class.dart'; import 'package:json_theme_annotation/json_theme_annotation.dart'; -import '../model/map_material_state_property.dart'; +import '../model/map_widget_state_property.dart'; import '../schema/schema_validator.dart'; /// Decoder capable of converting JSON compatible values into Flutter Theme @@ -1305,7 +1305,7 @@ class ThemeDecoder { /// "elevation": "", /// "enableFeedback": "", /// "landscapeLayout": "", - /// "mouseCursor": ">", + /// "mouseCursor": ">", /// "selectedIconTheme": "", /// "selectedIconColor": "", /// "selectedLabelStyle": "", @@ -1323,7 +1323,7 @@ class ThemeDecoder { /// * [decodeBottomNavigationBarType] /// * [decodeColor] /// * [decodeIconThemeData] - /// * [decodeMaterialStatePropertyMouseCursor] + /// * [decodeWidgetStatePropertyMouseCursor] /// * [decodeTextStyle] static BottomNavigationBarThemeData? decodeBottomNavigationBarThemeData( dynamic value, { @@ -1345,7 +1345,7 @@ class ThemeDecoder { value['landscapeLayout'], validate: false, ), - mouseCursor: decodeMaterialStatePropertyMouseCursor( + mouseCursor: decodeWidgetStatePropertyMouseCursor( value['mouseCursor'], validate: false, ), @@ -2119,47 +2119,47 @@ class ThemeDecoder { /// ```json /// { /// "alignment": "", - /// "animationDuration": ">", - /// "backgroundColor": ">", - /// "elevation": ">", + /// "animationDuration": ">", + /// "backgroundColor": ">", + /// "elevation": ">", /// "enableFeedback": "", - /// "fixedSize": ">", - /// "foregroundColor": ">", - /// "iconColor": ">", - /// "iconSize": ">", - /// "maximumSize": ">", - /// "minimumSize": ">", - /// "mouseCursor": ">", - /// "overlayColor": ">", - /// "padding": ">", - /// "shadowColor": ">", - /// "shape": ">", - /// "side": ">", + /// "fixedSize": ">", + /// "foregroundColor": ">", + /// "iconColor": ">", + /// "iconSize": ">", + /// "maximumSize": ">", + /// "minimumSize": ">", + /// "mouseCursor": ">", + /// "overlayColor": ">", + /// "padding": ">", + /// "shadowColor": ">", + /// "shape": ">", + /// "side": ">", /// "splashFactory": "", - /// "surfaceTintColor": ">", + /// "surfaceTintColor": ">", /// "tapTargetSize": "", - /// "textStyle": ">", + /// "textStyle": ">", /// "visualDensity": "" /// } /// ``` /// /// This will use the properties passed through JSON to create the - /// [MaterialStateProperty] of each corresponding property by using - /// the [MaterialStateProperty.all] function with the value passed in. + /// [WidgetStateProperty] of each corresponding property by using + /// the [WidgetStateProperty.all] function with the value passed in. /// /// See also: /// * [decodeBorderSide] /// * [decodeColor] /// * [decodeEdgeInsetsGeometry] /// * [decodeInteractiveInkFeatureFactory] - /// * [decodeMaterialStatePropertyBorderSide] - /// * [decodeMaterialStatePropertyColor] - /// * [decodeMaterialStatePropertyDouble] - /// * [decodeMaterialStatePropertyEdgeInsetsGeometry] - /// * [decodeMaterialStatePropertyMouseCursor] - /// * [decodeMaterialStatePropertyOutlinedBorder] - /// * [decodeMaterialStatePropertySize] - /// * [decodeMaterialStatePropertyTextStyle] + /// * [decodeWidgetStatePropertyBorderSide] + /// * [decodeWidgetStatePropertyColor] + /// * [decodeWidgetStatePropertyDouble] + /// * [decodeWidgetStatePropertyEdgeInsetsGeometry] + /// * [decodeWidgetStatePropertyMouseCursor] + /// * [decodeWidgetStatePropertyOutlinedBorder] + /// * [decodeWidgetStatePropertySize] + /// * [decodeWidgetStatePropertyTextStyle] /// * [decodeMaterialTapTargetSize] /// * [decodeMouseCursor] /// * [decodeOutlinedBorder] @@ -2189,60 +2189,60 @@ class ThemeDecoder { animationDuration: JsonClass.maybeParseDurationFromMillis( value['animationDuration'], ), - backgroundColor: decodeMaterialStatePropertyColor( + backgroundColor: decodeWidgetStatePropertyColor( value['backgroundColor'], validate: false, ), - elevation: decodeMaterialStatePropertyDouble( + elevation: decodeWidgetStatePropertyDouble( value['elevation'], validate: false, ), enableFeedback: JsonClass.maybeParseBool(value['enableFeedback']), - fixedSize: decodeMaterialStatePropertySize( + fixedSize: decodeWidgetStatePropertySize( value['fixedSize'], validate: false, ), - foregroundColor: decodeMaterialStatePropertyColor( + foregroundColor: decodeWidgetStatePropertyColor( value['foregroundColor'], validate: false, ), - iconColor: decodeMaterialStatePropertyColor( + iconColor: decodeWidgetStatePropertyColor( value['iconColor'], validate: false, ), - iconSize: decodeMaterialStatePropertyDouble( + iconSize: decodeWidgetStatePropertyDouble( value['iconSize'], validate: false, ), - maximumSize: decodeMaterialStatePropertySize( + maximumSize: decodeWidgetStatePropertySize( value['maximumSize'], validate: false, ), - minimumSize: decodeMaterialStatePropertySize( + minimumSize: decodeWidgetStatePropertySize( value['minimumSize'], validate: false, ), - mouseCursor: decodeMaterialStatePropertyMouseCursor( + mouseCursor: decodeWidgetStatePropertyMouseCursor( value['mouseCursor'], validate: false, ), - overlayColor: decodeMaterialStatePropertyColor( + overlayColor: decodeWidgetStatePropertyColor( value['overlayColor'], validate: false, ), - padding: decodeMaterialStatePropertyEdgeInsetsGeometry( + padding: decodeWidgetStatePropertyEdgeInsetsGeometry( value['padding'], validate: false, ), - shadowColor: decodeMaterialStatePropertyColor( + shadowColor: decodeWidgetStatePropertyColor( value['shadowColor'], validate: false, ), - shape: decodeMaterialStatePropertyOutlinedBorder( + shape: decodeWidgetStatePropertyOutlinedBorder( value['shape'], validate: false, ), - side: decodeMaterialStatePropertyBorderSide( + side: decodeWidgetStatePropertyBorderSide( value['side'], validate: false, ), @@ -2250,7 +2250,7 @@ class ThemeDecoder { value['splashFactory'], validate: false, ), - surfaceTintColor: decodeMaterialStatePropertyColor( + surfaceTintColor: decodeWidgetStatePropertyColor( value['surfaceTintColor'], validate: false, ), @@ -2258,7 +2258,7 @@ class ThemeDecoder { value['tapTargetSize'], validate: false, ), - textStyle: decodeMaterialStatePropertyTextStyle( + textStyle: decodeWidgetStatePropertyTextStyle( value['textStyle'], validate: false, ), @@ -2494,10 +2494,10 @@ class ThemeDecoder { /// ```json /// { /// "checkColor": "", - /// "fillColor": ">", + /// "fillColor": ">", /// "materialTapTargetSize": "", - /// "mouseCursor": ">", - /// "overlayColor": ">", + /// "mouseCursor": ">", + /// "overlayColor": ">", /// "shape": "", /// "side": "", /// "splashRadius": "", @@ -2508,8 +2508,8 @@ class ThemeDecoder { /// See also: /// * [decodeBorderSide] /// * [decodeColor] - /// * [decodeMaterialStatePropertyColor] - /// * [decodeMaterialStatePropertyMouseCursor] + /// * [decodeWidgetStatePropertyColor] + /// * [decodeWidgetStatePropertyMouseCursor] /// * [decodeMaterialTapTargetSize] /// * [decodeMouseCursor] /// * [decodeOutlinedBorder] @@ -2529,11 +2529,11 @@ class ThemeDecoder { validate: validate, )); result = CheckboxThemeData( - checkColor: decodeMaterialStatePropertyColor( + checkColor: decodeWidgetStatePropertyColor( value['checkColor'], validate: false, ), - fillColor: decodeMaterialStatePropertyColor( + fillColor: decodeWidgetStatePropertyColor( value['fillColor'], validate: false, ), @@ -2541,11 +2541,11 @@ class ThemeDecoder { value['materialTapTargetSize'], validate: false, ), - mouseCursor: decodeMaterialStatePropertyMouseCursor( + mouseCursor: decodeWidgetStatePropertyMouseCursor( value['mouseCursor'], validate: false, ), - overlayColor: decodeMaterialStatePropertyColor( + overlayColor: decodeWidgetStatePropertyColor( value['overlayColor'], validate: false, ), @@ -2576,7 +2576,7 @@ class ThemeDecoder { /// "backgroundColor": "", /// "brightness": "", /// "checkmarkColor": "", - /// "color": ">" + /// "color": ">" /// "deleteIconColor": "", /// "disabledColor": "", /// "elevation": "", @@ -2603,7 +2603,7 @@ class ThemeDecoder { /// * [decodeColor] /// * [decodeEdgeInsetsGeometry] /// * [decodeIconThemeData] - /// * [decodeMaterialStatePropertyColor] + /// * [decodeWidgetStatePropertyColor] /// * [decodeShapeBorder] /// * [decodeTextStyle] static ChipThemeData? decodeChipThemeData( @@ -2633,7 +2633,7 @@ class ThemeDecoder { value['checkmarkColor'], validate: false, ), - color: decodeMaterialStatePropertyColor( + color: decodeWidgetStatePropertyColor( value['color'], validate: false, ), @@ -2905,7 +2905,7 @@ class ThemeDecoder { /// "secondaryContainer": "", /// "shadow": "", /// "surface": "", - /// "surfaceVariant": "", + /// "surfaceContainerHighest": "", /// "tertiary": "", /// "tertiaryContainer": "" /// } @@ -2929,10 +2929,6 @@ class ThemeDecoder { validate: validate, )); result = ColorScheme( - background: decodeColor( - value['background'], - validate: false, - )!, brightness: decodeBrightness( value['brightness'], validate: false, @@ -2953,10 +2949,6 @@ class ThemeDecoder { value['inverseSurface'], validate: false, ), - onBackground: decodeColor( - value['onBackground'], - validate: false, - )!, onError: decodeColor( value['onError'], validate: false, @@ -3041,8 +3033,8 @@ class ThemeDecoder { value['surfaceTint'], validate: false, ), - surfaceVariant: decodeColor( - value['surfaceVariant'], + surfaceContainerHighest: decodeColor( + value['surfaceContainerHighest'] ?? value['surfaceVariant'], validate: false, ), tertiary: decodeColor( @@ -3307,9 +3299,9 @@ class ThemeDecoder { /// "backgroundColor": "", /// "cancelButtonStyle": "", /// "confirmButtonStyle": "", - /// "dayBackgroundColor": ">", - /// "dayForegroundColor": ">", - /// "dayOverlayColor": ">", + /// "dayBackgroundColor": ">", + /// "dayForegroundColor": ">", + /// "dayOverlayColor": ">", /// "dayStyle": "", /// "dividerColor": "", /// "elevation": "", @@ -3328,31 +3320,31 @@ class ThemeDecoder { /// "rangePickerShape": "", /// "rangePickerSurfaceTintColor": "", /// "rangeSelectionBackgroundColor": "", - /// "rangeSelectionOverlayColor": ">", + /// "rangeSelectionOverlayColor": ">", /// "shadowColor": "", /// "shape": "", /// "surfaceTintColor": "", - /// "todayBackgroundColor": ">", + /// "todayBackgroundColor": ">", /// "todayBorder": "", - /// "todayForegroundColor": ">", + /// "todayForegroundColor": ">", /// "weekdayStyle": "", - /// "yearBackgroundColor": ">", - /// "yearForegroundColor": ">", - /// "yearOverlayColor": ">", + /// "yearBackgroundColor": ">", + /// "yearForegroundColor": ">", + /// "yearOverlayColor": ">", /// "yearStyle": "" /// } /// ``` /// /// This will use the properties passed through JSON to create the - /// [MaterialStateProperty] of each corresponding property by using - /// the [MaterialStateProperty.all] function with the value passed in. + /// [WidgetStateProperty] of each corresponding property by using + /// the [WidgetStateProperty.all] function with the value passed in. /// /// See also: /// * [decodeBorderSide] /// * [decodeButtonStyle] /// * [decodeColor] /// * [decodeInputDecorationTheme] - /// * [decodeMaterialStatePropertyColor] + /// * [decodeWidgetStatePropertyColor] /// * [decodeShapeBorder] /// * [decodeTextStyle] static DatePickerThemeData? decodeDatePickerThemeData( @@ -3382,15 +3374,15 @@ class ThemeDecoder { value['confirmButtonStyle'], validate: false, ), - dayBackgroundColor: decodeMaterialStatePropertyColor( + dayBackgroundColor: decodeWidgetStatePropertyColor( value['dayBackgroundColor'], validate: false, ), - dayForegroundColor: decodeMaterialStatePropertyColor( + dayForegroundColor: decodeWidgetStatePropertyColor( value['dayForegroundColor'], validate: false, ), - dayOverlayColor: decodeMaterialStatePropertyColor( + dayOverlayColor: decodeWidgetStatePropertyColor( value['dayOverlayColor'], validate: false, ), @@ -3461,7 +3453,7 @@ class ThemeDecoder { value['rangeSelectionBackgroundColor'], validate: false, ), - rangeSelectionOverlayColor: decodeMaterialStatePropertyColor( + rangeSelectionOverlayColor: decodeWidgetStatePropertyColor( value['rangeSelectionOverlayColor'], validate: false, ), @@ -3477,7 +3469,7 @@ class ThemeDecoder { value['surfaceTintColor'], validate: false, ), - todayBackgroundColor: decodeMaterialStatePropertyColor( + todayBackgroundColor: decodeWidgetStatePropertyColor( value['todayBackgroundColor'], validate: false, ), @@ -3485,7 +3477,7 @@ class ThemeDecoder { value['todayBorder'], validate: false, ), - todayForegroundColor: decodeMaterialStatePropertyColor( + todayForegroundColor: decodeWidgetStatePropertyColor( value['todayForegroundColor'], validate: false, ), @@ -3493,15 +3485,15 @@ class ThemeDecoder { value['weekdayStyle'], validate: false, ), - yearBackgroundColor: decodeMaterialStatePropertyColor( + yearBackgroundColor: decodeWidgetStatePropertyColor( value['yearBackgroundColor'], validate: false, ), - yearForegroundColor: decodeMaterialStatePropertyColor( + yearForegroundColor: decodeWidgetStatePropertyColor( value['yearForegroundColor'], validate: false, ), - yearOverlayColor: decodeMaterialStatePropertyColor( + yearOverlayColor: decodeWidgetStatePropertyColor( value['yearOverlayColor'], validate: false, ), @@ -3522,15 +3514,15 @@ class ThemeDecoder { /// { /// "checkboxHorizontalMargin": "", /// "columnSpacing": "", - /// "dataRowColor": ">", - /// "dataRowCursor": "", + /// "dataRowColor": ">", + /// "dataRowCursor": "", /// "dataRowMaxHeight": "", /// "dataRowMinHeight": "", /// "dataTextStyle": "", /// "dividerThickness": "", - /// "headingCellCursor": "", - /// "headingRowColor": ">", + /// "headingCellCursor": "", + /// "headingRowColor": ">", /// "headingRowHeight": "", /// "headingTextStyle": "", /// "horizontalMargin": "" @@ -3538,14 +3530,14 @@ class ThemeDecoder { /// ``` /// /// This will use the properties passed through JSON to create the - /// [MaterialStateProperty] of each corresponding property by using - /// the [MaterialStateProperty.all] function with the value passed in. + /// [WidgetStateProperty] of each corresponding property by using + /// the [WidgetStateProperty.all] function with the value passed in. /// /// See also: /// * [decodeBoxDecoration] /// * [decodeColor] - /// * [decodeMaterialStatePropertyColor] - /// * [decodeMaterialStatePropertyMouseCursor] + /// * [decodeWidgetStatePropertyColor] + /// * [decodeWidgetStatePropertyMouseCursor] /// * [decodeTextStyle] static DataTableThemeData? decodeDataTableThemeData( dynamic value, { @@ -3568,11 +3560,11 @@ class ThemeDecoder { columnSpacing: JsonClass.maybeParseDouble( value['columnSpacing'], ), - dataRowColor: decodeMaterialStatePropertyColor( + dataRowColor: decodeWidgetStatePropertyColor( value['dataRowColor'], validate: false, ), - dataRowCursor: decodeMaterialStatePropertyMouseCursor( + dataRowCursor: decodeWidgetStatePropertyMouseCursor( value['dataRowCursor'], validate: false, ), @@ -3595,11 +3587,11 @@ class ThemeDecoder { dividerThickness: JsonClass.maybeParseDouble( value['dividerThickness'], ), - headingCellCursor: decodeMaterialStatePropertyMouseCursor( + headingCellCursor: decodeWidgetStatePropertyMouseCursor( value['dataRowCursor'], validate: false, ), - headingRowColor: decodeMaterialStatePropertyColor( + headingRowColor: decodeWidgetStatePropertyColor( value['headingRowColor'], validate: false, ), @@ -4666,7 +4658,7 @@ class ThemeDecoder { /// "hoverElevation": "", /// "iconSize": "", /// "largeSizeConstraints": "", - /// "mouseCursor": ">", + /// "mouseCursor": ">", /// "shape": "", /// "sizeConstraints": "", /// "smallSizeConstraints": "", @@ -4677,7 +4669,7 @@ class ThemeDecoder { /// See also: /// * [decodeBoxConstraints] /// * [decodeColor] - /// * [decodeMaterialStatePropertyMouseCursor] + /// * [decodeWidgetStatePropertyMouseCursor] /// * [decodeShapeBorder] /// * [decodeTextStyle] static FloatingActionButtonThemeData? decodeFloatingActionButtonThemeData( @@ -4739,7 +4731,7 @@ class ThemeDecoder { value['largeSizeConstraints'], validate: false, ), - mouseCursor: decodeMaterialStatePropertyMouseCursor( + mouseCursor: decodeWidgetStatePropertyMouseCursor( value['mouseCursor'], validate: false, ), @@ -6111,7 +6103,7 @@ class ThemeDecoder { /// "leadingAndTrailingTextStyle": "", /// "minLeadingWidth": "", /// "minVerticalPadding": "", - /// "mouseCursor": ">", + /// "mouseCursor": ">", /// "selectedColor": "", /// "selectedTileColor": "", /// "shape": "", @@ -6156,7 +6148,7 @@ class ThemeDecoder { minLeadingWidth: JsonClass.maybeParseDouble(value['minLeadingWidth']), minVerticalPadding: JsonClass.maybeParseDouble(value['minVerticalPadding']), - mouseCursor: decodeMaterialStatePropertyMouseCursor( + mouseCursor: decodeWidgetStatePropertyMouseCursor( value['mouseCursor'], validate: false, ), @@ -6456,1821 +6448,1329 @@ class ThemeDecoder { return result; } - /// Decodes a [value] into a [MaterialStateColor]. If the value is a - /// [String] then the value will be used for all states. - /// - /// Alternatively, if the [value] is a [Map] then this expects the following - /// format: - /// - /// ```json - /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "" - /// } - /// ``` - /// - /// The "empty" will be used for when any other value is missing. - static MaterialStateColor? decodeMaterialStateColor( + /// Decodes the [value] to a [MaterialTargetTapSize]. Supported values are: + /// * `padded` + /// * `shrinkWrap` + static MaterialTapTargetSize? decodeMaterialTapTargetSize( dynamic value, { bool validate = true, }) { - MaterialStateColor? result; - - if (value is MaterialStateColor) { + MaterialTapTargetSize? result; + if (value is MaterialTapTargetSize) { result = value; - } else if (value is Color) { - result = MaterialStateColor.resolveWith((_) => value); - } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/material_state_color', - value: value, - validate: validate, - )); - - result = MaterialStateColor.resolveWith((states) { - Color? result; - - if (value is String) { - result = decodeColor(value, validate: false); - } else if (value is Color) { - result = value; - } else if (states.contains(MaterialState.disabled)) { - result = decodeColor( - value['disabled'], - validate: false, - ); - } else if (states.contains(MaterialState.dragged)) { - result = decodeColor( - value['dragged'], - validate: false, - ); - } else if (states.contains(MaterialState.error)) { - result = decodeColor( - value['error'], - validate: false, - ); - } else if (states.contains(MaterialState.focused)) { - result = decodeColor( - value['focused'], - validate: false, - ); - } else if (states.contains(MaterialState.hovered)) { - result = decodeColor( - value['hovered'], - validate: false, - ); - } else if (states.contains(MaterialState.pressed)) { - result = decodeColor( - value['pressed'], - validate: false, - ); - } else if (states.contains(MaterialState.scrolledUnder)) { - result = decodeColor( - value['scrolledUnder'], - validate: false, - ); - } else if (states.contains(MaterialState.selected)) { - result = decodeColor( - value['selected'], - validate: false, - ); - } - - result ??= decodeColor( - value['empty'], - validate: false, - ); + } else { + _checkSupported( + 'MaterialTapTargetSize', + [ + 'padded', + 'shrinkWrap', + ], + value, + ); - if (result == null) { - throw Exception( - 'Unable to decode required Color for MaterialStateColor for state: $states and no "empty" value exists.', - ); + if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/material_tap_target_size', + value: value, + validate: validate, + )); + switch (value) { + case 'padded': + result = MaterialTapTargetSize.padded; + break; + case 'shrinkWrap': + result = MaterialTapTargetSize.shrinkWrap; + break; } - - return result; - }); + } } return result; } - /// Decodes a [value] into a [double] based [MaterialStateProperty]. This - /// accepts a [double] or a [String] which will be resolved for all states. - /// - /// Alternatively, if the [value] is a [Map] then this expects the following - /// format: - /// - /// ```json - /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "" - /// } - /// ``` - static MaterialStateProperty? decodeMaterialStatePropertyBool( + /// Decodes the [value] to a [MaterialType]. Supported values are: + /// * `button` + /// * `canvas` + /// * `card` + /// * `circle` + /// * `transparency` + static MaterialType? decodeMaterialType( dynamic value, { bool validate = true, }) { - MaterialStateProperty? result; - - if (value is MaterialStateProperty) { + MaterialType? result; + if (value is MaterialType) { result = value; - } else if (value != null) { - if (value is int || value is double || value is bool || value is String) { - result = MaterialStateProperty.all(JsonClass.parseBool(value)); - } else if (value is Map) { + } else { + _checkSupported( + 'MaterialType', + [ + 'button', + 'canvas', + 'card', + 'circle', + 'transparency', + ], + value, + ); + + if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/material_state_property_bool', + schemaId: '$_baseSchemaUrl/material_type', value: value, validate: validate, )); - - result = MapMaterialStateProperty.resolveWith((states) { - bool? result; - if (states.contains(MaterialState.disabled)) { - result = JsonClass.maybeParseBool(value['disabled']); - } else if (states.contains(MaterialState.dragged)) { - result = JsonClass.maybeParseBool(value['dragged']); - } else if (states.contains(MaterialState.error)) { - result = JsonClass.maybeParseBool(value['error']); - } else if (states.contains(MaterialState.focused)) { - result = JsonClass.maybeParseBool(value['focused']); - } else if (states.contains(MaterialState.hovered)) { - result = JsonClass.maybeParseBool(value['hovered']); - } else if (states.contains(MaterialState.pressed)) { - result = JsonClass.maybeParseBool(value['pressed']); - } else if (states.contains(MaterialState.scrolledUnder)) { - result = JsonClass.maybeParseBool(value['scrolledUnder']); - } else if (states.contains(MaterialState.selected)) { - result = JsonClass.maybeParseBool(value['selected']); - } else { - result = JsonClass.maybeParseBool(value['empty']); - } - - return result; - }); - } else { - result = MaterialStateProperty.all(value); + switch (value) { + case 'button': + result = MaterialType.button; + break; + case 'canvas': + result = MaterialType.canvas; + break; + case 'card': + result = MaterialType.card; + break; + case 'circle': + result = MaterialType.circle; + break; + case 'transparency': + result = MaterialType.transparency; + break; + } } } + return result; } - /// Decodes a [value] into a [BorderSide] based [MaterialStateProperty]. This - /// accepts a [BorderSide] or a [String] which will be resolved for all - /// states. - /// - /// Alternatively, if the [value] is a [Map] then this expects the following - /// format: + /// Decodes the [value] to a [Matrix4]. This requires the value to be an + /// [Iterable] of [double] with exactly 16 elements in it. /// - /// ```json - /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "" - /// } + /// The array is expected to be in the following format: /// ``` - /// - /// See also: - /// * [decodeBorderSide] - static MaterialStateProperty? - decodeMaterialStatePropertyBorderSide( + /// [ + /// x0, + /// x1, + /// x2, + /// x3, + /// y0, + /// y1, + /// y2, + /// y3, + /// z0, + /// z1, + /// z2, + /// z3, + /// w0, + /// w1, + /// w2, + /// w3 + /// ] + /// ``` + static Matrix4? decodeMatrix4( dynamic value, { bool validate = true, }) { - MaterialStateProperty? result; + Matrix4? result; - if (value is MaterialStateProperty) { + if (value is Matrix4) { result = value; - } else if (value != null) { - if (value is BorderSide) { - result = MaterialStateProperty.all(value); - } else if (value is String) { - result = MaterialStateProperty.all( - decodeBorderSide( - value, - validate: false, - ), - ); - } else if (value is Map) { - final testValues = [ - 'disabled', - 'dragged', - 'empty', - 'error', - 'focused', - 'hovered', - 'pressed', - 'scrolledUnder', - 'selected', - ]; - - var isMsp = false; - for (var key in value.keys) { - if (testValues.contains(key)) { - isMsp = true; - break; - } - } + } else { + if (value is Iterable) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/matrix4', + value: value, + validate: validate, + )); + final list = value.toList(); + result = Matrix4( + JsonClass.maybeParseDouble(list[0])!, + JsonClass.maybeParseDouble(list[1])!, + JsonClass.maybeParseDouble(list[2])!, + JsonClass.maybeParseDouble(list[3])!, + JsonClass.maybeParseDouble(list[4])!, + JsonClass.maybeParseDouble(list[5])!, + JsonClass.maybeParseDouble(list[6])!, + JsonClass.maybeParseDouble(list[7])!, + JsonClass.maybeParseDouble(list[8])!, + JsonClass.maybeParseDouble(list[9])!, + JsonClass.maybeParseDouble(list[10])!, + JsonClass.maybeParseDouble(list[11])!, + JsonClass.maybeParseDouble(list[12])!, + JsonClass.maybeParseDouble(list[13])!, + JsonClass.maybeParseDouble(list[14])!, + JsonClass.maybeParseDouble(list[15])!, + ); + } + } - if (isMsp != true) { - result = MaterialStateProperty.all( - decodeBorderSide( - value, - validate: false, - ), - ); - } else { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/material_state_property_border_side', - value: value, - validate: validate, - )); + return result; + } - result = MapMaterialStateProperty.resolveWith((states) { - BorderSide? result; - if (states.contains(MaterialState.disabled)) { - result = decodeBorderSide( - value['disabled'], - validate: false, - ); - } else if (states.contains(MaterialState.dragged)) { - result = decodeBorderSide( - value['dragged'], - validate: false, - ); - } else if (states.contains(MaterialState.error)) { - result = decodeBorderSide( - value['error'], - validate: false, - ); - } else if (states.contains(MaterialState.focused)) { - result = decodeBorderSide( - value['focused'], - validate: false, - ); - } else if (states.contains(MaterialState.hovered)) { - result = decodeBorderSide( - value['hovered'], - validate: false, - ); - } else if (states.contains(MaterialState.pressed)) { - result = decodeBorderSide( - value['pressed'], - validate: false, - ); - } else if (states.contains(MaterialState.scrolledUnder)) { - result = decodeBorderSide( - value['scrolledUnder'], - validate: false, - ); - } else if (states.contains(MaterialState.selected)) { - result = decodeBorderSide( - value['selected'], - validate: false, - ); - } else { - result = decodeBorderSide( - value['empty'], - validate: false, - ); - } + /// Decodes the [value] to a [MaxLengthEnforcement]. Supported values are: + /// * `enforced` + /// * `none` + /// * `truncateAfterCompositionEnds` + static MaxLengthEnforcement? decodeMaxLengthEnforcement( + dynamic value, { + bool validate = true, + }) { + MaxLengthEnforcement? result; + if (value is MaxLengthEnforcement) { + result = value; + } else { + _checkSupported( + 'MaxLengthEnforcement', + [ + 'enforced', + 'none', + 'truncateAfterCompositionEnds', + ], + value, + ); - return result; - }); + if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/max_length_enforcement', + value: value, + validate: validate, + )); + switch (value) { + case 'enforced': + result = MaxLengthEnforcement.enforced; + break; + case 'none': + result = MaxLengthEnforcement.none; + break; + case 'truncateAfterCompositionEnds': + result = MaxLengthEnforcement.truncateAfterCompositionEnds; + break; } - } else { - result = MaterialStateProperty.all(value); } } + return result; } - /// Decodes a [value] into a [Color] based [MaterialStateProperty]. This - /// accepts a [Color] or a [String] which will be resolved for all states. - /// - /// Alternatively, if the [value] is a [Map] then this expects the following - /// format: + /// Decodes the given [value] to an [MenuBarThemeData]. This expects the + /// given [value] to be of the following structure: /// /// ```json /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "" + /// "style": "" /// } /// ``` /// /// See also: - /// * [decodeColor] - static MaterialStateProperty? decodeMaterialStatePropertyColor( + /// * [decodeMenuStyle] + static MenuBarThemeData? decodeMenuBarThemeData( dynamic value, { bool validate = true, }) { - MaterialStateProperty? result; + MenuBarThemeData? result; - if (value is MaterialStateProperty) { + if (value is MenuBarThemeData) { result = value; } else if (value != null) { - if (value is Color) { - result = MaterialStateProperty.all(value); - } else if (value is String) { - result = MaterialStateProperty.all(decodeColor( + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/menu_bar_theme_data', + value: value, + validate: validate, + )); + + result = MenuBarThemeData( + style: decodeMenuStyle( value, validate: false, - )); - } else if (value is Map) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/material_state_property_color', - value: value, - validate: validate, - )); - - result = MapMaterialStateProperty.resolveWith((states) { - Color? result; - if (states.contains(MaterialState.disabled)) { - result = decodeColor( - value['disabled'], - validate: false, - ); - } else if (states.contains(MaterialState.dragged)) { - result = decodeColor( - value['dragged'], - validate: false, - ); - } else if (states.contains(MaterialState.error)) { - result = decodeColor( - value['error'], - validate: false, - ); - } else if (states.contains(MaterialState.focused)) { - result = decodeColor( - value['focused'], - validate: false, - ); - } else if (states.contains(MaterialState.pressed)) { - result = decodeColor( - value['pressed'], - validate: false, - ); - } else if (states.contains(MaterialState.hovered)) { - result = decodeColor( - value['hovered'], - validate: false, - ); - } else if (states.contains(MaterialState.scrolledUnder)) { - result = decodeColor( - value['scrolledUnder'], - validate: false, - ); - } else if (states.contains(MaterialState.selected)) { - result = decodeColor( - value['selected'], - validate: false, - ); - } else { - result = decodeColor( - value['empty'], - validate: false, - ); - } - - return result; - }); - } else { - result = MaterialStateProperty.all(value); - } + ), + ); } + return result; } - /// Decodes a [value] into a [double] based [MaterialStateProperty]. This - /// accepts a [double] or a [String] which will be resolved for all states. - /// - /// Alternatively, if the [value] is a [Map] then this expects the following - /// format: + /// Decodes the given [value] to an [MenuButtonThemeData]. This expects the + /// given [value] to be of the following structure: /// /// ```json /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "" + /// "style": "", /// } /// ``` - static MaterialStateProperty? decodeMaterialStatePropertyDouble( + /// + /// See also: + /// * [decodeButtonStyle] + static MenuButtonThemeData? decodeMenuButtonThemeData( dynamic value, { bool validate = true, }) { - MaterialStateProperty? result; + MenuButtonThemeData? result; - if (value is MaterialStateProperty) { + if (value is MenuButtonThemeData) { result = value; } else if (value != null) { - if (value is int) { - result = MaterialStateProperty.all(value.toDouble()); - } else if (value is double) { - result = MaterialStateProperty.all(value); - } else if (value is String) { - result = MaterialStateProperty.all( - JsonClass.maybeParseDouble(value), - ); - } else if (value is Map) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/material_state_property_double', - value: value, - validate: validate, - )); + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/menu_button_theme_data', + value: value, + validate: validate, + )); - result = MapMaterialStateProperty.resolveWith((states) { - double? result; - if (states.contains(MaterialState.disabled)) { - result = JsonClass.maybeParseDouble(value['disabled']); - } else if (states.contains(MaterialState.dragged)) { - result = JsonClass.maybeParseDouble(value['dragged']); - } else if (states.contains(MaterialState.error)) { - result = JsonClass.maybeParseDouble(value['error']); - } else if (states.contains(MaterialState.focused)) { - result = JsonClass.maybeParseDouble(value['focused']); - } else if (states.contains(MaterialState.hovered)) { - result = JsonClass.maybeParseDouble(value['hovered']); - } else if (states.contains(MaterialState.pressed)) { - result = JsonClass.maybeParseDouble(value['pressed']); - } else if (states.contains(MaterialState.scrolledUnder)) { - result = JsonClass.maybeParseDouble(value['scrolledUnder']); - } else if (states.contains(MaterialState.selected)) { - result = JsonClass.maybeParseDouble(value['selected']); - } else { - result = JsonClass.maybeParseDouble(value['empty']); - } - - return result; - }); - } else { - result = MaterialStateProperty.all(value); - } + result = MenuButtonThemeData( + style: decodeButtonStyle( + value['style'], + validate: false, + ), + ); } + return result; } - /// Decodes a [value] into a [EdgeInsetsGeometry] based - /// [MaterialStateProperty]. - /// - /// If the value is a [String], [double], or [int] then this will parse the - /// number and pass it to [EdgeInsets.all] for each state. - /// - /// If the value is an array with two entities, this calls - /// [EdgeInsets.symmetric] with the first element passed as the horizontal and - /// the second as the vertical. - /// - /// If the value is an array with four entities, this calls - /// [EdgeInsets.fromLTRB] passing each element in order. - /// - /// The value may be a [Map] in the following format: - /// ```json - /// { - /// "bottom": "", - /// "left": "", - /// "right": "", - /// "top": "" - /// } - /// ``` - /// - /// Finally, the [value] may be a [Map] in the following format: + /// Decodes the given [value] to an [MenuStyle]. This expects the given + /// [value] to be of the following structure: /// /// ```json /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "" + /// "alignment": "", + /// "backgroundColor": ">", + /// "elevation": ">", + /// "fixedSize": ">", + /// "maximumSize": ">", + /// "minimumSize": ">", + /// "padding": ">", + /// "shadowColor": ">", + /// "shape": ">", + /// "side": ">", + /// "surfaceTintColor": ">", + /// "visualDensity": "", /// } /// ``` /// /// See also: - /// * [decodeEdgeInsetsGeometry] - static MaterialStateProperty? - decodeMaterialStatePropertyEdgeInsetsGeometry( + /// * [decodeAlignment] + /// * [decodeWidgetStatePropertyBorderSide] + /// * [decodeWidgetStatePropertyColor] + /// * [decodeWidgetStatePropertyDouble] + /// * [decodeWidgetStatePropertyEdgeInsetsGeometry] + /// * [decodeWidgetStatePropertyMouseCursor] + /// * [decodeWidgetStatePropertySize] + /// * [decodeVisualDensity] + static MenuStyle? decodeMenuStyle( dynamic value, { bool validate = true, }) { - MaterialStateProperty? result; + MenuStyle? result; - if (value is MaterialStateProperty) { + if (value is MenuStyle) { result = value; } else if (value != null) { - if (value is EdgeInsetsGeometry) { - result = MaterialStateProperty.all(value); - } else if (value is String || value is List || value is int) { - result = MaterialStateProperty.all( - decodeEdgeInsetsGeometry( - value, - validate: false, - ), - ); - } else if (value is Map) { - final testValues = [ - 'disabled', - 'dragged', - 'empty', - 'error', - 'focused', - 'hovered', - 'pressed', - 'scrolledUnder', - 'selected', - ]; - - var isMsp = false; - for (var key in value.keys) { - if (testValues.contains(key)) { - isMsp = true; - break; - } - } - - if (isMsp != true) { - result = MaterialStateProperty.all( - decodeEdgeInsetsGeometry( - value, - validate: false, - ), - ); - } else { - assert(SchemaValidator.validate( - schemaId: - '$_baseSchemaUrl/material_state_property_edge_insets_geometry', - value: value, - validate: validate, - )); - - result = MapMaterialStateProperty.resolveWith((states) { - EdgeInsetsGeometry? result; - if (states.contains(MaterialState.disabled)) { - result = decodeEdgeInsetsGeometry( - value['disabled'], - validate: false, - ); - } else if (states.contains(MaterialState.dragged)) { - result = decodeEdgeInsetsGeometry( - value['dragged'], - validate: false, - ); - } else if (states.contains(MaterialState.error)) { - result = decodeEdgeInsetsGeometry( - value['error'], - validate: false, - ); - } else if (states.contains(MaterialState.focused)) { - result = decodeEdgeInsetsGeometry( - value['focused'], - validate: false, - ); - } else if (states.contains(MaterialState.hovered)) { - result = decodeEdgeInsetsGeometry( - value['hovered'], - validate: false, - ); - } else if (states.contains(MaterialState.pressed)) { - result = decodeEdgeInsetsGeometry( - value['pressed'], - validate: false, - ); - } else if (states.contains(MaterialState.scrolledUnder)) { - result = decodeEdgeInsetsGeometry( - value['scrolledUnder'], - validate: false, - ); - } else if (states.contains(MaterialState.selected)) { - result = decodeEdgeInsetsGeometry( - value['selected'], - validate: false, - ); - } else { - result = decodeEdgeInsetsGeometry( - value['empty'], - validate: false, - ); - } + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/menu_style', + value: value, + validate: validate, + )); - return result; - }); - } - } else { - result = MaterialStateProperty.all(value); - } + result = MenuStyle( + alignment: decodeAlignment( + value['alignment'], + validate: false, + ), + backgroundColor: decodeWidgetStatePropertyColor( + value['backgroundColor'], + validate: false, + ), + elevation: decodeWidgetStatePropertyDouble( + value['elevation'], + validate: false, + ), + fixedSize: + decodeWidgetStatePropertySize(value['fixedSize'], validate: false), + maximumSize: decodeWidgetStatePropertySize( + value['maximumSize'], + validate: false, + ), + minimumSize: decodeWidgetStatePropertySize( + value['minimumSize'], + validate: false, + ), + mouseCursor: decodeWidgetStatePropertyMouseCursor( + value['mouseCursor'], + validate: false, + ), + padding: decodeWidgetStatePropertyEdgeInsetsGeometry( + value['padding'], + validate: false, + ), + shadowColor: decodeWidgetStatePropertyColor( + value['shadowColor'], + validate: false, + ), + shape: decodeWidgetStatePropertyOutlinedBorder( + value['shape'], + validate: false, + ), + side: decodeWidgetStatePropertyBorderSide( + value['side'], + validate: false, + ), + surfaceTintColor: decodeWidgetStatePropertyColor( + value['surfaceTintColor'], + validate: false, + ), + visualDensity: decodeVisualDensity( + value['visualDensity'], + validate: false, + ), + ); } + return result; } - /// Decodes a [value] into a [Icon] based [MaterialStateProperty]. This - /// accepts a [Icon] or a [String] which will be resolved for all states. - /// - /// Alternatively, if the [value] is a [Map] then this expects the following - /// format: + /// Decodes the given [value] to an [MenuThemeData]. This expects the given + /// [value] to be of the following structure: /// /// ```json /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "" + /// "style": "" /// } /// ``` /// /// See also: - /// * [decodeIconData] - static MaterialStateProperty? decodeMaterialStatePropertyIcon( + /// * [decodeMenuStyle] + static MenuThemeData? decodeMenuThemeData( dynamic value, { bool validate = true, }) { - MaterialStateProperty? result; + MenuThemeData? result; - if (value is MaterialStateProperty) { + if (value is MenuThemeData) { result = value; } else if (value != null) { - if (value is Icon) { - result = MaterialStateProperty.all(value); - } else if (value is IconData) { - result = MaterialStateProperty.all(Icon(value)); - } else if (value is Map) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/material_state_property_icon', - value: value, - validate: validate, - )); + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/menu_theme_data', + value: value, + validate: validate, + )); - result = MapMaterialStateProperty.resolveWith((states) { - Icon? result; - if (states.contains(MaterialState.disabled)) { - result = decodeIcon( - value['disabled'], - validate: false, - ); - } else if (states.contains(MaterialState.dragged)) { - result = decodeIcon( - value['dragged'], - validate: false, - ); - } else if (states.contains(MaterialState.error)) { - result = decodeIcon( - value['error'], - validate: false, - ); - } else if (states.contains(MaterialState.focused)) { - result = decodeIcon( - value['focused'], - validate: false, - ); - } else if (states.contains(MaterialState.pressed)) { - result = decodeIcon( - value['pressed'], - validate: false, - ); - } else if (states.contains(MaterialState.hovered)) { - result = decodeIcon( - value['hovered'], - validate: false, - ); - } else if (states.contains(MaterialState.scrolledUnder)) { - result = decodeIcon( - value['scrolledUnder'], - validate: false, - ); - } else if (states.contains(MaterialState.selected)) { - result = decodeIcon( - value['selected'], - validate: false, - ); - } else { - result = decodeIcon( - value['empty'], - validate: false, - ); - } - - return result; - }); - } else { - result = MaterialStateProperty.all(value); - } + result = MenuThemeData( + style: decodeMenuStyle( + value['style'], + validate: false, + ), + ); } + return result; } - /// Decodes a [value] into a [IconThemeData] based [MaterialStateProperty]. - /// This accepts a [IconThemeData] or a [String] which will be resolved for - /// all states. - /// - /// Alternatively, if the [value] is a [Map] then this expects the following - /// format: + /// Decodes the given [value] to a [MouseCursor]. There must be a "type" + /// attribute that is one of: + /// * `defer` + /// * `material` + /// * `system` + /// * `uncontrolled` /// - /// ```json - /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "" - /// } - /// ``` + /// When the `type` is `material`, this expects a `cursor` that is one of: + /// * `clickable` + /// * `textable` /// - /// See also: - /// * [decodeIconThemeData] - static MaterialStateProperty? - decodeMaterialStatePropertyIconThemeData( + /// When the `type` is `system`, this expects a `cursor` that is one of: + /// * `alias` + /// * `allScroll` + /// * `basic` + /// * `cell` + /// * `click` + /// * `contextMenu` + /// * `copy` + /// * `disappearing` + /// * `forbidden` + /// * `grab` + /// * `grabbing` + /// * `help` + /// * `move` + /// * `noDrop` + /// * `none` + /// * `precise` + /// * `progress` + /// * `resizeColumn` + /// * `resizeDown` + /// * `resizeDownLeft` + /// * `resizeDownRight` + /// * `resizeLeft` + /// * `resizeRight` + /// * `resizeRow` + /// * `resizeUp` + /// * `resizeUpDown` + /// * `resizeUpLeft` + /// * `resizeUpLeftDownRight` + /// * `resizeUpRight` + /// * `resizeUpRightDownLeft` + /// * `text` + /// * `verticalText` + /// * `wait` + /// * `zoomIn` + /// * `zoomOut` + static MouseCursor? decodeMouseCursor( dynamic value, { bool validate = true, }) { - MaterialStateProperty? result; - - if (value is MaterialStateProperty) { + MouseCursor? result; + if (value is MouseCursor) { result = value; - } else if (value != null) { - if (value is IconThemeData) { - result = MaterialStateProperty.all(value); - } else if (value is String) { - result = MaterialStateProperty.all( - decodeIconThemeData( - value, - validate: false, - ), - ); - } else if (value is Map) { - final testValues = [ - 'disabled', - 'dragged', - 'empty', - 'error', - 'focused', - 'hovered', - 'pressed', - 'scrolledUnder', - 'selected', - ]; + } else { + assert(value == null || value['type'] is String); + _checkSupported( + 'MouseCursor.type', + [ + 'defer', + 'material', + 'system', + 'uncontrolled', + ], + value == null ? null : value['type'], + ); - var isMsp = false; - for (var key in value.keys) { - if (testValues.contains(key)) { - isMsp = true; + if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/mouse_cursor', + value: value, + validate: validate, + )); + switch (value['type']) { + case 'defer': + result = MouseCursor.defer; break; - } - } - - if (isMsp != true) { - result = MaterialStateProperty.all( - decodeIconThemeData( - value, - validate: false, - ), - ); - } else { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/material_state_property_icon_theme_data', - value: value, - validate: validate, - )); + case 'material': + assert(value['cursor'] is String); + _checkSupported( + 'MouseCursor.cursor', + [ + 'clickable', + 'textable', + ], + value['cursor'], + ); + switch (value['cursor']) { + case 'clickable': + result = WidgetStateMouseCursor.clickable; + break; - result = MapMaterialStateProperty.resolveWith((states) { - IconThemeData? result; - if (states.contains(MaterialState.disabled)) { - result = decodeIconThemeData( - value['disabled'], - validate: false, - ); - } else if (states.contains(MaterialState.dragged)) { - result = decodeIconThemeData( - value['dragged'], - validate: false, - ); - } else if (states.contains(MaterialState.error)) { - result = decodeIconThemeData( - value['error'], - validate: false, - ); - } else if (states.contains(MaterialState.focused)) { - result = decodeIconThemeData( - value['focused'], - validate: false, - ); - } else if (states.contains(MaterialState.hovered)) { - result = decodeIconThemeData( - value['hovered'], - validate: false, - ); - } else if (states.contains(MaterialState.pressed)) { - result = decodeIconThemeData( - value['pressed'], - validate: false, - ); - } else if (states.contains(MaterialState.scrolledUnder)) { - result = decodeIconThemeData( - value['scrolledUnder'], - validate: false, - ); - } else if (states.contains(MaterialState.selected)) { - result = decodeIconThemeData( - value['selected'], - validate: false, - ); - } else { - result = decodeIconThemeData( - value['empty'], - validate: false, - ); + case 'textable': + result = WidgetStateMouseCursor.textable; + break; } + break; + case 'system': + assert(value['cursor'] is String); + _checkSupported( + 'MouseCursor.cursor', + [ + 'alias', + 'allScroll', + 'basic', + 'cell', + 'click', + 'contextMenu', + 'copy', + 'disappearing', + 'forbidden', + 'grab', + 'grabbing', + 'help', + 'move', + 'noDrop', + 'none', + 'precise', + 'progress', + 'resizeColumn', + 'resizeDown', + 'resizeDownLeft', + 'resizeDownRight', + 'resizeLeft', + 'resizeLeftRight', + 'resizeRight', + 'resizeRow', + 'resizeUp', + 'resizeUpDown', + 'resizeUpLeft', + 'resizeUpLeftDownRight', + 'resizeUpRight', + 'resizeUpRightDownLeft', + 'text', + 'verticalText', + 'wait', + 'zoomIn', + 'zoomOut', + ], + value['cursor'], + ); - return result; - }); - } - } else { - result = MaterialStateProperty.all(value); - } - } - return result; - } - - /// Decodes a [value] into a [MouseCursor] based [MaterialStateProperty]. - /// This accepts a [MouseCursor] or a [String] which will be resolved for all - /// states. - /// - /// Alternatively, if the [value] is a [Map] then this expects the following - /// format: + switch (value['cursor']) { + case 'alias': + result = SystemMouseCursors.alias; + break; + + case 'allScroll': + result = SystemMouseCursors.allScroll; + break; + + case 'basic': + result = SystemMouseCursors.basic; + break; + + case 'cell': + result = SystemMouseCursors.cell; + break; + + case 'click': + result = SystemMouseCursors.click; + break; + + case 'contextMenu': + result = SystemMouseCursors.contextMenu; + break; + + case 'copy': + result = SystemMouseCursors.copy; + break; + + case 'disappearing': + result = SystemMouseCursors.disappearing; + break; + + case 'forbidden': + result = SystemMouseCursors.forbidden; + break; + + case 'grab': + result = SystemMouseCursors.grab; + break; + + case 'grabbing': + result = SystemMouseCursors.grabbing; + break; + + case 'help': + result = SystemMouseCursors.help; + break; + + case 'move': + result = SystemMouseCursors.move; + break; + + case 'noDrop': + result = SystemMouseCursors.noDrop; + break; + + case 'none': + result = SystemMouseCursors.none; + break; + + case 'precise': + result = SystemMouseCursors.precise; + break; + + case 'progress': + result = SystemMouseCursors.progress; + break; + + case 'resizeColumn': + result = SystemMouseCursors.resizeColumn; + break; + + case 'resizeDown': + result = SystemMouseCursors.resizeDown; + break; + + case 'resizeDownLeft': + result = SystemMouseCursors.resizeDownLeft; + break; + + case 'resizeDownRight': + result = SystemMouseCursors.resizeDownRight; + break; + + case 'resizeLeft': + result = SystemMouseCursors.resizeLeft; + break; + + case 'resizeLeftRight': + result = SystemMouseCursors.resizeLeftRight; + break; + + case 'resizeRight': + result = SystemMouseCursors.resizeRight; + break; + + case 'resizeRow': + result = SystemMouseCursors.resizeRow; + break; + + case 'resizeUp': + result = SystemMouseCursors.resizeUp; + break; + + case 'resizeUpDown': + result = SystemMouseCursors.resizeUpDown; + break; + + case 'resizeUpLeft': + result = SystemMouseCursors.resizeUpLeft; + break; + + case 'resizeUpLeftDownRight': + result = SystemMouseCursors.resizeUpLeftDownRight; + break; + + case 'resizeUpRight': + result = SystemMouseCursors.resizeUpRight; + break; + + case 'resizeUpRightDownLeft': + result = SystemMouseCursors.resizeUpRightDownLeft; + break; + + case 'text': + result = SystemMouseCursors.text; + break; + + case 'verticalText': + result = SystemMouseCursors.verticalText; + break; + + case 'wait': + result = SystemMouseCursors.wait; + break; + + case 'zoomIn': + result = SystemMouseCursors.zoomIn; + break; + + case 'zoomOut': + result = SystemMouseCursors.zoomOut; + break; + } + break; + case 'uncontrolled': + result = MouseCursor.uncontrolled; + break; + } + } + } + return result; + } + + /// Decodes the given [value] to an [NavigationBarThemeData]. This expects + /// the given [value] to be of the following structure: /// /// ```json /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "" + /// "backgroundColor": "", + /// "elevation": "", + /// "height": "", + /// "iconTheme": ">", + /// "indicatorColor": "", + /// "indicatorShape": "", + /// "labelBehavior": "", + /// "labelTextStyle": ">", + /// "shadowColor": "", + /// "surfaceTintColor": "" /// } /// ``` /// /// See also: - /// * [decodeMouseCursor] - static MaterialStateProperty? - decodeMaterialStatePropertyMouseCursor( + /// * [decodeColor] + /// * [decodeWidgetStatePropertyIconThemeData] + /// * [decodeWidgetStatePropertyTextStyle] + /// * [decodeNavigationDestinationLabelBehavior] + static NavigationBarThemeData? decodeNavigationBarThemeData( dynamic value, { bool validate = true, }) { - MaterialStateProperty? result; + NavigationBarThemeData? result; - if (value is MaterialStateProperty) { + if (value is NavigationBarThemeData) { result = value; } else if (value != null) { - if (value is MouseCursor) { - result = MaterialStateProperty.all(value); - } else if (value is String) { - result = MaterialStateProperty.all(decodeMouseCursor( - value, + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/navigation_bar_theme_data', + value: value, + validate: validate, + )); + result = NavigationBarThemeData( + backgroundColor: decodeColor( + value['backgroundColor'], validate: false, - )); - } else if (value is Map) { - final testValues = [ - 'disabled', - 'dragged', - 'empty', - 'error', - 'focused', - 'hovered', - 'pressed', - 'scrolledUnder', - 'selected', - ]; + ), + elevation: JsonClass.maybeParseDouble(value['elevation']), + height: JsonClass.maybeParseDouble(value['height']), + iconTheme: decodeWidgetStatePropertyIconThemeData( + value['iconTheme'], + validate: false, + ), + indicatorColor: decodeColor( + value['indicatorColor'], + validate: false, + ), + indicatorShape: decodeShapeBorder( + value['indicatorShape'], + validate: false, + ), + labelBehavior: decodeNavigationDestinationLabelBehavior( + value['labelBehavior'], + validate: false, + ), + labelTextStyle: decodeWidgetStatePropertyTextStyle( + value['labelTextStyle'], + validate: false, + ), + shadowColor: decodeColor( + value['shadowColor'], + validate: false, + ), + surfaceTintColor: decodeColor( + value['surfaceTintColor'], + validate: false, + ), + ); + } - var isMsp = false; - for (var key in value.keys) { - if (testValues.contains(key)) { - isMsp = true; - break; - } - } + return result; + } - if (isMsp != true) { - result = MaterialStateProperty.all( - decodeMouseCursor( - value, - validate: false, - ), - ); - } else { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/material_state_property_mouse_cursor', - value: value, - validate: validate, - )); - - result = MapMaterialStateProperty.resolveWith((states) { - MouseCursor? result; - if (states.contains(MaterialState.disabled)) { - result = decodeMouseCursor( - value['disabled'], - validate: false, - ); - } else if (states.contains(MaterialState.dragged)) { - result = decodeMouseCursor( - value['dragged'], - validate: false, - ); - } else if (states.contains(MaterialState.error)) { - result = decodeMouseCursor( - value['error'], - validate: false, - ); - } else if (states.contains(MaterialState.focused)) { - result = decodeMouseCursor( - value['focused'], - validate: false, - ); - } else if (states.contains(MaterialState.hovered)) { - result = decodeMouseCursor( - value['hovered'], - validate: false, - ); - } else if (states.contains(MaterialState.pressed)) { - result = decodeMouseCursor( - value['pressed'], - validate: false, - ); - } else if (states.contains(MaterialState.scrolledUnder)) { - result = decodeMouseCursor( - value['scrolledUnder'], - validate: false, - ); - } else if (states.contains(MaterialState.selected)) { - result = decodeMouseCursor( - value['selected'], - validate: false, - ); - } else { - result = decodeMouseCursor( - value['empty'], - validate: false, - ); - } - - return result; - }); - } - } else { - result = MaterialStateProperty.all(value); - } - } - return result; - } - - /// Decodes a [value] into a [OutlinedBorder] based [MaterialStateProperty]. - /// This accepts a [OutlinedBorder] or a [String] which will be resolved for - /// all states. - /// - /// Alternatively, if the [value] is a [Map] then this expects the following - /// format: - /// - /// ```json - /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "" - /// } - /// ``` - /// - /// See also: - /// * [decodeOutlinedBorder] - static MaterialStateProperty? - decodeMaterialStatePropertyOutlinedBorder( + /// Decodes the [value] to a [NavigationDestinationLabelBehavior]. Supported + /// values are: + /// * `alwaysHide` + /// * `alwaysShow` + /// * `onlyShowSelected` + static NavigationDestinationLabelBehavior? + decodeNavigationDestinationLabelBehavior( dynamic value, { bool validate = true, }) { - MaterialStateProperty? result; + NavigationDestinationLabelBehavior? result; - if (value is MaterialStateProperty) { + if (value is NavigationDestinationLabelBehavior) { result = value; } else if (value != null) { - if (value is OutlinedBorder) { - result = MaterialStateProperty.all(value); - } else if (value is String) { - result = MaterialStateProperty.all( - decodeOutlinedBorder( - value, - validate: false, - ), - ); - } else if (value is Map) { - final testValues = [ - 'disabled', - 'dragged', - 'empty', - 'error', - 'focused', - 'hovered', - 'pressed', - 'scrolledUnder', - 'selected', - ]; - - var isMsp = false; - for (var key in value.keys) { - if (testValues.contains(key)) { - isMsp = true; - break; - } - } + _checkSupported( + 'NavigationDestinationLabelBehavior', + [ + 'alwaysHide', + 'alwaysShow', + 'onlyShowSelected', + ], + value, + ); - if (isMsp != true) { - result = MaterialStateProperty.all( - decodeOutlinedBorder( - value, - validate: false, - ), - ); - } else { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/material_state_property_outlined_border', - value: value, - validate: validate, - )); + switch (value) { + case 'alwaysHide': + result = NavigationDestinationLabelBehavior.alwaysHide; + break; - result = MapMaterialStateProperty.resolveWith((states) { - OutlinedBorder? result; - if (states.contains(MaterialState.disabled)) { - result = decodeOutlinedBorder( - value['disabled'], - validate: false, - ); - } else if (states.contains(MaterialState.dragged)) { - result = decodeOutlinedBorder( - value['dragged'], - validate: false, - ); - } else if (states.contains(MaterialState.error)) { - result = decodeOutlinedBorder( - value['error'], - validate: false, - ); - } else if (states.contains(MaterialState.focused)) { - result = decodeOutlinedBorder( - value['focused'], - validate: false, - ); - } else if (states.contains(MaterialState.hovered)) { - result = decodeOutlinedBorder( - value['hovered'], - validate: false, - ); - } else if (states.contains(MaterialState.pressed)) { - result = decodeOutlinedBorder( - value['pressed'], - validate: false, - ); - } else if (states.contains(MaterialState.scrolledUnder)) { - result = decodeOutlinedBorder( - value['scrolledUnder'], - validate: false, - ); - } else if (states.contains(MaterialState.selected)) { - result = decodeOutlinedBorder( - value['selected'], - validate: false, - ); - } else { - result = decodeOutlinedBorder( - value['empty'], - validate: false, - ); - } + case 'alwaysShow': + result = NavigationDestinationLabelBehavior.alwaysShow; + break; - return result; - }); - } - } else { - result = MaterialStateProperty.all(value); + case 'onlyShowSelected': + result = NavigationDestinationLabelBehavior.onlyShowSelected; + break; } } + return result; } - /// Decodes a [value] into a [Size] based [MaterialStateProperty]. This - /// accepts a [Size] or a [String] which will be resolved for all states. - /// - /// Alternatively, if the [value] is a [Map] then this expects the following - /// format: + /// Decodes the given [value] to an [NavigationDrawerThemeData]. This expects + /// the given [value] to be of the following structure: /// /// ```json /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "" + /// "backgroundColor": "", + /// "elevation": "", + /// "iconTheme": ">", + /// "indicatorColor": "", + /// "indicatorShape": "", + /// "indicatorSize": "", + /// "labelTextStyle": ">", + /// "shadowColor": "", + /// "surfaceTintColor": "", + /// "tileHeight": "" /// } /// ``` /// /// See also: - /// * [decodeSize] - static MaterialStateProperty? decodeMaterialStatePropertySize( + /// * [decodeColor] + /// * [decodeWidgetStatePropertyIconThemeData] + /// * [decodeShapeBorder] + static NavigationDrawerThemeData? decodeNavigationDrawerThemeData( dynamic value, { bool validate = true, }) { - MaterialStateProperty? result; + NavigationDrawerThemeData? result; - if (value is MaterialStateProperty) { + if (value is NavigationDrawerThemeData) { result = value; } else if (value != null) { - if (value is Size) { - result = MaterialStateProperty.all(value); - } else if (value is String) { - result = MaterialStateProperty.all(decodeSize( - value, - validate: false, - )); - } else if (value is Map) { - final testValues = [ - 'disabled', - 'dragged', - 'empty', - 'error', - 'focused', - 'hovered', - 'pressed', - 'scrolledUnder', - 'selected', - ]; - - var isMsp = false; - for (var key in value.keys) { - if (testValues.contains(key)) { - isMsp = true; - break; - } - } - - if (isMsp != true) { - result = MaterialStateProperty.all(decodeSize( - value, - validate: false, - )); - } else { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/material_state_property_size', - value: value, - validate: validate, - )); + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/navigation_drawer_theme_data', + value: value, + validate: validate, + )); - result = MapMaterialStateProperty.resolveWith((states) { - Size? result; - if (states.contains(MaterialState.disabled)) { - result = decodeSize( - value['disabled'], - validate: false, - ); - } else if (states.contains(MaterialState.dragged)) { - result = decodeSize( - value['dragged'], - validate: false, - ); - } else if (states.contains(MaterialState.error)) { - result = decodeSize( - value['error'], - validate: false, - ); - } else if (states.contains(MaterialState.focused)) { - result = decodeSize( - value['focused'], - validate: false, - ); - } else if (states.contains(MaterialState.hovered)) { - result = decodeSize( - value['hovered'], - validate: false, - ); - } else if (states.contains(MaterialState.pressed)) { - result = decodeSize( - value['pressed'], - validate: false, - ); - } else if (states.contains(MaterialState.scrolledUnder)) { - result = decodeSize( - value['scrolledUnder'], - validate: false, - ); - } else if (states.contains(MaterialState.selected)) { - result = decodeSize( - value['selected'], - validate: false, - ); - } else { - result = decodeSize( - value['empty'], - validate: false, - ); - } - - return result; - }); - } - } else { - result = MaterialStateProperty.all(value); - } - } - return result; - } - - /// Decodes a [value] into a [TextStyle] based [MaterialStateProperty]. This - /// accepts a [TextStyle] or a [String] which will be resolved for all states. - /// - /// Alternatively, if the [value] is a [Map] then this expects the following - /// format: - /// - /// ```json - /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "" - /// } - /// ``` - /// - /// See also: - /// * [decodeTextStyle] - static MaterialStateProperty? - decodeMaterialStatePropertyTextStyle( - dynamic value, { - bool validate = true, - }) { - MaterialStateProperty? result; - - if (value is MaterialStateProperty) { - result = value; - } else if (value != null) { - if (value is TextStyle) { - result = MaterialStateProperty.all(value); - } else if (value is String) { - result = MaterialStateProperty.all(decodeTextStyle( - value, + result = NavigationDrawerThemeData( + backgroundColor: decodeColor(value['backgroundColor'], validate: false), + elevation: JsonClass.maybeParseDouble(value['elevation']), + iconTheme: decodeWidgetStatePropertyIconThemeData( + value['iconTheme'], validate: false, - )); - } else if (value is Map) { - final testValues = [ - 'disabled', - 'dragged', - 'empty', - 'error', - 'focused', - 'hovered', - 'pressed', - 'scrolledUnder', - 'selected', - ]; - - var isMsp = false; - for (var key in value.keys) { - if (testValues.contains(key)) { - isMsp = true; - break; - } - } - - if (isMsp != true) { - result = MaterialStateProperty.all( - decodeTextStyle( - value, - validate: false, - ), - ); - } else { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/material_state_property_text_style', - value: value, - validate: validate, - )); - - result = MapMaterialStateProperty.resolveWith((states) { - TextStyle? result; - if (states.contains(MaterialState.disabled)) { - result = decodeTextStyle( - value['disabled'], - validate: false, - ); - } else if (states.contains(MaterialState.dragged)) { - result = decodeTextStyle( - value['dragged'], - validate: false, - ); - } else if (states.contains(MaterialState.error)) { - result = decodeTextStyle( - value['error'], - validate: false, - ); - } else if (states.contains(MaterialState.focused)) { - result = decodeTextStyle( - value['focused'], - validate: false, - ); - } else if (states.contains(MaterialState.hovered)) { - result = decodeTextStyle( - value['hovered'], - validate: false, - ); - } else if (states.contains(MaterialState.pressed)) { - result = decodeTextStyle( - value['pressed'], - validate: false, - ); - } else if (states.contains(MaterialState.scrolledUnder)) { - result = decodeTextStyle( - value['scrolledUnder'], - validate: false, - ); - } else if (states.contains(MaterialState.selected)) { - result = decodeTextStyle( - value['selected'], - validate: false, - ); - } else { - result = decodeTextStyle( - value['empty'], - validate: false, - ); - } - - return result; - }); - } - } else { - result = MaterialStateProperty.all(value); - } + ), + indicatorColor: decodeColor( + value['indicatorColor'], + validate: false, + ), + indicatorShape: decodeShapeBorder( + value['indicateShape'], + validate: false, + ), + indicatorSize: decodeSize( + value['size'], + validate: false, + ), + labelTextStyle: decodeWidgetStatePropertyTextStyle( + value['labelTextStyle'], + validate: false, + ), + shadowColor: decodeColor( + value['shadowColor'], + validate: false, + ), + surfaceTintColor: decodeColor( + value['surfaceTintColor'], + validate: false, + ), + tileHeight: JsonClass.maybeParseDouble(value['tileHeight']), + ); } + return result; } - /// Decodes the [value] to a [MaterialTargetTapSize]. Supported values are: - /// * `padded` - /// * `shrinkWrap` - static MaterialTapTargetSize? decodeMaterialTapTargetSize( + /// Decodes the [value] to a [NavigationRailLabelType]. Supported values are: + /// * `all` + /// * `none` + /// * `selected` + static NavigationRailLabelType? decodeNavigationRailLabelType( dynamic value, { bool validate = true, }) { - MaterialTapTargetSize? result; - if (value is MaterialTapTargetSize) { + NavigationRailLabelType? result; + if (value is NavigationRailLabelType) { result = value; } else { _checkSupported( - 'MaterialTapTargetSize', + 'NavigationRailLabelType', [ - 'padded', - 'shrinkWrap', + 'all', + 'none', + 'selected', ], value, ); if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/material_tap_target_size', + schemaId: '$_baseSchemaUrl/navigation_rail_label_type', value: value, validate: validate, )); switch (value) { - case 'padded': - result = MaterialTapTargetSize.padded; + case 'all': + result = NavigationRailLabelType.all; break; - case 'shrinkWrap': - result = MaterialTapTargetSize.shrinkWrap; + + case 'none': + result = NavigationRailLabelType.none; + break; + + case 'selected': + result = NavigationRailLabelType.selected; break; } } } + return result; } - /// Decodes the [value] to a [MaterialType]. Supported values are: - /// * `button` - /// * `canvas` - /// * `card` - /// * `circle` - /// * `transparency` - static MaterialType? decodeMaterialType( - dynamic value, { - bool validate = true, - }) { - MaterialType? result; - if (value is MaterialType) { - result = value; - } else { - _checkSupported( - 'MaterialType', - [ - 'button', - 'canvas', - 'card', - 'circle', - 'transparency', - ], - value, - ); - - if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/material_type', - value: value, - validate: validate, - )); - switch (value) { - case 'button': - result = MaterialType.button; - break; - case 'canvas': - result = MaterialType.canvas; - break; - case 'card': - result = MaterialType.card; - break; - case 'circle': - result = MaterialType.circle; - break; - case 'transparency': - result = MaterialType.transparency; - break; - } - } - } - - return result; - } - - /// Decodes the [value] to a [Matrix4]. This requires the value to be an - /// [Iterable] of [double] with exactly 16 elements in it. + /// Decodes the given [value] to an [NavigationRailThemeData]. This expects + /// the given [value] to be of the following structure: /// - /// The array is expected to be in the following format: - /// ``` - /// [ - /// x0, - /// x1, - /// x2, - /// x3, - /// y0, - /// y1, - /// y2, - /// y3, - /// z0, - /// z1, - /// z2, - /// z3, - /// w0, - /// w1, - /// w2, - /// w3 - /// ] + /// ```json + /// { + /// "backgroundColor": "", + /// "elevation": "", + /// "groupAlignment": "", + /// "indicatorColor": "", + /// "indicatorShape": "", + /// "labelType": "", + /// "minExtendedWidth": "", + /// "minWidth": "", + /// "selectedIconTheme": "", + /// "selectedLabelTextStyle": "", + /// "unselectedIconTheme": "", + /// "unselectedLabelTextStyle": "", + /// "useIndicator": "" + /// } /// ``` - static Matrix4? decodeMatrix4( + /// + /// See also: + /// * [decodeColor] + /// * [decodeIconThemeData] + /// * [decodeNavigationRailLabelType] + /// * [decodeShapeBorder] + /// * [decodeTextStyle] + static NavigationRailThemeData? decodeNavigationRailThemeData( dynamic value, { bool validate = true, }) { - Matrix4? result; + NavigationRailThemeData? result; - if (value is Matrix4) { + if (value is NavigationRailThemeData) { result = value; - } else { - if (value is Iterable) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/matrix4', - value: value, - validate: validate, - )); - final list = value.toList(); - result = Matrix4( - JsonClass.maybeParseDouble(list[0])!, - JsonClass.maybeParseDouble(list[1])!, - JsonClass.maybeParseDouble(list[2])!, - JsonClass.maybeParseDouble(list[3])!, - JsonClass.maybeParseDouble(list[4])!, - JsonClass.maybeParseDouble(list[5])!, - JsonClass.maybeParseDouble(list[6])!, - JsonClass.maybeParseDouble(list[7])!, - JsonClass.maybeParseDouble(list[8])!, - JsonClass.maybeParseDouble(list[9])!, - JsonClass.maybeParseDouble(list[10])!, - JsonClass.maybeParseDouble(list[11])!, - JsonClass.maybeParseDouble(list[12])!, - JsonClass.maybeParseDouble(list[13])!, - JsonClass.maybeParseDouble(list[14])!, - JsonClass.maybeParseDouble(list[15])!, - ); - } + } else if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/navigation_rail_theme_data', + value: value, + validate: validate, + )); + result = NavigationRailThemeData( + backgroundColor: decodeColor( + value['backgroundColor'], + validate: false, + ), + elevation: JsonClass.maybeParseDouble(value['elevation']), + groupAlignment: JsonClass.maybeParseDouble(value['groupAlignment']), + indicatorColor: decodeColor( + value['indicatorColor'], + validate: false, + ), + indicatorShape: decodeShapeBorder( + value['indicatorShape'], + validate: false, + ), + labelType: decodeNavigationRailLabelType( + value['labelType'], + validate: false, + ), + minExtendedWidth: JsonClass.maybeParseDouble(value['minExtendedWidth']), + minWidth: JsonClass.maybeParseDouble(value['minWidth']), + selectedIconTheme: decodeIconThemeData( + value['selectedIconTheme'], + validate: false, + ), + selectedLabelTextStyle: decodeTextStyle( + value['selectedLabelTextStyle'], + validate: false, + ), + unselectedIconTheme: decodeIconThemeData( + value['unselectedIconTheme'], + validate: false, + ), + unselectedLabelTextStyle: decodeTextStyle( + value['unselectedLabelTextStyle'], + validate: false, + ), + useIndicator: JsonClass.maybeParseBool(value['useIndicator']), + ); } return result; } - /// Decodes the [value] to a [MaxLengthEnforcement]. Supported values are: - /// * `enforced` - /// * `none` - /// * `truncateAfterCompositionEnds` - static MaxLengthEnforcement? decodeMaxLengthEnforcement( + /// Decodes the [value] to a [NotchedShape]. Supported values are: + /// * `circular` + static NotchedShape? decodeNotchedShape( dynamic value, { bool validate = true, }) { - MaxLengthEnforcement? result; - if (value is MaxLengthEnforcement) { + NotchedShape? result; + if (value is NotchedShape) { result = value; } else { _checkSupported( - 'MaxLengthEnforcement', + 'NotchedShape', [ - 'enforced', - 'none', - 'truncateAfterCompositionEnds', + 'circular', ], value, ); if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/max_length_enforcement', + schemaId: '$_baseSchemaUrl/notched_shape', value: value, validate: validate, )); switch (value) { - case 'enforced': - result = MaxLengthEnforcement.enforced; - break; - case 'none': - result = MaxLengthEnforcement.none; - break; - case 'truncateAfterCompositionEnds': - result = MaxLengthEnforcement.truncateAfterCompositionEnds; + case 'circular': + result = const CircularNotchedRectangle(); break; } } } - return result; } - /// Decodes the given [value] to an [MenuBarThemeData]. This expects the - /// given [value] to be of the following structure: + /// Decodes the given [value] to an [Offset]. This expects the given [value] + /// to be of the following structure: /// /// ```json /// { - /// "style": "" + /// "dx": "", + /// "dy": "" /// } /// ``` - /// - /// See also: - /// * [decodeMenuStyle] - static MenuBarThemeData? decodeMenuBarThemeData( + static Offset? decodeOffset( dynamic value, { bool validate = true, }) { - MenuBarThemeData? result; + Offset? result; - if (value is MenuBarThemeData) { + if (value is Offset) { result = value; } else if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/menu_bar_theme_data', + schemaId: '$_baseSchemaUrl/offset', value: value, validate: validate, )); - - result = MenuBarThemeData( - style: decodeMenuStyle( - value, - validate: false, - ), + result = Offset( + JsonClass.maybeParseDouble(value['dx'], 0)!, + JsonClass.maybeParseDouble(value['dy'], 0)!, ); } return result; } - /// Decodes the given [value] to an [MenuButtonThemeData]. This expects the - /// given [value] to be of the following structure: + /// Decodes the given [value] to an [OrdinalSortKey]. This expects the given + /// [value] to be of the following structure: /// /// ```json /// { - /// "style": "", + /// "name": "", + /// "order": "" /// } /// ``` - /// - /// See also: - /// * [decodeButtonStyle] - static MenuButtonThemeData? decodeMenuButtonThemeData( + static OrdinalSortKey? decodeOrdinalSortKey( dynamic value, { bool validate = true, }) { - MenuButtonThemeData? result; + OrdinalSortKey? result; - if (value is MenuButtonThemeData) { + if (value is OrdinalSortKey) { result = value; } else if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/menu_button_theme_data', + schemaId: '$_baseSchemaUrl/ordinal_sort_key', value: value, validate: validate, )); - result = MenuButtonThemeData( - style: decodeButtonStyle( - value['style'], - validate: false, - ), + result = OrdinalSortKey( + JsonClass.maybeParseDouble(value['order'])!, + name: value['name'], ); } return result; } - /// Decodes the given [value] to an [MenuStyle]. This expects the given - /// [value] to be of the following structure: + /// Decodes a given Map-like value into a [OutlinedBorder]. The value returned + /// depends on the "type" parameter. The "type" must be one of: + /// * `beveled` + /// * `circle` + /// * `rectangle` + /// * `rounded` + /// * `stadium` + /// + /// The JSON format of the [value] depends on the "type" and the associated + /// class. /// + /// `BeveledRectangleBorder` /// ```json /// { - /// "alignment": "", - /// "backgroundColor": ">", - /// "elevation": ">", - /// "fixedSize": ">", - /// "maximumSize": ">", - /// "minimumSize": ">", - /// "padding": ">", - /// "shadowColor": ">", - /// "shape": ">", - /// "side": ">", - /// "surfaceTintColor": ">", - /// "visualDensity": "", + /// "borderRadius": "", + /// "side": "", + /// "type": "beveled" /// } /// ``` /// - /// See also: - /// * [decodeAlignment] - /// * [decodeMaterialStatePropertyBorderSide] - /// * [decodeMaterialStatePropertyColor] - /// * [decodeMaterialStatePropertyDouble] - /// * [decodeMaterialStatePropertyEdgeInsetsGeometry] - /// * [decodeMaterialStatePropertyMouseCursor] - /// * [decodeMaterialStatePropertySize] - /// * [decodeVisualDensity] - static MenuStyle? decodeMenuStyle( - dynamic value, { - bool validate = true, + /// `CircleBorder` + /// ```json + /// { + /// "side": "", + /// "type": "circle" + /// } + /// ``` + /// + /// `ContinuousRectangleBorder` + /// ```json + /// { + /// "borderRadius": "", + /// "side": "", + /// "type": "rectangle" + /// } + /// ``` + /// + /// `RoundedRectangleBorder` + /// ```json + /// { + /// "borderRadius": "", + /// "side": "", + /// "type": "rounded" + /// } + /// ``` + /// + /// `StadiumBorder` + /// ```json + /// { + /// "side": "", + /// "type": "stadium" + /// } + /// + /// See also: + /// * [decodeBorderRadius] + /// * [decodeBorderSide] + static OutlinedBorder? decodeOutlinedBorder( + dynamic value, { + bool validate = true, }) { - MenuStyle? result; - - if (value is MenuStyle) { + OutlinedBorder? result; + if (value is OutlinedBorder) { result = value; - } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/menu_style', - value: value, - validate: validate, - )); - - result = MenuStyle( - alignment: decodeAlignment( - value['alignment'], - validate: false, - ), - backgroundColor: decodeMaterialStatePropertyColor( - value['backgroundColor'], - validate: false, - ), - elevation: decodeMaterialStatePropertyDouble( - value['elevation'], - validate: false, - ), - fixedSize: decodeMaterialStatePropertySize(value['fixedSize'], - validate: false), - maximumSize: decodeMaterialStatePropertySize( - value['maximumSize'], - validate: false, - ), - minimumSize: decodeMaterialStatePropertySize( - value['minimumSize'], - validate: false, - ), - mouseCursor: decodeMaterialStatePropertyMouseCursor( - value['mouseCursor'], - validate: false, - ), - padding: decodeMaterialStatePropertyEdgeInsetsGeometry( - value['padding'], - validate: false, - ), - shadowColor: decodeMaterialStatePropertyColor( - value['shadowColor'], - validate: false, - ), - shape: decodeMaterialStatePropertyOutlinedBorder( - value['shape'], - validate: false, - ), - side: decodeMaterialStatePropertyBorderSide( - value['side'], - validate: false, - ), - surfaceTintColor: decodeMaterialStatePropertyColor( - value['surfaceTintColor'], - validate: false, - ), - visualDensity: decodeVisualDensity( - value['visualDensity'], - validate: false, - ), + } else { + assert(value == null || value['type'] is String); + _checkSupported( + 'OutlinedBorder.type', + [ + 'beveled', + 'circle', + 'rectangle', + 'rounded', + 'stadium', + ], + value == null ? null : value['type'], ); + + if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/outlined_border', + value: value, + validate: validate, + )); + final String? type = value['type']; + + switch (type) { + case 'beveled': + result = BeveledRectangleBorder( + borderRadius: decodeBorderRadius( + value['borderRadius'], + validate: false, + ) ?? + BorderRadius.zero, + side: decodeBorderSide( + value['side'], + validate: false, + ) ?? + BorderSide.none, + ); + break; + + case 'circle': + result = CircleBorder( + side: decodeBorderSide( + value['side'], + validate: false, + ) ?? + BorderSide.none, + ); + break; + + case 'rectangle': + result = ContinuousRectangleBorder( + borderRadius: decodeBorderRadius( + value['borderRadius'], + validate: false, + ) ?? + BorderRadius.zero, + side: decodeBorderSide( + value['side'], + validate: false, + ) ?? + BorderSide.none, + ); + break; + + case 'rounded': + result = RoundedRectangleBorder( + borderRadius: decodeBorderRadius( + value['borderRadius'], + validate: false, + ) ?? + BorderRadius.zero, + side: decodeBorderSide( + value['side'], + validate: false, + ) ?? + BorderSide.none, + ); + break; + + case 'stadium': + result = StadiumBorder( + side: decodeBorderSide( + value['side'], + validate: false, + ) ?? + BorderSide.none, + ); + break; + } + } } return result; } - /// Decodes the given [value] to an [MenuThemeData]. This expects the given - /// [value] to be of the following structure: + /// Decodes the given [value] to an [OutlinedButtonThemeData]. This expects the + /// given [value] to be of the following structure: /// /// ```json /// { - /// "style": "" + /// "style": "" /// } /// ``` /// /// See also: - /// * [decodeMenuStyle] - static MenuThemeData? decodeMenuThemeData( + /// * [decodeButtonStyle] + static OutlinedButtonThemeData? decodeOutlinedButtonThemeData( dynamic value, { bool validate = true, }) { - MenuThemeData? result; + OutlinedButtonThemeData? result; - if (value is MenuThemeData) { + if (value is OutlinedButtonThemeData) { result = value; } else if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/menu_theme_data', + schemaId: '$_baseSchemaUrl/outlined_button_theme_data', value: value, validate: validate, )); - - result = MenuThemeData( - style: decodeMenuStyle( + result = OutlinedButtonThemeData( + style: decodeButtonStyle( value['style'], validate: false, ), @@ -8280,1205 +7780,1150 @@ class ThemeDecoder { return result; } - /// Decodes the given [value] to a [MouseCursor]. There must be a "type" - /// attribute that is one of: - /// * `defer` - /// * `material` - /// * `system` - /// * `uncontrolled` - /// - /// When the `type` is `material`, this expects a `cursor` that is one of: - /// * `clickable` - /// * `textable` - /// - /// When the `type` is `system`, this expects a `cursor` that is one of: - /// * `alias` - /// * `allScroll` - /// * `basic` - /// * `cell` - /// * `click` - /// * `contextMenu` - /// * `copy` - /// * `disappearing` - /// * `forbidden` - /// * `grab` - /// * `grabbing` - /// * `help` - /// * `move` - /// * `noDrop` - /// * `none` - /// * `precise` - /// * `progress` - /// * `resizeColumn` - /// * `resizeDown` - /// * `resizeDownLeft` - /// * `resizeDownRight` - /// * `resizeLeft` - /// * `resizeRight` - /// * `resizeRow` - /// * `resizeUp` - /// * `resizeUpDown` - /// * `resizeUpLeft` - /// * `resizeUpLeftDownRight` - /// * `resizeUpRight` - /// * `resizeUpRightDownLeft` - /// * `text` - /// * `verticalText` - /// * `wait` - /// * `zoomIn` - /// * `zoomOut` - static MouseCursor? decodeMouseCursor( + /// Decodes the [value] to a [OverflowBoxFit]. Supported values are: + /// * `deferToChild` + /// * `max` + static OverflowBoxFit? decodeOverflowBoxFit( dynamic value, { bool validate = true, }) { - MouseCursor? result; - if (value is MouseCursor) { + OverflowBoxFit? result; + + if (value is OverflowBoxFit) { result = value; - } else { - assert(value == null || value['type'] is String); + } else if (value != null) { _checkSupported( - 'MouseCursor.type', + 'OverflowBoxFit', [ - 'defer', - 'material', - 'system', - 'uncontrolled', + 'deferToChild', + 'max', ], - value == null ? null : value['type'], + value, ); + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/overflow_box_fit', + value: value, + validate: validate, + )); - if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/mouse_cursor', - value: value, - validate: validate, - )); - switch (value['type']) { - case 'defer': - result = MouseCursor.defer; - break; - case 'material': - assert(value['cursor'] is String); - _checkSupported( - 'MouseCursor.cursor', - [ - 'clickable', - 'textable', - ], - value['cursor'], - ); - switch (value['cursor']) { - case 'clickable': - result = MaterialStateMouseCursor.clickable; - break; - - case 'textable': - result = MaterialStateMouseCursor.textable; - break; - } - break; - case 'system': - assert(value['cursor'] is String); - _checkSupported( - 'MouseCursor.cursor', - [ - 'alias', - 'allScroll', - 'basic', - 'cell', - 'click', - 'contextMenu', - 'copy', - 'disappearing', - 'forbidden', - 'grab', - 'grabbing', - 'help', - 'move', - 'noDrop', - 'none', - 'precise', - 'progress', - 'resizeColumn', - 'resizeDown', - 'resizeDownLeft', - 'resizeDownRight', - 'resizeLeft', - 'resizeLeftRight', - 'resizeRight', - 'resizeRow', - 'resizeUp', - 'resizeUpDown', - 'resizeUpLeft', - 'resizeUpLeftDownRight', - 'resizeUpRight', - 'resizeUpRightDownLeft', - 'text', - 'verticalText', - 'wait', - 'zoomIn', - 'zoomOut', - ], - value['cursor'], - ); - - switch (value['cursor']) { - case 'alias': - result = SystemMouseCursors.alias; - break; - - case 'allScroll': - result = SystemMouseCursors.allScroll; - break; - - case 'basic': - result = SystemMouseCursors.basic; - break; + switch (value) { + case 'deferToChild': + result = OverflowBoxFit.deferToChild; + break; - case 'cell': - result = SystemMouseCursors.cell; - break; + case 'max': + result = OverflowBoxFit.max; + break; + } + } - case 'click': - result = SystemMouseCursors.click; - break; + return result; + } - case 'contextMenu': - result = SystemMouseCursors.contextMenu; - break; + /// Decodes the [value] to a [PageTransitionsBuilder]. Supported values are: + /// * `cupertino` + /// * `fadeUpwards` + /// * `openUpwards` + /// * `zoom` + static PageTransitionsBuilder? decodePageTransitionsBuilder( + dynamic value, { + bool validate = true, + }) { + PageTransitionsBuilder? result; - case 'copy': - result = SystemMouseCursors.copy; - break; + if (value is PageTransitionsBuilder) { + result = value; + } else if (value != null) { + _checkSupported( + 'PageTransitionsBuilder', + [ + 'cupertino', + 'fadeUpwards', + 'openUpwards', + 'zoom', + ], + value, + ); + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/page_transitions_builder', + value: value, + validate: validate, + )); - case 'disappearing': - result = SystemMouseCursors.disappearing; - break; + switch (value) { + case 'cupertino': + result = const CupertinoPageTransitionsBuilder(); + break; - case 'forbidden': - result = SystemMouseCursors.forbidden; - break; + case 'fadeUpwards': + result = const FadeUpwardsPageTransitionsBuilder(); + break; - case 'grab': - result = SystemMouseCursors.grab; - break; + case 'openUpwards': + result = const OpenUpwardsPageTransitionsBuilder(); + break; - case 'grabbing': - result = SystemMouseCursors.grabbing; - break; + case 'zoom': + result = const ZoomPageTransitionsBuilder(); + break; + } + } - case 'help': - result = SystemMouseCursors.help; - break; + return result; + } - case 'move': - result = SystemMouseCursors.move; - break; + /// Decodes the given [value] to a [PopupMenuThemeData]. This expects the + /// given [value] to be of the following structure: + /// + /// ```json + /// { + /// "builders": ">" + /// } + /// ``` + /// + /// See also: + /// * [decodePageTransitionsBuilder] + /// * [decodeTargetPlatform] + static PageTransitionsTheme? decodePageTransitionsTheme( + dynamic value, { + bool validate = true, + }) { + PageTransitionsTheme? result; - case 'noDrop': - result = SystemMouseCursors.noDrop; - break; + if (value is PageTransitionsTheme) { + result = value; + } else if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/page_transitions_theme', + value: value, + validate: validate, + )); - case 'none': - result = SystemMouseCursors.none; - break; + final builders = {}; + value['builders']?.forEach( + (key, value) => builders[decodeTargetPlatform( + key, + validate: false, + )!] = decodePageTransitionsBuilder( + value, + validate: false, + )!, + ); - case 'precise': - result = SystemMouseCursors.precise; - break; + result = PageTransitionsTheme( + builders: builders, + ); + } - case 'progress': - result = SystemMouseCursors.progress; - break; + return result; + } - case 'resizeColumn': - result = SystemMouseCursors.resizeColumn; - break; + /// Decodes the [value] to a [PanAxis]. Supported values are: + /// * `aligned` + /// * `free` + /// * `horizontal` + /// * `vertical` + static PanAxis? decodePanAxis( + dynamic value, { + bool validate = true, + }) { + PanAxis? result; - case 'resizeDown': - result = SystemMouseCursors.resizeDown; - break; - - case 'resizeDownLeft': - result = SystemMouseCursors.resizeDownLeft; - break; - - case 'resizeDownRight': - result = SystemMouseCursors.resizeDownRight; - break; - - case 'resizeLeft': - result = SystemMouseCursors.resizeLeft; - break; - - case 'resizeLeftRight': - result = SystemMouseCursors.resizeLeftRight; - break; + if (value is PanAxis) { + result = value; + } else if (value != null) { + _checkSupported( + 'PanAxis', + [ + 'aligned', + 'free', + 'horizontal', + 'vertical', + ], + value, + ); + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/pan_axis', + value: value, + validate: validate, + )); - case 'resizeRight': - result = SystemMouseCursors.resizeRight; - break; + switch (value) { + case 'aligned': + result = PanAxis.aligned; + break; - case 'resizeRow': - result = SystemMouseCursors.resizeRow; - break; + case 'free': + result = PanAxis.free; + break; - case 'resizeUp': - result = SystemMouseCursors.resizeUp; - break; + case 'horizontal': + result = PanAxis.horizontal; + break; - case 'resizeUpDown': - result = SystemMouseCursors.resizeUpDown; - break; + case 'vertical': + result = PanAxis.vertical; + break; + } + } - case 'resizeUpLeft': - result = SystemMouseCursors.resizeUpLeft; - break; + return result; + } - case 'resizeUpLeftDownRight': - result = SystemMouseCursors.resizeUpLeftDownRight; - break; + /// Decodes the [value] to a [PointerDeviceKind]. Supported values are: + /// * `invertedStylus` + /// * `mouse` + /// * `stylus` + /// * `touch` + /// * `trackpad` + /// * `unknown` + static PointerDeviceKind? decodePointerDeviceKind( + dynamic value, { + bool validate = true, + }) { + PointerDeviceKind? result; - case 'resizeUpRight': - result = SystemMouseCursors.resizeUpRight; - break; + if (value is PointerDeviceKind) { + result = value; + } else if (value != null) { + _checkSupported( + 'PointerDeviceKind', + [ + 'invertedStylus', + 'mouse', + 'stylus', + 'touch', + 'trackpad', + 'unknown', + ], + value, + ); + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/pointer_device_kind', + value: value, + validate: validate, + )); - case 'resizeUpRightDownLeft': - result = SystemMouseCursors.resizeUpRightDownLeft; - break; + switch (value) { + case 'invertedStylus': + result = PointerDeviceKind.invertedStylus; + break; + case 'mouse': + result = PointerDeviceKind.mouse; + break; + case 'stylus': + result = PointerDeviceKind.stylus; + break; + case 'touch': + result = PointerDeviceKind.touch; + break; + case 'trackpad': + result = PointerDeviceKind.trackpad; + break; + case 'unknown': + result = PointerDeviceKind.unknown; + break; + } + } - case 'text': - result = SystemMouseCursors.text; - break; + return result; + } - case 'verticalText': - result = SystemMouseCursors.verticalText; - break; + /// Decodes the [value] to a [PopupMenuPosition]. Supported values are: + /// * `over` + /// * `under` + static PopupMenuPosition? decodePopupMenuPosition( + dynamic value, { + bool validate = true, + }) { + PopupMenuPosition? result; - case 'wait': - result = SystemMouseCursors.wait; - break; + if (value is PopupMenuPosition) { + result = value; + } else if (value != null) { + _checkSupported( + 'PopupMenuPosition', + [ + 'over', + 'under', + ], + value, + ); + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/popup_menu_position', + value: value, + validate: validate, + )); - case 'zoomIn': - result = SystemMouseCursors.zoomIn; - break; + switch (value) { + case 'over': + result = PopupMenuPosition.over; + break; - case 'zoomOut': - result = SystemMouseCursors.zoomOut; - break; - } - break; - case 'uncontrolled': - result = MouseCursor.uncontrolled; - break; - } + case 'under': + result = PopupMenuPosition.under; + break; } } + return result; } - /// Decodes the given [value] to an [NavigationBarThemeData]. This expects - /// the given [value] to be of the following structure: + /// Decodes the given [value] to a [PopupMenuThemeData]. This expects the + /// given [value] to be of the following structure: /// /// ```json /// { - /// "backgroundColor": "", + /// "color": "", /// "elevation": "", - /// "height": "", - /// "iconTheme": ">", - /// "indicatorColor": "", - /// "indicatorShape": "", - /// "labelBehavior": "", - /// "labelTextStyle": ">", + /// "enableFeedback": "", + /// "iconColor": "", + /// "iconSize": "", + /// "labelTextStyle": ">", + /// "mouseCursor": ">", + /// "position": "", /// "shadowColor": "", - /// "surfaceTintColor": "" + /// "shape": "", + /// "surfaceTintColor": "", + /// "textStyle": "" /// } /// ``` /// /// See also: /// * [decodeColor] - /// * [decodeMaterialStatePropertyIconThemeData] - /// * [decodeMaterialStatePropertyTextStyle] - /// * [decodeNavigationDestinationLabelBehavior] - static NavigationBarThemeData? decodeNavigationBarThemeData( + /// * [decodeWidgetStatePropertyMouseCursor] + /// * [decodeWidgetStatePropertyTextStyle] + /// * [decodePopupMenuPosition] + /// * [decodeShapeBorder] + /// * [decodeTextStyle] + static PopupMenuThemeData? decodePopupMenuThemeData( dynamic value, { bool validate = true, }) { - NavigationBarThemeData? result; + PopupMenuThemeData? result; - if (value is NavigationBarThemeData) { + if (value is PopupMenuThemeData) { result = value; } else if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/navigation_bar_theme_data', + schemaId: '$_baseSchemaUrl/popup_menu_theme_data', value: value, validate: validate, )); - result = NavigationBarThemeData( - backgroundColor: decodeColor( - value['backgroundColor'], + result = PopupMenuThemeData( + color: decodeColor( + value['color'], validate: false, ), elevation: JsonClass.maybeParseDouble(value['elevation']), - height: JsonClass.maybeParseDouble(value['height']), - iconTheme: decodeMaterialStatePropertyIconThemeData( - value['iconTheme'], - validate: false, - ), - indicatorColor: decodeColor( - value['indicatorColor'], + enableFeedback: JsonClass.maybeParseBool(value['enableFeedback']), + iconColor: decodeColor( + value['iconColor'], validate: false, ), - indicatorShape: decodeShapeBorder( - value['indicatorShape'], + iconSize: JsonClass.maybeParseDouble(value['iconSize']), + labelTextStyle: decodeWidgetStatePropertyTextStyle( + value['labelTextStyle'], validate: false, ), - labelBehavior: decodeNavigationDestinationLabelBehavior( - value['labelBehavior'], + mouseCursor: decodeWidgetStatePropertyMouseCursor( + value['mouseCursor'], validate: false, ), - labelTextStyle: decodeMaterialStatePropertyTextStyle( - value['labelTextStyle'], + position: decodePopupMenuPosition( + value['position'], validate: false, ), shadowColor: decodeColor( value['shadowColor'], validate: false, ), + shape: decodeShapeBorder( + value['shape'], + validate: false, + ), surfaceTintColor: decodeColor( value['surfaceTintColor'], validate: false, ), + textStyle: decodeTextStyle( + value['textStyle'], + validate: false, + ), ); } return result; } - /// Decodes the [value] to a [NavigationDestinationLabelBehavior]. Supported - /// values are: - /// * `alwaysHide` - /// * `alwaysShow` - /// * `onlyShowSelected` - static NavigationDestinationLabelBehavior? - decodeNavigationDestinationLabelBehavior( - dynamic value, { - bool validate = true, - }) { - NavigationDestinationLabelBehavior? result; - - if (value is NavigationDestinationLabelBehavior) { - result = value; - } else if (value != null) { - _checkSupported( - 'NavigationDestinationLabelBehavior', - [ - 'alwaysHide', - 'alwaysShow', - 'onlyShowSelected', - ], - value, - ); - - switch (value) { - case 'alwaysHide': - result = NavigationDestinationLabelBehavior.alwaysHide; - break; - - case 'alwaysShow': - result = NavigationDestinationLabelBehavior.alwaysShow; - break; - - case 'onlyShowSelected': - result = NavigationDestinationLabelBehavior.onlyShowSelected; - break; - } - } - - return result; - } - - /// Decodes the given [value] to an [NavigationDrawerThemeData]. This expects - /// the given [value] to be of the following structure: + /// Decodes the given [value] to an [ProgressIndicatorThemeData]. This + /// expects the given [value] to follow the structure below: /// /// ```json /// { - /// "backgroundColor": "", - /// "elevation": "", - /// "iconTheme": ">", - /// "indicatorColor": "", - /// "indicatorShape": "", - /// "indicatorSize": "", - /// "labelTextStyle": ">", - /// "shadowColor": "", - /// "surfaceTintColor": "", - /// "tileHeight": "" + /// "circularTrackColor": "", + /// "color": "", + /// "linearMinHeight": "", + /// "linearTrackColor": "", + /// "refreshBackgroundColor": "" /// } /// ``` /// /// See also: /// * [decodeColor] - /// * [decodeMaterialStatePropertyIconThemeData] - /// * [decodeShapeBorder] - static NavigationDrawerThemeData? decodeNavigationDrawerThemeData( + static ProgressIndicatorThemeData? decodeProgressIndicatorThemeData( dynamic value, { bool validate = true, }) { - NavigationDrawerThemeData? result; + ProgressIndicatorThemeData? result; - if (value is NavigationDrawerThemeData) { + if (value is ProgressIndicatorThemeData) { result = value; } else if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/navigation_drawer_theme_data', + schemaId: '$_baseSchemaUrl/progress_indicator_theme_data', value: value, validate: validate, )); - result = NavigationDrawerThemeData( - backgroundColor: decodeColor(value['backgroundColor'], validate: false), - elevation: JsonClass.maybeParseDouble(value['elevation']), - iconTheme: decodeMaterialStatePropertyIconThemeData( - value['iconTheme'], - validate: false, - ), - indicatorColor: decodeColor( - value['indicatorColor'], - validate: false, - ), - indicatorShape: decodeShapeBorder( - value['indicateShape'], - validate: false, - ), - indicatorSize: decodeSize( - value['size'], + result = ProgressIndicatorThemeData( + circularTrackColor: decodeColor( + value['circularTrackColor'], validate: false, ), - labelTextStyle: decodeMaterialStatePropertyTextStyle( - value['labelTextStyle'], + color: decodeColor( + value['color'], validate: false, ), - shadowColor: decodeColor( - value['shadowColor'], + linearMinHeight: JsonClass.maybeParseDouble(value['linearMinHeight']), + linearTrackColor: decodeColor( + value['linearTrackColor'], validate: false, ), - surfaceTintColor: decodeColor( - value['surfaceTintColor'], + refreshBackgroundColor: decodeColor( + value['refreshBackgroundColor'], validate: false, ), - tileHeight: JsonClass.maybeParseDouble(value['tileHeight']), - ); - } - - return result; - } - - /// Decodes the [value] to a [NavigationRailLabelType]. Supported values are: - /// * `all` - /// * `none` - /// * `selected` - static NavigationRailLabelType? decodeNavigationRailLabelType( - dynamic value, { - bool validate = true, - }) { - NavigationRailLabelType? result; - if (value is NavigationRailLabelType) { - result = value; - } else { - _checkSupported( - 'NavigationRailLabelType', - [ - 'all', - 'none', - 'selected', - ], - value, ); - - if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/navigation_rail_label_type', - value: value, - validate: validate, - )); - switch (value) { - case 'all': - result = NavigationRailLabelType.all; - break; - - case 'none': - result = NavigationRailLabelType.none; - break; - - case 'selected': - result = NavigationRailLabelType.selected; - break; - } - } } return result; } - /// Decodes the given [value] to an [NavigationRailThemeData]. This expects - /// the given [value] to be of the following structure: + /// Decodes the given [value] to an [RadioThemeData]. This expects the given + /// [value] to follow the structure below: /// /// ```json /// { - /// "backgroundColor": "", - /// "elevation": "", - /// "groupAlignment": "", - /// "indicatorColor": "", - /// "indicatorShape": "", - /// "labelType": "", - /// "minExtendedWidth": "", - /// "minWidth": "", - /// "selectedIconTheme": "", - /// "selectedLabelTextStyle": "", - /// "unselectedIconTheme": "", - /// "unselectedLabelTextStyle": "", - /// "useIndicator": "" + /// "fillColor": ">", + /// "materialTapTargetSize": "", + /// "mouseCursor": ">", + /// "overlayColor": ">", + /// "splashRadius": "", + /// "visualDensity": "" /// } /// ``` /// /// See also: /// * [decodeColor] - /// * [decodeIconThemeData] - /// * [decodeNavigationRailLabelType] - /// * [decodeShapeBorder] - /// * [decodeTextStyle] - static NavigationRailThemeData? decodeNavigationRailThemeData( + /// * [decodeWidgetStatePropertyColor] + /// * [decodeWidgetStatePropertyMouseCursor] + /// * [decodeMaterialTapTargetSize] + /// * [decodeMouseCursor] + /// * [decodeVisualDensity] + static RadioThemeData? decodeRadioThemeData( dynamic value, { bool validate = true, }) { - NavigationRailThemeData? result; + RadioThemeData? result; - if (value is NavigationRailThemeData) { + if (value is RadioThemeData) { result = value; } else if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/navigation_rail_theme_data', + schemaId: '$_baseSchemaUrl/radio_theme_data', value: value, validate: validate, )); - result = NavigationRailThemeData( - backgroundColor: decodeColor( - value['backgroundColor'], - validate: false, - ), - elevation: JsonClass.maybeParseDouble(value['elevation']), - groupAlignment: JsonClass.maybeParseDouble(value['groupAlignment']), - indicatorColor: decodeColor( - value['indicatorColor'], - validate: false, - ), - indicatorShape: decodeShapeBorder( - value['indicatorShape'], - validate: false, - ), - labelType: decodeNavigationRailLabelType( - value['labelType'], + + result = RadioThemeData( + fillColor: decodeWidgetStatePropertyColor( + value['fillColor'], validate: false, ), - minExtendedWidth: JsonClass.maybeParseDouble(value['minExtendedWidth']), - minWidth: JsonClass.maybeParseDouble(value['minWidth']), - selectedIconTheme: decodeIconThemeData( - value['selectedIconTheme'], + materialTapTargetSize: decodeMaterialTapTargetSize( + value['materialTapTargetSize'], validate: false, ), - selectedLabelTextStyle: decodeTextStyle( - value['selectedLabelTextStyle'], + mouseCursor: decodeWidgetStatePropertyMouseCursor( + value['mouseCursor'], validate: false, ), - unselectedIconTheme: decodeIconThemeData( - value['unselectedIconTheme'], + overlayColor: decodeWidgetStatePropertyColor( + value['overlayColor'], validate: false, ), - unselectedLabelTextStyle: decodeTextStyle( - value['unselectedLabelTextStyle'], + splashRadius: JsonClass.maybeParseDouble(value['splashRadius']), + visualDensity: decodeVisualDensity( + value['visualDensity'], validate: false, ), - useIndicator: JsonClass.maybeParseBool(value['useIndicator']), ); } return result; } - /// Decodes the [value] to a [NotchedShape]. Supported values are: + /// Decodes the given [value] to a [Radius]. This can be a [String], [int], + /// [double], or an object. If this is an object, there must be a "type" + /// attribute that is one of: /// * `circular` - static NotchedShape? decodeNotchedShape( + /// * `elliptical` + /// * `zero` + /// + /// When passed in as a [String], [int], or [double] then this will use + /// [JsonClass.maybeParseDouble] to parse the number to send to [Radius.circular]. + /// + /// Otherwise, if this is an object then the structure of the other attributes + /// depends on the "type". + /// + /// Type: `circular` + /// ```json + /// { + /// "radius": "", + /// "type": "circular" + /// } + /// ``` + /// + /// Type: `elliptical` + /// ```json + /// { + /// "type": "elliptical", + /// "x": "", + /// "y": "" + /// } + /// ``` + /// + /// Type: `zero` + /// ```json + /// { + /// "type": "zero" + /// } + /// ``` + static Radius? decodeRadius( dynamic value, { bool validate = true, }) { - NotchedShape? result; - if (value is NotchedShape) { + Radius? result; + if (value is Radius) { result = value; } else { - _checkSupported( - 'NotchedShape', - [ - 'circular', - ], - value, - ); + final radius = JsonClass.maybeParseDouble(value); - if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/notched_shape', - value: value, - validate: validate, - )); - switch (value) { - case 'circular': - result = const CircularNotchedRectangle(); - break; + if (radius != null) { + result = Radius.circular(radius); + } else { + assert(value == null || value['type'] is String); + _checkSupported( + 'Radius.type', + [ + 'circular', + 'elliptical', + 'zero', + ], + value == null ? null : value['type'], + ); + + if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/radius', + value: value, + validate: validate, + )); + final String? type = value['type']; + + switch (type) { + case 'circular': + result = + Radius.circular(JsonClass.maybeParseDouble(value['radius'])!); + break; + + case 'elliptical': + result = Radius.elliptical( + JsonClass.maybeParseDouble(value['x']) ?? 0.0, + JsonClass.maybeParseDouble(value['y']) ?? 0.0, + ); + break; + + case 'zero': + result = Radius.zero; + break; + } } } } + return result; } - /// Decodes the given [value] to an [Offset]. This expects the given [value] - /// to be of the following structure: + /// Decodes the given [value] to a [RangeSliderThumbShape]. This expects a + /// "type" attribute to be one of: + /// * `round` + /// + /// The structure of the other attributes depends on the "type". /// + /// Type: `round` /// ```json /// { - /// "dx": "", - /// "dy": "" + /// "disabledThumbRadius": "", + /// "enabledThumbRadius": "", + /// "elevation": "", + /// "pressedElevation": "", + /// "type": "round" /// } /// ``` - static Offset? decodeOffset( + static RangeSliderThumbShape? decodeRangeSliderThumbShape( dynamic value, { bool validate = true, }) { - Offset? result; - - if (value is Offset) { + RangeSliderThumbShape? result; + if (value is RangeSliderThumbShape) { result = value; - } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/offset', - value: value, - validate: validate, - )); - result = Offset( - JsonClass.maybeParseDouble(value['dx'], 0)!, - JsonClass.maybeParseDouble(value['dy'], 0)!, + } else { + assert(value == null || value['type'] is String); + _checkSupported( + 'RangeSliderThumbShape.type', + [ + 'round', + ], + value == null ? null : value['type'], ); - } - - return result; - } - - /// Decodes the given [value] to an [OrdinalSortKey]. This expects the given - /// [value] to be of the following structure: - /// - /// ```json - /// { - /// "name": "", - /// "order": "" - /// } - /// ``` - static OrdinalSortKey? decodeOrdinalSortKey( - dynamic value, { - bool validate = true, - }) { - OrdinalSortKey? result; - if (value is OrdinalSortKey) { - result = value; - } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/ordinal_sort_key', - value: value, - validate: validate, - )); + if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/range_slider_thumb_shape', + value: value, + validate: validate, + )); - result = OrdinalSortKey( - JsonClass.maybeParseDouble(value['order'])!, - name: value['name'], - ); + final String? type = value['type']; + switch (type) { + case 'round': + result = RoundRangeSliderThumbShape( + disabledThumbRadius: JsonClass.maybeParseDouble( + value['disabledThumbRadius'], + ), + elevation: JsonClass.maybeParseDouble(value['elevation']) ?? 1.0, + enabledThumbRadius: JsonClass.maybeParseDouble( + value['enabledThumbRadius'], + ) ?? + 10.0, + pressedElevation: JsonClass.maybeParseDouble( + value['pressedElevation'], + ) ?? + 6.0, + ); + break; + } + } } return result; } - /// Decodes a given Map-like value into a [OutlinedBorder]. The value returned - /// depends on the "type" parameter. The "type" must be one of: - /// * `beveled` - /// * `circle` - /// * `rectangle` - /// * `rounded` - /// * `stadium` - /// - /// The JSON format of the [value] depends on the "type" and the associated - /// class. - /// - /// `BeveledRectangleBorder` - /// ```json - /// { - /// "borderRadius": "", - /// "side": "", - /// "type": "beveled" - /// } - /// ``` - /// - /// `CircleBorder` - /// ```json - /// { - /// "side": "", - /// "type": "circle" - /// } - /// ``` + /// Decodes the given [value] to a [RangeSliderTickMarkShape]. This expects + /// a "type" attribute to be one of: + /// * `round` /// - /// `ContinuousRectangleBorder` - /// ```json - /// { - /// "borderRadius": "", - /// "side": "", - /// "type": "rectangle" - /// } - /// ``` + /// The structure of the other attributes depends on the "type". /// - /// `RoundedRectangleBorder` + /// Type: `round` /// ```json /// { - /// "borderRadius": "", - /// "side": "", - /// "type": "rounded" + /// "tickMarkRadius": "", + /// "type": "round" /// } /// ``` - /// - /// `StadiumBorder` - /// ```json - /// { - /// "side": "", - /// "type": "stadium" - /// } - /// - /// See also: - /// * [decodeBorderRadius] - /// * [decodeBorderSide] - static OutlinedBorder? decodeOutlinedBorder( + static RangeSliderTickMarkShape? decodeRangeSliderTickMarkShape( dynamic value, { bool validate = true, }) { - OutlinedBorder? result; - if (value is OutlinedBorder) { + RangeSliderTickMarkShape? result; + if (value is RangeSliderTickMarkShape) { result = value; } else { assert(value == null || value['type'] is String); _checkSupported( - 'OutlinedBorder.type', + 'RangeSliderTickMarkShape.type', [ - 'beveled', - 'circle', - 'rectangle', - 'rounded', - 'stadium', + 'round', ], value == null ? null : value['type'], ); if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/outlined_border', + schemaId: '$_baseSchemaUrl/range_slider_tick_mark_shape', value: value, validate: validate, )); final String? type = value['type']; switch (type) { - case 'beveled': - result = BeveledRectangleBorder( - borderRadius: decodeBorderRadius( - value['borderRadius'], - validate: false, - ) ?? - BorderRadius.zero, - side: decodeBorderSide( - value['side'], - validate: false, - ) ?? - BorderSide.none, + case 'round': + result = RoundRangeSliderTickMarkShape( + tickMarkRadius: + JsonClass.maybeParseDouble(value['tickMarkRadius']), ); break; + } + } + } - case 'circle': - result = CircleBorder( - side: decodeBorderSide( - value['side'], - validate: false, - ) ?? - BorderSide.none, - ); - break; + return result; + } - case 'rectangle': - result = ContinuousRectangleBorder( - borderRadius: decodeBorderRadius( - value['borderRadius'], - validate: false, - ) ?? - BorderRadius.zero, - side: decodeBorderSide( - value['side'], - validate: false, - ) ?? - BorderSide.none, - ); - break; - - case 'rounded': - result = RoundedRectangleBorder( - borderRadius: decodeBorderRadius( - value['borderRadius'], - validate: false, - ) ?? - BorderRadius.zero, - side: decodeBorderSide( - value['side'], - validate: false, - ) ?? - BorderSide.none, - ); - break; - - case 'stadium': - result = StadiumBorder( - side: decodeBorderSide( - value['side'], - validate: false, - ) ?? - BorderSide.none, - ); - break; - } - } - } - - return result; - } - - /// Decodes the given [value] to an [OutlinedButtonThemeData]. This expects the - /// given [value] to be of the following structure: - /// - /// ```json - /// { - /// "style": "" - /// } - /// ``` - /// - /// See also: - /// * [decodeButtonStyle] - static OutlinedButtonThemeData? decodeOutlinedButtonThemeData( - dynamic value, { - bool validate = true, - }) { - OutlinedButtonThemeData? result; - - if (value is OutlinedButtonThemeData) { - result = value; - } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/outlined_button_theme_data', - value: value, - validate: validate, - )); - result = OutlinedButtonThemeData( - style: decodeButtonStyle( - value['style'], - validate: false, - ), - ); - } - - return result; - } - - /// Decodes the [value] to a [OverflowBoxFit]. Supported values are: - /// * `deferToChild` - /// * `max` - static OverflowBoxFit? decodeOverflowBoxFit( + /// Decodes the [value] to a [RangeSliderTrackShape]. Supported values are: + /// * `rectangular` + /// * `rounded` + static RangeSliderTrackShape? decodeRangeSliderTrackShape( dynamic value, { bool validate = true, }) { - OverflowBoxFit? result; - - if (value is OverflowBoxFit) { + RangeSliderTrackShape? result; + if (value is RangeSliderTrackShape) { result = value; - } else if (value != null) { + } else { _checkSupported( - 'OverflowBoxFit', + 'RangeSliderTrackShape', [ - 'deferToChild', - 'max', + 'rectangular', + 'rounded', ], value, ); - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/overflow_box_fit', - value: value, - validate: validate, - )); - switch (value) { - case 'deferToChild': - result = OverflowBoxFit.deferToChild; - break; + if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/range_slider_track_shape', + value: value, + validate: validate, + )); + switch (value) { + case 'rectangular': + result = const RectangularRangeSliderTrackShape(); + break; - case 'max': - result = OverflowBoxFit.max; - break; + case 'rounded': + result = const RoundedRectRangeSliderTrackShape(); + break; + } } } - return result; } - /// Decodes the [value] to a [PageTransitionsBuilder]. Supported values are: - /// * `cupertino` - /// * `fadeUpwards` - /// * `openUpwards` - /// * `zoom` - static PageTransitionsBuilder? decodePageTransitionsBuilder( + /// Decodes the [value] to a [RangeSliderValueIndicatorShape]. Supported + /// values are: + /// * `paddle` + /// * `rectangular` + static RangeSliderValueIndicatorShape? decodeRangeSliderValueIndicatorShape( dynamic value, { bool validate = true, }) { - PageTransitionsBuilder? result; - - if (value is PageTransitionsBuilder) { + RangeSliderValueIndicatorShape? result; + if (value is RangeSliderValueIndicatorShape) { result = value; - } else if (value != null) { + } else { _checkSupported( - 'PageTransitionsBuilder', + 'RangeSliderValueIndicatorShape.type', [ - 'cupertino', - 'fadeUpwards', - 'openUpwards', - 'zoom', + 'paddle', + 'rectangular', ], value, ); - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/page_transitions_builder', - value: value, - validate: validate, - )); - - switch (value) { - case 'cupertino': - result = const CupertinoPageTransitionsBuilder(); - break; - - case 'fadeUpwards': - result = const FadeUpwardsPageTransitionsBuilder(); - break; - case 'openUpwards': - result = const OpenUpwardsPageTransitionsBuilder(); - break; + if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/range_slider_value_indicator_shape', + value: value, + validate: validate, + )); + switch (value) { + case 'paddle': + result = const PaddleRangeSliderValueIndicatorShape(); + break; - case 'zoom': - result = const ZoomPageTransitionsBuilder(); - break; + case 'rectangular': + result = const RectangularRangeSliderValueIndicatorShape(); + break; + } } } return result; } - /// Decodes the given [value] to a [PopupMenuThemeData]. This expects the - /// given [value] to be of the following structure: + /// Decodes the [value] to a [Rect]. If [value] is not `null` then + /// it must contain a property named "type" with one of the following values: + /// * `center` + /// * `circle` + /// * `largest` + /// * `ltrb` + /// * `ltwh` + /// * `points` + /// * `zero` + /// + /// The structure of the remaining attributes depends on the "type" property. /// + /// Type: `center` /// ```json /// { - /// "builders": ">" + /// "center": { + /// "dx": "", + /// "dy": "" + /// }, + /// "height": "", + /// "width": "", + /// "type": "center" /// } /// ``` /// - /// See also: - /// * [decodePageTransitionsBuilder] - /// * [decodeTargetPlatform] - static PageTransitionsTheme? decodePageTransitionsTheme( - dynamic value, { - bool validate = true, - }) { - PageTransitionsTheme? result; - - if (value is PageTransitionsTheme) { - result = value; - } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/page_transitions_theme', - value: value, - validate: validate, - )); - - final builders = {}; - value['builders']?.forEach( - (key, value) => builders[decodeTargetPlatform( - key, - validate: false, - )!] = decodePageTransitionsBuilder( - value, - validate: false, - )!, - ); - - result = PageTransitionsTheme( - builders: builders, - ); - } - - return result; - } - - /// Decodes the [value] to a [PanAxis]. Supported values are: - /// * `aligned` - /// * `free` - /// * `horizontal` - /// * `vertical` - static PanAxis? decodePanAxis( - dynamic value, { + /// Type: `circle` + /// ```json + /// { + /// "center": { + /// "dx": "", + /// "dy": "" + /// }, + /// "radius": "", + /// "type": "circle" + /// } + /// ``` + /// + /// Type: `largest` + /// ```json + /// { + /// "type": "largest" + /// } + /// ``` + /// + /// Type: `ltrb` + /// ```json + /// { + /// "bottom": "", + /// "left": "", + /// "right": "", + /// "top": "", + /// "type": "ltrb" + /// } + /// ``` + /// + /// Type: `ltwh` + /// ```json + /// { + /// "height": "", + /// "left": "", + /// "top": "", + /// "type": "ltwh", + /// "width": "" + /// } + /// ``` + /// + /// Type: `points` + /// ```json + /// { + /// "a": { + /// "dx": "", + /// "dy": "" + /// }, + /// "b": { + /// "dx": "", + /// "dy": "" + /// } + /// "type": "points" + /// } + /// ``` + /// + /// Type: `zero` + /// ```json + /// { + /// "type": "zero" + /// } + /// ``` + /// + /// See also: + /// * [decodeOffset] + static Rect? decodeRect( + dynamic value, { bool validate = true, }) { - PanAxis? result; - - if (value is PanAxis) { + Rect? result; + if (value is Rect) { result = value; - } else if (value != null) { + } else { + assert(value == null || value['type'] is String); _checkSupported( - 'PanAxis', + 'Rect.type', [ - 'aligned', - 'free', - 'horizontal', - 'vertical', + 'center', + 'circle', + 'largest', + 'ltrb', + 'ltwh', + 'points', + 'zero', ], - value, + value == null ? null : value['type'], ); - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/pan_axis', - value: value, - validate: validate, - )); - switch (value) { - case 'aligned': - result = PanAxis.aligned; - break; + if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/rect', + value: value, + validate: validate, + )); + final String? type = value['type']; + switch (type) { + case 'center': + result = Rect.fromCenter( + center: decodeOffset( + value['center'], + validate: false, + )!, + height: JsonClass.maybeParseDouble(value['height'])!, + width: JsonClass.maybeParseDouble(value['width'])!, + ); + break; - case 'free': - result = PanAxis.free; - break; + case 'circle': + result = Rect.fromCircle( + center: decodeOffset( + value['center'], + validate: false, + )!, + radius: JsonClass.maybeParseDouble(value['radius'])!, + ); + break; - case 'horizontal': - result = PanAxis.horizontal; - break; + case 'largest': + result = Rect.largest; + break; - case 'vertical': - result = PanAxis.vertical; - break; + case 'ltrb': + result = Rect.fromLTRB( + JsonClass.maybeParseDouble(value['left'])!, + JsonClass.maybeParseDouble(value['top'])!, + JsonClass.maybeParseDouble(value['right'])!, + JsonClass.maybeParseDouble(value['bottom'])!, + ); + break; + + case 'ltwh': + result = Rect.fromLTWH( + JsonClass.maybeParseDouble(value['left'])!, + JsonClass.maybeParseDouble(value['top'])!, + JsonClass.maybeParseDouble(value['width'])!, + JsonClass.maybeParseDouble(value['height'])!, + ); + break; + + case 'points': + result = Rect.fromPoints( + decodeOffset( + value['a'], + validate: false, + )!, + decodeOffset( + value['b'], + validate: false, + )!, + ); + break; + + case 'zero': + result = Rect.zero; + break; + } } } return result; } - /// Decodes the [value] to a [PointerDeviceKind]. Supported values are: - /// * `invertedStylus` - /// * `mouse` - /// * `stylus` - /// * `touch` - /// * `trackpad` - /// * `unknown` - static PointerDeviceKind? decodePointerDeviceKind( + /// Decodes the given [value] to an [ScrollBehavior]. This expects the given + /// [value] to follow the structure below: + /// + /// ```json + /// { + /// } + /// ``` + static ScrollBehavior? decodeScrollBehavior( dynamic value, { bool validate = true, }) { - PointerDeviceKind? result; + ScrollBehavior? result; - if (value is PointerDeviceKind) { + if (value is ScrollBehavior) { result = value; } else if (value != null) { - _checkSupported( - 'PointerDeviceKind', - [ - 'invertedStylus', - 'mouse', - 'stylus', - 'touch', - 'trackpad', - 'unknown', - ], - value, - ); assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/pointer_device_kind', + schemaId: '$_baseSchemaUrl/scroll_behavior', value: value, validate: validate, )); - - switch (value) { - case 'invertedStylus': - result = PointerDeviceKind.invertedStylus; - break; - case 'mouse': - result = PointerDeviceKind.mouse; - break; - case 'stylus': - result = PointerDeviceKind.stylus; - break; - case 'touch': - result = PointerDeviceKind.touch; - break; - case 'trackpad': - result = PointerDeviceKind.trackpad; - break; - case 'unknown': - result = PointerDeviceKind.unknown; - break; - } + result = const ScrollBehavior(); } return result; } - /// Decodes the [value] to a [PopupMenuPosition]. Supported values are: - /// * `over` - /// * `under` - static PopupMenuPosition? decodePopupMenuPosition( + /// Decodes the [value] to a [ScrollPhysics]. If [value] is not `null` then + /// it must contain a property named "type" with one of the following values: + /// * `always` + /// * `bouncing` + /// * `clamping` + /// * `fixedExtent` + /// * `never` + /// * `page` + /// * `rangeMaintaining` + /// + /// This expects the JSON representation to follow the structure: + /// ```json + /// { + /// "parent": "", + /// "type": "" + /// } + /// ``` + static ScrollPhysics? decodeScrollPhysics( dynamic value, { bool validate = true, }) { - PopupMenuPosition? result; - - if (value is PopupMenuPosition) { + ScrollPhysics? result; + if (value is ScrollPhysics) { result = value; - } else if (value != null) { + } else { + assert(value == null || value['type'] is String); _checkSupported( - 'PopupMenuPosition', + 'ScrollPhysics.type', [ - 'over', - 'under', + 'always', + 'bouncing', + 'clamping', + 'fixedExtent', + 'never', + 'page', + 'rangeMaintaining', ], - value, + value == null ? null : value['type'], ); + + if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/scroll_physics', + value: value, + validate: validate, + )); + final type = value['type']; + + switch (type) { + case 'always': + result = AlwaysScrollableScrollPhysics( + parent: decodeScrollPhysics( + value['parent'], + validate: false, + ), + ); + break; + + case 'bouncing': + result = BouncingScrollPhysics( + parent: decodeScrollPhysics( + value['parent'], + validate: false, + ), + ); + break; + + case 'clamping': + result = ClampingScrollPhysics( + parent: decodeScrollPhysics( + value['parent'], + validate: false, + ), + ); + break; + + case 'fixedExtent': + result = FixedExtentScrollPhysics( + parent: decodeScrollPhysics( + value['parent'], + validate: false, + ), + ); + break; + + case 'never': + result = NeverScrollableScrollPhysics( + parent: decodeScrollPhysics( + value['parent'], + validate: false, + ), + ); + break; + + case 'page': + result = PageScrollPhysics( + parent: decodeScrollPhysics( + value['parent'], + validate: false, + ), + ); + break; + + case 'rangeMaintaining': + result = RangeMaintainingScrollPhysics( + parent: decodeScrollPhysics( + value['parent'], + validate: false, + ), + ); + break; + } + } + } + + return result; + } + + /// Decodes the [value] to a [ScrollViewKeyboardDismissBehavior]. Supported + /// values are: + /// * `manual` + /// * `onDrag` + static ScrollViewKeyboardDismissBehavior? + decodeScrollViewKeyboardDismissBehavior( + dynamic value, { + bool validate = true, + }) { + ScrollViewKeyboardDismissBehavior? result; + + if (value is ScrollViewKeyboardDismissBehavior) { + result = value; + } else if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/popup_menu_position', + schemaId: '$_baseSchemaUrl/scroll_view_keyboard_dismiss_behavior', value: value, validate: validate, )); switch (value) { - case 'over': - result = PopupMenuPosition.over; + case 'manual': + result = ScrollViewKeyboardDismissBehavior.manual; break; - case 'under': - result = PopupMenuPosition.under; + case 'onDrag': + result = ScrollViewKeyboardDismissBehavior.onDrag; break; } } @@ -9486,85 +8931,117 @@ class ThemeDecoder { return result; } - /// Decodes the given [value] to a [PopupMenuThemeData]. This expects the - /// given [value] to be of the following structure: + /// Decodes the [value] to a [ScrollbarOrientation]. Supported values are: + /// * `bottom` + /// * `left` + /// * `right` + /// * `top` + static ScrollbarOrientation? decodeScrollbarOrientation( + dynamic value, { + bool validate = true, + }) { + ScrollbarOrientation? result; + + if (value is ScrollbarOrientation) { + result = value; + } else if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/scrollbar_orientation', + value: value, + validate: validate, + )); + switch (value) { + case 'bottom': + result = ScrollbarOrientation.bottom; + break; + + case 'left': + result = ScrollbarOrientation.left; + break; + + case 'right': + result = ScrollbarOrientation.right; + break; + + case 'top': + result = ScrollbarOrientation.top; + break; + } + } + + return result; + } + + /// Decodes the given [value] to an [ScrollbarThemeData]. This expects the given + /// [value] to follow the structure below: /// /// ```json /// { - /// "color": "", - /// "elevation": "", - /// "enableFeedback": "", - /// "iconColor": "", - /// "iconSize": "", - /// "labelTextStyle": ">", - /// "mouseCursor": ">", - /// "position": "", - /// "shadowColor": "", - /// "shape": "", - /// "surfaceTintColor": "", - /// "textStyle": "" + /// "crossAxisMargin": "", + /// "interactive": "", + /// "mainAxisMargin": "", + /// "minThumbLength": "", + /// "radius": "", + /// "thickness": ">", + /// "thumbColor": ">", + /// "thumbVisibility": ">", + /// "trackBorderColor": ">", + /// "trackColor": ">", + /// "trackVisibility": ">", /// } /// ``` /// /// See also: - /// * [decodeColor] - /// * [decodeMaterialStatePropertyMouseCursor] - /// * [decodeMaterialStatePropertyTextStyle] - /// * [decodePopupMenuPosition] - /// * [decodeShapeBorder] - /// * [decodeTextStyle] - static PopupMenuThemeData? decodePopupMenuThemeData( + /// * [decodeWidgetStatePropertyBool] + /// * [decodeWidgetStatePropertyColor] + /// * [decodeWidgetStatePropertyDouble] + /// * [decodeRadius] + static ScrollbarThemeData? decodeScrollbarThemeData( dynamic value, { bool validate = true, }) { - PopupMenuThemeData? result; + ScrollbarThemeData? result; - if (value is PopupMenuThemeData) { + if (value is ScrollbarThemeData) { result = value; } else if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/popup_menu_theme_data', + schemaId: '$_baseSchemaUrl/scrollbar_theme_data', value: value, validate: validate, )); - result = PopupMenuThemeData( - color: decodeColor( - value['color'], - validate: false, - ), - elevation: JsonClass.maybeParseDouble(value['elevation']), - enableFeedback: JsonClass.maybeParseBool(value['enableFeedback']), - iconColor: decodeColor( - value['iconColor'], - validate: false, - ), - iconSize: JsonClass.maybeParseDouble(value['iconSize']), - labelTextStyle: decodeMaterialStatePropertyTextStyle( - value['labelTextStyle'], + result = ScrollbarThemeData( + crossAxisMargin: JsonClass.maybeParseDouble(value['crossAxisMargin']), + interactive: JsonClass.maybeParseBool(value['interactive']), + mainAxisMargin: JsonClass.maybeParseDouble(value['mainAxisMargin']), + minThumbLength: JsonClass.maybeParseDouble(value['minThumbLength']), + radius: decodeRadius( + value['radius'], validate: false, ), - mouseCursor: decodeMaterialStatePropertyMouseCursor( - value['mouseCursor'], + // showTrackOnHover: @deprecated + thickness: decodeWidgetStatePropertyDouble( + value['thickness'], validate: false, ), - position: decodePopupMenuPosition( - value['position'], + thumbColor: decodeWidgetStatePropertyColor( + value['thumbColor'], validate: false, ), - shadowColor: decodeColor( - value['shadowColor'], + thumbVisibility: decodeWidgetStatePropertyBool( + value['thumbVisibility'], validate: false, ), - shape: decodeShapeBorder( - value['shape'], + trackBorderColor: decodeWidgetStatePropertyColor( + value['trackBorderColor'], validate: false, ), - surfaceTintColor: decodeColor( - value['surfaceTintColor'], + trackColor: decodeWidgetStatePropertyColor( + value['trackColor'], validate: false, ), - textStyle: decodeTextStyle( - value['textStyle'], + trackVisibility: decodeWidgetStatePropertyBool( + value['trackVisibility'], validate: false, ), ); @@ -9573,52 +9050,97 @@ class ThemeDecoder { return result; } - /// Decodes the given [value] to an [ProgressIndicatorThemeData]. This - /// expects the given [value] to follow the structure below: + /// Decodes the given [value] to an [SearchBarThemeData]. This expects the given + /// [value] to follow the structure below: /// /// ```json /// { - /// "circularTrackColor": "", - /// "color": "", - /// "linearMinHeight": "", - /// "linearTrackColor": "", - /// "refreshBackgroundColor": "" + /// "backgroundColor": ">", + /// "constraints": "", + /// "elevation": ">", + /// "hintStyle": ">", + /// "overlayColor": ">", + /// "padding": ">", + /// "shadowColor": ">", + /// "shape": WidgetStateProperty, + /// "side": ">", + /// "surfaceTintColor": ">", + /// "textStyle": ">", + /// "textCapitalization": "" /// } /// ``` /// /// See also: - /// * [decodeColor] - static ProgressIndicatorThemeData? decodeProgressIndicatorThemeData( + /// * [decodeBoxConstraints] + /// * [decodeWidgetStatePropertyBorderSide] + /// * [decodeWidgetStatePropertyColor] + /// * [decodeWidgetStatePropertyDouble] + /// * [decodeWidgetStatePropertyEdgeInsetsGeometry] + /// * [decodeWidgetStatePropertyOutlinedBorder] + /// * [decodeWidgetStatePropertyTextStyle] + /// * [decodeTextCapitalization] + static SearchBarThemeData? decodeSearchBarThemeData( dynamic value, { bool validate = true, }) { - ProgressIndicatorThemeData? result; + SearchBarThemeData? result; - if (value is ProgressIndicatorThemeData) { + if (value is SearchBarThemeData) { result = value; } else if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/progress_indicator_theme_data', + schemaId: '$_baseSchemaUrl/search_bar_theme_data', value: value, validate: validate, )); - result = ProgressIndicatorThemeData( - circularTrackColor: decodeColor( - value['circularTrackColor'], - validate: false, + result = SearchBarThemeData( + backgroundColor: decodeWidgetStatePropertyColor( + value['backgroundColor'], + validate: false, ), - color: decodeColor( - value['color'], + constraints: decodeBoxConstraints( + value['constraints'], validate: false, ), - linearMinHeight: JsonClass.maybeParseDouble(value['linearMinHeight']), - linearTrackColor: decodeColor( - value['linearTrackColor'], + elevation: decodeWidgetStatePropertyDouble( + value['elevation'], validate: false, ), - refreshBackgroundColor: decodeColor( - value['refreshBackgroundColor'], + hintStyle: decodeWidgetStatePropertyTextStyle( + value['hintStyle'], + validate: false, + ), + overlayColor: decodeWidgetStatePropertyColor( + value['overlayColor'], + validate: false, + ), + padding: decodeWidgetStatePropertyEdgeInsetsGeometry( + value['padding'], + validate: false, + ), + shadowColor: decodeWidgetStatePropertyColor( + value['shadowColor'], + validate: false, + ), + shape: decodeWidgetStatePropertyOutlinedBorder( + value['shape'], + validate: false, + ), + side: decodeWidgetStatePropertyBorderSide( + value['side'], + validate: false, + ), + surfaceTintColor: decodeWidgetStatePropertyColor( + value['surfaceTintColor'], + validate: false, + ), + textCapitalization: decodeTextCapitalization( + value['textCapitalization'], + validate: false, + ), + textStyle: decodeWidgetStatePropertyTextStyle( + value['textStyle'], validate: false, ), ); @@ -9627,62 +9149,76 @@ class ThemeDecoder { return result; } - /// Decodes the given [value] to an [RadioThemeData]. This expects the given - /// [value] to follow the structure below: + /// Decodes the given [value] to an [SearchViewThemeData]. This expects the + /// given [value] to follow the structure below: /// /// ```json /// { - /// "fillColor": ">", - /// "materialTapTargetSize": "", - /// "mouseCursor": ">", - /// "overlayColor": ">", - /// "splashRadius": "", - /// "visualDensity": "" + /// "backgroundColor": "", + /// "constraints": "", + /// "dividerColor": "", + /// "elevation": "", + /// "headerHintStyle": "", + /// "headerTextStyle": "", + /// "shape": "", + /// "side": "", + /// "surfaceTintColor": "" /// } /// ``` /// /// See also: + /// * [decodeBorderSide] + /// * [decodeBoxConstraints] /// * [decodeColor] - /// * [decodeMaterialStatePropertyColor] - /// * [decodeMaterialStatePropertyMouseCursor] - /// * [decodeMaterialTapTargetSize] - /// * [decodeMouseCursor] - /// * [decodeVisualDensity] - static RadioThemeData? decodeRadioThemeData( + /// * [decodeOutlinedBorder] + /// * [decodeTextStyle] + static SearchViewThemeData? decodeSearchViewThemeData( dynamic value, { bool validate = true, }) { - RadioThemeData? result; + SearchViewThemeData? result; - if (value is RadioThemeData) { + if (value is SearchViewThemeData) { result = value; } else if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/radio_theme_data', + schemaId: '$_baseSchemaUrl/search_view_theme_data', value: value, validate: validate, )); - result = RadioThemeData( - fillColor: decodeMaterialStatePropertyColor( - value['fillColor'], + result = SearchViewThemeData( + backgroundColor: decodeColor( + value['backgroundColor'], validate: false, ), - materialTapTargetSize: decodeMaterialTapTargetSize( - value['materialTapTargetSize'], + constraints: decodeBoxConstraints( + value['constraints'], validate: false, ), - mouseCursor: decodeMaterialStatePropertyMouseCursor( - value['mouseCursor'], + dividerColor: decodeColor( + value['dividerColor'], validate: false, ), - overlayColor: decodeMaterialStatePropertyColor( - value['overlayColor'], + elevation: JsonClass.maybeParseDouble(value['elevation']), + headerHintStyle: decodeTextStyle( + value['headerHintStyle'], validate: false, ), - splashRadius: JsonClass.maybeParseDouble(value['splashRadius']), - visualDensity: decodeVisualDensity( - value['visualDensity'], + headerTextStyle: decodeTextStyle( + value['headerTextStyle'], + validate: false, + ), + shape: decodeOutlinedBorder( + value['shape'], + validate: false, + ), + side: decodeBorderSide( + value['side'], + validate: false, + ), + surfaceTintColor: decodeColor( + value['surfaceTintColor'], validate: false, ), ); @@ -9691,206 +9227,244 @@ class ThemeDecoder { return result; } - /// Decodes the given [value] to a [Radius]. This can be a [String], [int], - /// [double], or an object. If this is an object, there must be a "type" - /// attribute that is one of: - /// * `circular` - /// * `elliptical` - /// * `zero` - /// - /// When passed in as a [String], [int], or [double] then this will use - /// [JsonClass.maybeParseDouble] to parse the number to send to [Radius.circular]. - /// - /// Otherwise, if this is an object then the structure of the other attributes - /// depends on the "type". + /// Decodes the given [value] to an [SegmentedButtonThemeData]. This expects + /// the given [value] to follow the structure below: /// - /// Type: `circular` /// ```json /// { - /// "radius": "", - /// "type": "circular" + /// "selectedIcon": "", + /// "style": "" /// } /// ``` /// - /// Type: `elliptical` - /// ```json - /// { - /// "type": "elliptical", - /// "x": "", - /// "y": "" - /// } - /// ``` + /// See also: + /// * [decodeButtonStyle] + /// * [decodeIcon] + static SegmentedButtonThemeData? decodeSegmentedButtonThemeData( + dynamic value, { + validate = true, + }) { + SegmentedButtonThemeData? result; + + if (value is SegmentedButtonThemeData) { + result = value; + } else if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/segmented_button_theme_data', + value: value, + validate: validate, + )); + + result = SegmentedButtonThemeData( + selectedIcon: decodeIcon( + value['selectedIcon'], + validate: false, + ), + style: decodeButtonStyle( + value['style'], + validate: false, + ), + ); + } + + return result; + } + + /// Decodes the given [value] to an [SemanticsTag]. This expects the given + /// [value] to be of the following structure: /// - /// Type: `zero` /// ```json /// { - /// "type": "zero" + /// "name": "" /// } /// ``` - static Radius? decodeRadius( + static SemanticsTag? decodeSemanticsTag( dynamic value, { bool validate = true, }) { - Radius? result; - if (value is Radius) { - result = value; - } else { - final radius = JsonClass.maybeParseDouble(value); - - if (radius != null) { - result = Radius.circular(radius); - } else { - assert(value == null || value['type'] is String); - _checkSupported( - 'Radius.type', - [ - 'circular', - 'elliptical', - 'zero', - ], - value == null ? null : value['type'], - ); - - if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/radius', - value: value, - validate: validate, - )); - final String? type = value['type']; - - switch (type) { - case 'circular': - result = - Radius.circular(JsonClass.maybeParseDouble(value['radius'])!); - break; + SemanticsTag? result; - case 'elliptical': - result = Radius.elliptical( - JsonClass.maybeParseDouble(value['x']) ?? 0.0, - JsonClass.maybeParseDouble(value['y']) ?? 0.0, - ); - break; + if (value is SemanticsTag) { + result = value; + } else if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/semantics_tag', + value: value, + validate: validate, + )); - case 'zero': - result = Radius.zero; - break; - } - } - } + result = SemanticsTag(value['name']); } return result; } - /// Decodes the given [value] to a [RangeSliderThumbShape]. This expects a - /// "type" attribute to be one of: - /// * `round` - /// - /// The structure of the other attributes depends on the "type". + /// Decodes the given [value] to a [Shadow]. This expects the [value] to have + /// the following structure: /// - /// Type: `round` /// ```json /// { - /// "disabledThumbRadius": "", - /// "enabledThumbRadius": "", - /// "elevation": "", - /// "pressedElevation": "", - /// "type": "round" + /// "blurRadius": "", + /// "color": "", + /// "offset": "" /// } /// ``` - static RangeSliderThumbShape? decodeRangeSliderThumbShape( + /// + /// See also: + /// * [decodeColor] + /// * [decodeOffset] + static Shadow? decodeShadow( dynamic value, { bool validate = true, }) { - RangeSliderThumbShape? result; - if (value is RangeSliderThumbShape) { + Shadow? result; + + if (value is Shadow) { result = value; - } else { - assert(value == null || value['type'] is String); - _checkSupported( - 'RangeSliderThumbShape.type', - [ - 'round', - ], - value == null ? null : value['type'], + } else if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/shadow', + value: value, + validate: validate, + )); + result = Shadow( + blurRadius: JsonClass.maybeParseDouble(value['blurRadius'], 0.0)!, + color: decodeColor( + value['color'], + validate: false, + )!, + offset: decodeOffset( + value['offset'], + validate: false, + )!, ); - - if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/range_slider_thumb_shape', - value: value, - validate: validate, - )); - - final String? type = value['type']; - switch (type) { - case 'round': - result = RoundRangeSliderThumbShape( - disabledThumbRadius: JsonClass.maybeParseDouble( - value['disabledThumbRadius'], - ), - elevation: JsonClass.maybeParseDouble(value['elevation']) ?? 1.0, - enabledThumbRadius: JsonClass.maybeParseDouble( - value['enabledThumbRadius'], - ) ?? - 10.0, - pressedElevation: JsonClass.maybeParseDouble( - value['pressedElevation'], - ) ?? - 6.0, - ); - break; - } - } } return result; } - /// Decodes the given [value] to a [RangeSliderTickMarkShape]. This expects - /// a "type" attribute to be one of: - /// * `round` + /// Decodes a given Map-like value into a [ShapeBorder]. The value returned + /// depends on the "type" parameter. The "type" must be one of: + /// * `circle` + /// * `rectangle` + /// * `rounded` /// - /// The structure of the other attributes depends on the "type". + /// The JSON format of the [value] depends on the "type" and the associated + /// class. /// - /// Type: `round` + /// `CircleBorder` /// ```json /// { - /// "tickMarkRadius": "", - /// "type": "round" + /// "side": "", + /// "type": "circle" /// } /// ``` - static RangeSliderTickMarkShape? decodeRangeSliderTickMarkShape( + /// + /// `ContinuousRectangleBorder` + /// ```json + /// { + /// "borderRadius": "", + /// "side": "", + /// "type": "rectangle" + /// } + /// ``` + /// + /// `RoundedRectangleBorder` + /// ```json + /// { + /// "borderRadius": "", + /// "side": "", + /// "type": "rounded" + /// } + /// ``` + /// + /// `StadiumBorder` + /// ```json + /// { + /// "side": "", + /// "type": "stadium" + /// } + /// ``` + /// + /// See also: + /// * [decodeBorderRadius] + /// * [decodeBorderSide] + static ShapeBorder? decodeShapeBorder( dynamic value, { bool validate = true, }) { - RangeSliderTickMarkShape? result; - if (value is RangeSliderTickMarkShape) { + ShapeBorder? result; + if (value is ShapeBorder) { result = value; } else { assert(value == null || value['type'] is String); _checkSupported( - 'RangeSliderTickMarkShape.type', + 'ShapeBorder.type', [ - 'round', + 'circle', + 'rectangle', + 'rounded', + 'stadium', ], value == null ? null : value['type'], ); if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/range_slider_tick_mark_shape', + schemaId: '$_baseSchemaUrl/shape_border', value: value, validate: validate, )); final String? type = value['type']; switch (type) { - case 'round': - result = RoundRangeSliderTickMarkShape( - tickMarkRadius: - JsonClass.maybeParseDouble(value['tickMarkRadius']), + case 'circle': + result = CircleBorder( + side: decodeBorderSide( + value['side'], + validate: false, + ) ?? + BorderSide.none, + ); + break; + + case 'rectangle': + result = ContinuousRectangleBorder( + borderRadius: decodeBorderRadius( + value['borderRadius'], + validate: false, + ) ?? + BorderRadius.zero, + side: decodeBorderSide( + value['side'], + validate: false, + ) ?? + BorderSide.none, + ); + break; + + case 'rounded': + result = RoundedRectangleBorder( + borderRadius: decodeBorderRadius( + value['borderRadius'], + validate: false, + ) ?? + BorderRadius.zero, + side: decodeBorderSide( + value['side'], + validate: false, + ) ?? + BorderSide.none, + ); + break; + + case 'stadium': + result = StadiumBorder( + side: decodeBorderSide( + value['side'], + validate: false, + ) ?? + BorderSide.none, ); break; } @@ -9900,39 +9474,51 @@ class ThemeDecoder { return result; } - /// Decodes the [value] to a [RangeSliderTrackShape]. Supported values are: - /// * `rectangular` - /// * `rounded` - static RangeSliderTrackShape? decodeRangeSliderTrackShape( + /// Decodes the [value] to a [ShowValueIndicator]. Supported values are: + /// * `always` + /// * `never` + /// * `onlyForContinuous` + /// * `onlyForDiscrete` + static ShowValueIndicator? decodeShowValueIndicator( dynamic value, { bool validate = true, }) { - RangeSliderTrackShape? result; - if (value is RangeSliderTrackShape) { + ShowValueIndicator? result; + if (value is ShowValueIndicator) { result = value; } else { _checkSupported( - 'RangeSliderTrackShape', + 'ShowValueIndicator', [ - 'rectangular', - 'rounded', + 'always', + 'never', + 'onlyForContinuous', + 'onlyForDiscrete', ], value, ); if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/range_slider_track_shape', + schemaId: '$_baseSchemaUrl/show_value_indicator', value: value, validate: validate, )); switch (value) { - case 'rectangular': - result = const RectangularRangeSliderTrackShape(); + case 'always': + result = ShowValueIndicator.always; break; - case 'rounded': - result = const RoundedRectRangeSliderTrackShape(); + case 'never': + result = ShowValueIndicator.never; + break; + + case 'onlyForContinuous': + result = ShowValueIndicator.onlyForContinuous; + break; + + case 'onlyForDiscrete': + result = ShowValueIndicator.onlyForDiscrete; break; } } @@ -9940,40 +9526,71 @@ class ThemeDecoder { return result; } - /// Decodes the [value] to a [RangeSliderValueIndicatorShape]. Supported - /// values are: - /// * `paddle` - /// * `rectangular` - static RangeSliderValueIndicatorShape? decodeRangeSliderValueIndicatorShape( + /// Decodes the given [value] to a [Size]. This expects the + /// [value] to have the following structure: + /// + /// ```json + /// { + /// "height": "", + /// "width": "" + /// } + /// ``` + static Size? decodeSize( dynamic value, { bool validate = true, }) { - RangeSliderValueIndicatorShape? result; - if (value is RangeSliderValueIndicatorShape) { + Size? result; + + if (value is Size) { + result = value; + } else if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/size', + value: value, + validate: validate, + )); + result = Size( + JsonClass.maybeParseDouble(value['width'])!, + JsonClass.maybeParseDouble(value['height'])!, + ); + } + + return result; + } + + /// Decodes the [value] to a [SliderComponentShape]. Supported values are: + /// * `noOverlay` + /// * `noThumb` + static SliderComponentShape? decodeSliderComponentShape( + dynamic value, { + bool validate = true, + }) { + SliderComponentShape? result; + if (value is SliderComponentShape) { result = value; } else { _checkSupported( - 'RangeSliderValueIndicatorShape.type', + 'SliderComponentShape', [ - 'paddle', - 'rectangular', + 'noOverlay', + 'noThumb', ], value, ); if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/range_slider_value_indicator_shape', + schemaId: '$_baseSchemaUrl/slider_component_shape', value: value, validate: validate, )); switch (value) { - case 'paddle': - result = const PaddleRangeSliderValueIndicatorShape(); + case 'noOverlay': + result = SliderComponentShape.noOverlay; break; - case 'rectangular': - result = const RectangularRangeSliderValueIndicatorShape(); + case 'noThumb': + result = SliderComponentShape.noThumb; break; } } @@ -9982,185 +9599,48 @@ class ThemeDecoder { return result; } - /// Decodes the [value] to a [Rect]. If [value] is not `null` then - /// it must contain a property named "type" with one of the following values: - /// * `center` - /// * `circle` - /// * `largest` - /// * `ltrb` - /// * `ltwh` - /// * `points` - /// * `zero` - /// - /// The structure of the remaining attributes depends on the "type" property. - /// - /// Type: `center` - /// ```json - /// { - /// "center": { - /// "dx": "", - /// "dy": "" - /// }, - /// "height": "", - /// "width": "", - /// "type": "center" - /// } - /// ``` - /// - /// Type: `circle` - /// ```json - /// { - /// "center": { - /// "dx": "", - /// "dy": "" - /// }, - /// "radius": "", - /// "type": "circle" - /// } - /// ``` - /// - /// Type: `largest` - /// ```json - /// { - /// "type": "largest" - /// } - /// ``` - /// - /// Type: `ltrb` - /// ```json - /// { - /// "bottom": "", - /// "left": "", - /// "right": "", - /// "top": "", - /// "type": "ltrb" - /// } - /// ``` - /// - /// Type: `ltwh` - /// ```json - /// { - /// "height": "", - /// "left": "", - /// "top": "", - /// "type": "ltwh", - /// "width": "" - /// } - /// ``` - /// - /// Type: `points` - /// ```json - /// { - /// "a": { - /// "dx": "", - /// "dy": "" - /// }, - /// "b": { - /// "dx": "", - /// "dy": "" - /// } - /// "type": "points" - /// } - /// ``` - /// - /// Type: `zero` - /// ```json - /// { - /// "type": "zero" - /// } - /// ``` - /// - /// See also: - /// * [decodeOffset] - static Rect? decodeRect( + /// Decodes the [value] to a [SliderComponentShape]. Supported values are: + /// * `slideOnly` + /// * `slideThumb` + /// * `tapAndSlide`` + /// * `tapOnly` + static SliderInteraction? decodeSliderInteraction( dynamic value, { - bool validate = true, + bool validate = false, }) { - Rect? result; - if (value is Rect) { + SliderInteraction? result; + if (value is SliderInteraction) { result = value; } else { - assert(value == null || value['type'] is String); _checkSupported( - 'Rect.type', + 'SliderInteraction', [ - 'center', - 'circle', - 'largest', - 'ltrb', - 'ltwh', - 'points', - 'zero', + 'slideOnly', + 'slideThumb', + 'tapAndSlide', + 'tapOnly', ], - value == null ? null : value['type'], + value, ); if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/rect', + schemaId: '$_baseSchemaUrl/slider_interaction', value: value, validate: validate, )); - final String? type = value['type']; - switch (type) { - case 'center': - result = Rect.fromCenter( - center: decodeOffset( - value['center'], - validate: false, - )!, - height: JsonClass.maybeParseDouble(value['height'])!, - width: JsonClass.maybeParseDouble(value['width'])!, - ); - break; - - case 'circle': - result = Rect.fromCircle( - center: decodeOffset( - value['center'], - validate: false, - )!, - radius: JsonClass.maybeParseDouble(value['radius'])!, - ); - break; - - case 'largest': - result = Rect.largest; - break; - - case 'ltrb': - result = Rect.fromLTRB( - JsonClass.maybeParseDouble(value['left'])!, - JsonClass.maybeParseDouble(value['top'])!, - JsonClass.maybeParseDouble(value['right'])!, - JsonClass.maybeParseDouble(value['bottom'])!, - ); + switch (value) { + case 'slideOnly': + result = SliderInteraction.slideOnly; break; - - case 'ltwh': - result = Rect.fromLTWH( - JsonClass.maybeParseDouble(value['left'])!, - JsonClass.maybeParseDouble(value['top'])!, - JsonClass.maybeParseDouble(value['width'])!, - JsonClass.maybeParseDouble(value['height'])!, - ); + case 'slideThumb': + result = SliderInteraction.slideThumb; break; - - case 'points': - result = Rect.fromPoints( - decodeOffset( - value['a'], - validate: false, - )!, - decodeOffset( - value['b'], - validate: false, - )!, - ); + case 'tapAndSlide': + result = SliderInteraction.tapAndSlide; break; - - case 'zero': - result = Rect.zero; + case 'tapOnly': + result = SliderInteraction.tapOnly; break; } } @@ -10169,143 +9649,319 @@ class ThemeDecoder { return result; } - /// Decodes the given [value] to an [ScrollBehavior]. This expects the given - /// [value] to follow the structure below: + /// Decodes the given [value] to a [SliderThemeData]. This expects the + /// [value] to have the following structure: /// /// ```json /// { + /// "activeTickMarkColor": "", + /// "activeTrackColor": "", + /// "allowedInteraction": "", + /// "disabledActiveTickMarkColor": "", + /// "disabledActiveTrackColor": "", + /// "disabledInactiveTickMarkColor": "", + /// "disabledInactiveTrackColor": "", + /// "disabledSecondaryActiveTrackColor": "", + /// "disabledThumbColor": "", + /// "inactiveTickMarkColor": "", + /// "inactiveTrackColor": "", + /// "minThumbSeparation": "", + /// "mouseCursor": ">", + /// "overlappingShapeStrokeColor": "", + /// "overlayColor": "", + /// "overlayShape": "", + /// "rangeThumbShape": "", + /// "rangeTickMarkShape": "", + /// "rangeTrackShape": "", + /// "rangeValueIndicatorShape": "", + /// "secondaryActiveTrackColor": "", + /// "showValueIndicator": "", + /// "thumbColor": "", + /// "thumbShape": "", + /// "tickMarkShape": "", + /// "trackHeight": "", + /// "trackShape": "", + /// "valueIndicatorColor": "", + /// "valueIndicatorShape": "", + /// "valueIndicatorTextStyle": "" /// } /// ``` - static ScrollBehavior? decodeScrollBehavior( + /// + /// See also: + /// * [decodeColor] + /// * [decodeWidgetStatePropertyMouseCursor] + /// * [decodeShowValueIndicator] + /// * [decodeSliderComponentShape] + /// * [decodeSliderInteraction] + /// * [decodeSliderTickMarkShape] + /// * [decodeRangeSliderThumbShape] + /// * [decodeRangeSliderTickMarkShape] + /// * [decodeRangeSliderTrackShape] + /// * [decodeRangeSliderValueIndicatorShape] + static SliderThemeData? decodeSliderThemeData( dynamic value, { bool validate = true, }) { - ScrollBehavior? result; + SliderThemeData? result; - if (value is ScrollBehavior) { + if (value is SliderThemeData) { result = value; } else if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/scroll_behavior', + schemaId: '$_baseSchemaUrl/slider_theme_data', value: value, validate: validate, )); - result = const ScrollBehavior(); - } - - return result; - } - - /// Decodes the [value] to a [ScrollPhysics]. If [value] is not `null` then - /// it must contain a property named "type" with one of the following values: - /// * `always` - /// * `bouncing` - /// * `clamping` - /// * `fixedExtent` - /// * `never` - /// * `page` - /// * `rangeMaintaining` + result = SliderThemeData( + activeTickMarkColor: decodeColor( + value['activeTickMarkColor'], + validate: false, + ), + activeTrackColor: decodeColor( + value['activeTrackColor'], + validate: false, + ), + allowedInteraction: decodeSliderInteraction( + value['allowedInteraction'], + validate: false, + ), + disabledActiveTickMarkColor: decodeColor( + value['disabledActiveTickMarkColor'], + validate: false, + ), + disabledActiveTrackColor: decodeColor( + value['disabledActiveTrackColor'], + validate: false, + ), + disabledInactiveTickMarkColor: decodeColor( + value['disabledInactiveTickMarkColor'], + validate: false, + ), + disabledInactiveTrackColor: decodeColor( + value['disabledInactiveTrackColor'], + validate: false, + ), + disabledSecondaryActiveTrackColor: decodeColor( + value['disabledSecondaryActiveTrackColor'], + validate: false, + ), + disabledThumbColor: decodeColor( + value['disabledThumbColor'], + validate: false, + ), + inactiveTickMarkColor: decodeColor( + value['inactiveTickMarkColor'], + validate: false, + ), + inactiveTrackColor: decodeColor( + value['inactiveTrackColor'], + validate: false, + ), + minThumbSeparation: + JsonClass.maybeParseDouble(value['minThumbSeparation']), + mouseCursor: decodeWidgetStatePropertyMouseCursor( + value['mouseCursor'], + validate: false, + ), + overlappingShapeStrokeColor: decodeColor( + value['overlappingShapeStrokeColor'], + validate: false, + ), + overlayColor: decodeColor( + value['overlayColor'], + validate: false, + ), + overlayShape: decodeSliderComponentShape( + value['overlayShape'], + validate: false, + ), + rangeThumbShape: decodeRangeSliderThumbShape( + value['rangeThumbShape'], + validate: false, + ), + rangeTickMarkShape: decodeRangeSliderTickMarkShape( + value['rangeTickMarkShape'], + validate: false, + ), + rangeTrackShape: decodeRangeSliderTrackShape( + value['rangeTrackShape'], + validate: false, + ), + rangeValueIndicatorShape: decodeRangeSliderValueIndicatorShape( + value['rangeValueIndicatorShape'], + validate: false, + ), + secondaryActiveTrackColor: decodeColor( + value['secondaryActiveTrackColor'], + validate: false, + ), + showValueIndicator: decodeShowValueIndicator( + value['showValueIndicator'], + validate: false, + ), + thumbColor: decodeColor( + value['thumbColor'], + validate: false, + ), + // thumbSelector: @unencodable + thumbShape: decodeSliderComponentShape( + value['thumbShape'], + validate: false, + ), + tickMarkShape: decodeSliderTickMarkShape( + value['tickMarkShape'], + validate: false, + ), + trackHeight: JsonClass.maybeParseDouble(value['trackHeight']), + trackShape: decodeSliderTrackShape( + value['trackShape'], + validate: false, + ), + valueIndicatorColor: decodeColor( + value['valueIndicatorColor'], + validate: false, + ), + valueIndicatorShape: decodeSliderComponentShape( + value['valueIndicatorShape'], + validate: false, + ), + valueIndicatorTextStyle: decodeTextStyle( + value['valueIndicatorTextStyle'], + validate: false, + ), + ); + } + + return result; + } + + /// Decodes the [value] to a [SliderTickMarkShape]. Supported values are: + /// * `noTickMark` + static SliderTickMarkShape? decodeSliderTickMarkShape( + dynamic value, { + bool validate = true, + }) { + SliderTickMarkShape? result; + if (value is SliderTickMarkShape) { + result = value; + } else { + _checkSupported( + 'SliderTickMarkShape', + [ + 'noTickMark', + ], + value, + ); + + if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/slider_tick_mark_shape', + value: value, + validate: validate, + )); + switch (value) { + case 'noTickMark': + result = SliderTickMarkShape.noTickMark; + break; + } + } + } + return result; + } + + /// Decodes the given [value] to a [SliderTrackShape]. This expects the + /// [value] to have an attribute named "type" that is one of the following + /// values: + /// * `rectangular` + /// * `rounded` /// - /// This expects the JSON representation to follow the structure: + /// The schema for the rest of the attributes depends on the "type". + /// + /// Type: `rectangular` /// ```json /// { - /// "parent": "", - /// "type": "" + /// "type": "rectangular" /// } /// ``` - static ScrollPhysics? decodeScrollPhysics( + /// + /// Type: `rounded` + /// ```json + /// { + /// "type": "rounded" + /// } + /// ``` + static SliderTrackShape? decodeSliderTrackShape( dynamic value, { bool validate = true, }) { - ScrollPhysics? result; - if (value is ScrollPhysics) { + SliderTrackShape? result; + if (value is SliderTrackShape) { result = value; } else { assert(value == null || value['type'] is String); _checkSupported( - 'ScrollPhysics.type', + 'type', [ - 'always', - 'bouncing', - 'clamping', - 'fixedExtent', - 'never', - 'page', - 'rangeMaintaining', + 'rectangular', + 'rounded', ], value == null ? null : value['type'], ); if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/scroll_physics', + schemaId: '$_baseSchemaUrl/slider_track_shape', value: value, validate: validate, )); - final type = value['type']; - + final String? type = value['type']; switch (type) { - case 'always': - result = AlwaysScrollableScrollPhysics( - parent: decodeScrollPhysics( - value['parent'], - validate: false, - ), - ); - break; - - case 'bouncing': - result = BouncingScrollPhysics( - parent: decodeScrollPhysics( - value['parent'], - validate: false, - ), - ); - break; - - case 'clamping': - result = ClampingScrollPhysics( - parent: decodeScrollPhysics( - value['parent'], - validate: false, - ), - ); + case 'rectangular': + result = const RectangularSliderTrackShape(); break; - case 'fixedExtent': - result = FixedExtentScrollPhysics( - parent: decodeScrollPhysics( - value['parent'], - validate: false, - ), - ); + case 'rounded': + result = const RoundedRectSliderTrackShape(); break; + } + } + } - case 'never': - result = NeverScrollableScrollPhysics( - parent: decodeScrollPhysics( - value['parent'], - validate: false, - ), - ); - break; + return result; + } - case 'page': - result = PageScrollPhysics( - parent: decodeScrollPhysics( - value['parent'], - validate: false, - ), - ); - break; + /// Decodes a [value] to a [SmartDashesType]. Supported values are: + /// * `disabled` + /// * `enabled` + static SmartDashesType? decodeSmartDashesType( + dynamic value, { + bool validate = true, + }) { + SmartDashesType? result; + if (value is SmartDashesType) { + result = value; + } else { + _checkSupported( + 'SmartDashesType', + [ + 'disabled', + 'enabled', + ], + value, + ); - case 'rangeMaintaining': - result = RangeMaintainingScrollPhysics( - parent: decodeScrollPhysics( - value['parent'], - validate: false, - ), - ); + if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/smart_dashes_type', + value: value, + validate: validate, + )); + switch (value) { + case 'disabled': + result = SmartDashesType.disabled; + break; + case 'enabled': + result = SmartDashesType.enabled; break; } } @@ -10314,371 +9970,354 @@ class ThemeDecoder { return result; } - /// Decodes the [value] to a [ScrollViewKeyboardDismissBehavior]. Supported - /// values are: - /// * `manual` - /// * `onDrag` - static ScrollViewKeyboardDismissBehavior? - decodeScrollViewKeyboardDismissBehavior( + /// Decodes a [value] to a [SmartQuotesType]. Supported values are: + /// * `disabled` + /// * `enabled` + static SmartQuotesType? decodeSmartQuotesType( dynamic value, { bool validate = true, }) { - ScrollViewKeyboardDismissBehavior? result; - - if (value is ScrollViewKeyboardDismissBehavior) { + SmartQuotesType? result; + if (value is SmartQuotesType) { result = value; - } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/scroll_view_keyboard_dismiss_behavior', - value: value, - validate: validate, - )); - - switch (value) { - case 'manual': - result = ScrollViewKeyboardDismissBehavior.manual; - break; + } else { + _checkSupported( + 'SmartQuotesType', + [ + 'disabled', + 'enabled', + ], + value, + ); - case 'onDrag': - result = ScrollViewKeyboardDismissBehavior.onDrag; - break; + if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/smart_quotes_type', + value: value, + validate: validate, + )); + switch (value) { + case 'disabled': + result = SmartQuotesType.disabled; + break; + case 'enabled': + result = SmartQuotesType.enabled; + break; + } } } return result; } - /// Decodes the [value] to a [ScrollbarOrientation]. Supported values are: - /// * `bottom` - /// * `left` - /// * `right` - /// * `top` - static ScrollbarOrientation? decodeScrollbarOrientation( + /// Decodes a [value] to a [SnackBarBehavior]. Supported values are: + /// * `fixed` + /// * `floating` + static SnackBarBehavior? decodeSnackBarBehavior( dynamic value, { bool validate = true, }) { - ScrollbarOrientation? result; - - if (value is ScrollbarOrientation) { + SnackBarBehavior? result; + if (value is SnackBarBehavior) { result = value; - } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/scrollbar_orientation', - value: value, - validate: validate, - )); - switch (value) { - case 'bottom': - result = ScrollbarOrientation.bottom; - break; - - case 'left': - result = ScrollbarOrientation.left; - break; + } else { + _checkSupported( + 'SnackBarBehavior', + [ + 'fixed', + 'floating', + ], + value, + ); - case 'right': - result = ScrollbarOrientation.right; - break; + if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/snack_bar_behavior', + value: value, + validate: validate, + )); + switch (value) { + case 'fixed': + result = SnackBarBehavior.fixed; + break; - case 'top': - result = ScrollbarOrientation.top; - break; + case 'floating': + result = SnackBarBehavior.floating; + break; + } } } return result; } - /// Decodes the given [value] to an [ScrollbarThemeData]. This expects the given - /// [value] to follow the structure below: + /// Decodes the given [value] to a [SnackBarThemeData]. This expects the + /// [value] to have the following structure: /// /// ```json /// { - /// "crossAxisMargin": "", - /// "interactive": "", - /// "mainAxisMargin": "", - /// "minThumbLength": "", - /// "radius": "", - /// "thickness": ">", - /// "thumbColor": ">", - /// "thumbVisibility": ">", - /// "trackBorderColor": ">", - /// "trackColor": ">", - /// "trackVisibility": ">", + /// "actionBackgroundColor": "", + /// "actionOverflowThreshold": "", + /// "actionTextColor": "", + /// "backgroundColor": "", + /// "behavior": "", + /// "closeIconColor": "", + /// "contentTextStyle": "", + /// "disabledActionBackgroundColor": "", + /// "disabledActionTextColor": "", + /// "elevation": "", + /// "insetPadding": "", + /// "shape": "", + /// "showCloseIcon": "", + /// "width": "" /// } /// ``` /// /// See also: - /// * [decodeMaterialStatePropertyBool] - /// * [decodeMaterialStatePropertyColor] - /// * [decodeMaterialStatePropertyDouble] - /// * [decodeRadius] - static ScrollbarThemeData? decodeScrollbarThemeData( + /// * [decodeColor] + /// * [decodeEdgeInsets] + /// * [decodeSnackBarBehavior] + /// * [decodeShapeBorder] + /// * [decodeTextStyle] + static SnackBarThemeData? decodeSnackBarThemeData( dynamic value, { bool validate = true, }) { - ScrollbarThemeData? result; + SnackBarThemeData? result; - if (value is ScrollbarThemeData) { + if (value is SnackBarThemeData) { result = value; } else if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/scrollbar_theme_data', + schemaId: '$_baseSchemaUrl/snack_bar_theme_data', value: value, validate: validate, )); - result = ScrollbarThemeData( - crossAxisMargin: JsonClass.maybeParseDouble(value['crossAxisMargin']), - interactive: JsonClass.maybeParseBool(value['interactive']), - mainAxisMargin: JsonClass.maybeParseDouble(value['mainAxisMargin']), - minThumbLength: JsonClass.maybeParseDouble(value['minThumbLength']), - radius: decodeRadius( - value['radius'], + result = SnackBarThemeData( + actionBackgroundColor: decodeColor( + value['actionBackgroundColor'], validate: false, ), - // showTrackOnHover: @deprecated - thickness: decodeMaterialStatePropertyDouble( - value['thickness'], + actionOverflowThreshold: JsonClass.maybeParseDouble( + value['actionOverflowThreshold'], + ), + actionTextColor: decodeColor( + value['actionTextColor'], validate: false, ), - thumbColor: decodeMaterialStatePropertyColor( - value['thumbColor'], + backgroundColor: decodeColor( + value['backgroundColor'], validate: false, ), - thumbVisibility: decodeMaterialStatePropertyBool( - value['thumbVisibility'], + behavior: decodeSnackBarBehavior( + value['behavior'], validate: false, ), - trackBorderColor: decodeMaterialStatePropertyColor( - value['trackBorderColor'], + closeIconColor: decodeColor( + value['closeIconColor'], validate: false, ), - trackColor: decodeMaterialStatePropertyColor( - value['trackColor'], + contentTextStyle: decodeTextStyle( + value['contentTextStyle'], validate: false, ), - trackVisibility: decodeMaterialStatePropertyBool( - value['trackVisibility'], + disabledActionBackgroundColor: decodeColor( + value['disabledActionBackgroundColor'], + validate: false, + ), + disabledActionTextColor: decodeColor( + value['disabledActionTextColor'], + validate: false, + ), + elevation: JsonClass.maybeParseDouble(value['elevation']), + insetPadding: decodeEdgeInsets( + value['insetPadding'], + validate: false, + ), + shape: decodeShapeBorder( + value['shape'], validate: false, ), + showCloseIcon: JsonClass.maybeParseBool(value['showCloseIcon']), + width: JsonClass.maybeParseDouble(value['width']), ); } return result; } - /// Decodes the given [value] to an [SearchBarThemeData]. This expects the given - /// [value] to follow the structure below: - /// - /// ```json - /// { - /// "backgroundColor": ">", - /// "constraints": "", - /// "elevation": ">", - /// "hintStyle": ">", - /// "overlayColor": ">", - /// "padding": ">", - /// "shadowColor": ">", - /// "shape": MaterialStateProperty, - /// "side": ">", - /// "surfaceTintColor": ">", - /// "textStyle": ">", - /// "textCapitalization": "" - /// } - /// ``` - /// - /// See also: - /// * [decodeBoxConstraints] - /// * [decodeMaterialStatePropertyBorderSide] - /// * [decodeMaterialStatePropertyColor] - /// * [decodeMaterialStatePropertyDouble] - /// * [decodeMaterialStatePropertyEdgeInsetsGeometry] - /// * [decodeMaterialStatePropertyOutlinedBorder] - /// * [decodeMaterialStatePropertyTextStyle] - /// * [decodeTextCapitalization] - static SearchBarThemeData? decodeSearchBarThemeData( + /// Decodes a [value] to a [StackFit]. Supported values are: + /// * `expand` + /// * `loose` + /// * `passthrough` + static StackFit? decodeStackFit( dynamic value, { bool validate = true, }) { - SearchBarThemeData? result; + StackFit? result; - if (value is SearchBarThemeData) { + if (value is StackFit) { result = value; } else if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/search_bar_theme_data', + schemaId: '$_baseSchemaUrl/stack_fit', value: value, validate: validate, )); + switch (value) { + case 'expand': + result = StackFit.expand; + break; - result = SearchBarThemeData( - backgroundColor: decodeMaterialStatePropertyColor( - value['backgroundColor'], - validate: false, - ), - constraints: decodeBoxConstraints( - value['constraints'], - validate: false, - ), - elevation: decodeMaterialStatePropertyDouble( - value['elevation'], - validate: false, - ), - hintStyle: decodeMaterialStatePropertyTextStyle( - value['hintStyle'], - validate: false, - ), - overlayColor: decodeMaterialStatePropertyColor( - value['overlayColor'], - validate: false, - ), - padding: decodeMaterialStatePropertyEdgeInsetsGeometry( - value['padding'], - validate: false, - ), - shadowColor: decodeMaterialStatePropertyColor( - value['shadowColor'], - validate: false, - ), - shape: decodeMaterialStatePropertyOutlinedBorder( - value['shape'], - validate: false, - ), - side: decodeMaterialStatePropertyBorderSide( - value['side'], - validate: false, - ), - surfaceTintColor: decodeMaterialStatePropertyColor( - value['surfaceTintColor'], - validate: false, - ), - textCapitalization: decodeTextCapitalization( - value['textCapitalization'], - validate: false, - ), - textStyle: decodeMaterialStatePropertyTextStyle( - value['textStyle'], - validate: false, - ), - ); + case 'loose': + result = StackFit.loose; + break; + + case 'passthrough': + result = StackFit.passthrough; + break; + } } return result; } - /// Decodes the given [value] to an [SearchViewThemeData]. This expects the - /// given [value] to follow the structure below: + /// Decodes the given [value] into a [StrutStyle]. If the value is `null` + /// then `null` will be returned. Otherwise, this expects a Map like value + /// that in JSON would look like: /// /// ```json /// { - /// "backgroundColor": "", - /// "constraints": "", - /// "dividerColor": "", - /// "elevation": "", - /// "headerHintStyle": "", - /// "headerTextStyle": "", - /// "shape": "", - /// "side": "", - /// "surfaceTintColor": "" + /// "fontFamily": "", + /// "fontFamilyFallback": "", + /// "fontSize": "", + /// "fontStyle": "", + /// "fontWeight": "" + /// "forceStrutHeight": "", + /// "height": "", + /// "leading": "", + /// "leadingDistribution": "", + /// "package": "" /// } /// ``` /// /// See also: - /// * [decodeBorderSide] - /// * [decodeBoxConstraints] - /// * [decodeColor] - /// * [decodeOutlinedBorder] - /// * [decodeTextStyle] - static SearchViewThemeData? decodeSearchViewThemeData( + /// * [decodeFontStyle] + /// * [decodeFontWeight] + /// * [decodeTextLeadingDistribution] + static StrutStyle? decodeStrutStyle( dynamic value, { bool validate = true, }) { - SearchViewThemeData? result; + StrutStyle? result; - if (value is SearchViewThemeData) { + if (value is StrutStyle) { result = value; } else if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/search_view_theme_data', + schemaId: '$_baseSchemaUrl/strut_style', value: value, validate: validate, )); - - result = SearchViewThemeData( - backgroundColor: decodeColor( - value['backgroundColor'], - validate: false, - ), - constraints: decodeBoxConstraints( - value['constraints'], - validate: false, - ), - dividerColor: decodeColor( - value['dividerColor'], - validate: false, - ), - elevation: JsonClass.maybeParseDouble(value['elevation']), - headerHintStyle: decodeTextStyle( - value['headerHintStyle'], - validate: false, - ), - headerTextStyle: decodeTextStyle( - value['headerTextStyle'], - validate: false, + result = StrutStyle( + fontFamily: value['fontFamily'], + fontFamilyFallback: _decodeStringList( + value['fontFamilyFallback'], + (value) => value, ), - shape: decodeOutlinedBorder( - value['shape'], + fontSize: JsonClass.maybeParseDouble(value['fontSize']), + fontStyle: decodeFontStyle( + value['fontStyle'], validate: false, ), - side: decodeBorderSide( - value['side'], + fontWeight: decodeFontWeight( + value['fontWeight'], validate: false, ), - surfaceTintColor: decodeColor( - value['surfaceTintColor'], + forceStrutHeight: JsonClass.maybeParseBool(value['forceStrutHeight']), + height: JsonClass.maybeParseDouble(value['height']), + leading: JsonClass.maybeParseDouble(value['leading']), + leadingDistribution: decodeTextLeadingDistribution( + value['leadingDistribution'], validate: false, ), + package: value['package'], ); } return result; } - /// Decodes the given [value] to an [SegmentedButtonThemeData]. This expects - /// the given [value] to follow the structure below: + /// Decodes the given [value] to an [SwitchThemeData]. This expects the given + /// [value] to follow the structure below: /// /// ```json /// { - /// "selectedIcon": "", - /// "style": "" + /// "materialTapTargetSize": "", + /// "mouseCursor": ">", + /// "overlayColor": ">", + /// "splashRadius": "", + /// "thumbColor": ">", + /// "trackColor": ">", + /// "trackOutlineColor": ">" + /// "trackOutlineWidth": ">" /// } /// ``` /// /// See also: - /// * [decodeButtonStyle] - /// * [decodeIcon] - static SegmentedButtonThemeData? decodeSegmentedButtonThemeData( + /// * [decodeColor] + /// * [decodeWidgetStatePropertyColor] + /// * [decodeWidgetStatePropertyDouble] + /// * [decodeWidgetStatePropertyMouseCursor] + /// * [decodeMaterialTapTargetSize] + /// * [decodeMouseCursor] + static SwitchThemeData? decodeSwitchThemeData( dynamic value, { - validate = true, + bool validate = true, }) { - SegmentedButtonThemeData? result; + SwitchThemeData? result; - if (value is SegmentedButtonThemeData) { + if (value is SwitchThemeData) { result = value; } else if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/segmented_button_theme_data', + schemaId: '$_baseSchemaUrl/switch_theme_data', value: value, validate: validate, )); - result = SegmentedButtonThemeData( - selectedIcon: decodeIcon( - value['selectedIcon'], + result = SwitchThemeData( + materialTapTargetSize: decodeMaterialTapTargetSize( + value['materialTapTargetSize'], validate: false, ), - style: decodeButtonStyle( - value['style'], + mouseCursor: decodeWidgetStatePropertyMouseCursor( + value['mouseCursor'], + validate: false, + ), + overlayColor: decodeWidgetStatePropertyColor( + value['overlayColor'], + validate: false, + ), + splashRadius: JsonClass.maybeParseDouble(value['splashRadius']), + thumbColor: decodeWidgetStatePropertyColor( + value['thumbColor'], + validate: false, + ), + thumbIcon: decodeWidgetStatePropertyIcon( + value['thumbIcon'], + validate: false, + ), + trackColor: decodeWidgetStatePropertyColor( + value['trackColor'], + validate: false, + ), + trackOutlineColor: decodeWidgetStatePropertyColor( + value['trackOutlineColor'], + validate: false, + ), + trackOutlineWidth: decodeWidgetStatePropertyDouble( + value['trackOutlineWidth'], validate: false, ), ); @@ -10687,202 +10326,78 @@ class ThemeDecoder { return result; } - /// Decodes the given [value] to an [SemanticsTag]. This expects the given - /// [value] to be of the following structure: - /// - /// ```json - /// { - /// "name": "" - /// } - /// ``` - static SemanticsTag? decodeSemanticsTag( + /// Decodes a [value] to a [SystemUiOverlayStyle]. Supported values are: + /// * `dark` + /// * `light` + static SystemUiOverlayStyle? decodeSystemUiOverlayStyle( dynamic value, { bool validate = true, }) { - SemanticsTag? result; - - if (value is SemanticsTag) { + SystemUiOverlayStyle? result; + if (value is SystemUiOverlayStyle) { result = value; - } else if (value != null) { + } else if (value is Map) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/semantics_tag', + schemaId: '$_baseSchemaUrl/system_ui_overlay_style', value: value, validate: validate, )); - result = SemanticsTag(value['name']); - } - - return result; - } - - /// Decodes the given [value] to a [Shadow]. This expects the [value] to have - /// the following structure: - /// - /// ```json - /// { - /// "blurRadius": "", - /// "color": "", - /// "offset": "" - /// } - /// ``` - /// - /// See also: - /// * [decodeColor] - /// * [decodeOffset] - static Shadow? decodeShadow( - dynamic value, { - bool validate = true, - }) { - Shadow? result; - - if (value is Shadow) { - result = value; - } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/shadow', - value: value, - validate: validate, - )); - result = Shadow( - blurRadius: JsonClass.maybeParseDouble(value['blurRadius'], 0.0)!, - color: decodeColor( - value['color'], + result = SystemUiOverlayStyle( + statusBarBrightness: decodeBrightness( + value['statusBarBrightness'], validate: false, - )!, - offset: decodeOffset( - value['offset'], + ), + statusBarColor: decodeColor( + value['statusBarColor'], validate: false, - )!, + ), + statusBarIconBrightness: decodeBrightness( + value['statusBarIconBrightness'], + validate: false, + ), + systemNavigationBarColor: decodeColor( + value['systemNavigationBarColor'], + validate: false, + ), + systemNavigationBarContrastEnforced: JsonClass.maybeParseBool( + value['systemNavigationBarContrastEnforced'], + ), + systemNavigationBarDividerColor: decodeColor( + value['systemNavigationBarDividerColor'], + validate: false, + ), + systemNavigationBarIconBrightness: decodeBrightness( + value['systemNavigationBarIconBrightness'], + validate: false, + ), + systemStatusBarContrastEnforced: JsonClass.maybeParseBool( + value['systemStatusBarContrastEnforced'], + ), ); - } - - return result; - } - - /// Decodes a given Map-like value into a [ShapeBorder]. The value returned - /// depends on the "type" parameter. The "type" must be one of: - /// * `circle` - /// * `rectangle` - /// * `rounded` - /// - /// The JSON format of the [value] depends on the "type" and the associated - /// class. - /// - /// `CircleBorder` - /// ```json - /// { - /// "side": "", - /// "type": "circle" - /// } - /// ``` - /// - /// `ContinuousRectangleBorder` - /// ```json - /// { - /// "borderRadius": "", - /// "side": "", - /// "type": "rectangle" - /// } - /// ``` - /// - /// `RoundedRectangleBorder` - /// ```json - /// { - /// "borderRadius": "", - /// "side": "", - /// "type": "rounded" - /// } - /// ``` - /// - /// `StadiumBorder` - /// ```json - /// { - /// "side": "", - /// "type": "stadium" - /// } - /// ``` - /// - /// See also: - /// * [decodeBorderRadius] - /// * [decodeBorderSide] - static ShapeBorder? decodeShapeBorder( - dynamic value, { - bool validate = true, - }) { - ShapeBorder? result; - if (value is ShapeBorder) { - result = value; } else { - assert(value == null || value['type'] is String); _checkSupported( - 'ShapeBorder.type', + 'SystemUiOverlayStyle', [ - 'circle', - 'rectangle', - 'rounded', - 'stadium', + 'dark', + 'light', ], - value == null ? null : value['type'], + value, ); if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/shape_border', + schemaId: '$_baseSchemaUrl/system_ui_overlay_style', value: value, validate: validate, )); - final String? type = value['type']; - - switch (type) { - case 'circle': - result = CircleBorder( - side: decodeBorderSide( - value['side'], - validate: false, - ) ?? - BorderSide.none, - ); - break; - - case 'rectangle': - result = ContinuousRectangleBorder( - borderRadius: decodeBorderRadius( - value['borderRadius'], - validate: false, - ) ?? - BorderRadius.zero, - side: decodeBorderSide( - value['side'], - validate: false, - ) ?? - BorderSide.none, - ); - break; - - case 'rounded': - result = RoundedRectangleBorder( - borderRadius: decodeBorderRadius( - value['borderRadius'], - validate: false, - ) ?? - BorderRadius.zero, - side: decodeBorderSide( - value['side'], - validate: false, - ) ?? - BorderSide.none, - ); + switch (value) { + case 'dark': + result = SystemUiOverlayStyle.dark; break; - case 'stadium': - result = StadiumBorder( - side: decodeBorderSide( - value['side'], - validate: false, - ) ?? - BorderSide.none, - ); + case 'light': + result = SystemUiOverlayStyle.light; break; } } @@ -10891,123 +10406,92 @@ class ThemeDecoder { return result; } - /// Decodes the [value] to a [ShowValueIndicator]. Supported values are: - /// * `always` - /// * `never` - /// * `onlyForContinuous` - /// * `onlyForDiscrete` - static ShowValueIndicator? decodeShowValueIndicator( + /// Decodes a [value] to a [TabAlignment]. Supported values are: + /// * `center` + /// * `fill` + /// * `start` + /// * `startOffset` + static TabAlignment? decodeTabAlignment( dynamic value, { bool validate = true, }) { - ShowValueIndicator? result; - if (value is ShowValueIndicator) { + TabAlignment? result; + if (value is TabAlignment) { result = value; } else { _checkSupported( - 'ShowValueIndicator', + 'TabAlignment', [ - 'always', - 'never', - 'onlyForContinuous', - 'onlyForDiscrete', + 'center', + 'fill', + 'start', + 'startOffset', ], value, ); if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/show_value_indicator', + schemaId: '$_baseSchemaUrl/tab_alignment', value: value, validate: validate, )); switch (value) { - case 'always': - result = ShowValueIndicator.always; + case 'center': + result = TabAlignment.center; break; - case 'never': - result = ShowValueIndicator.never; + case 'fill': + result = TabAlignment.fill; break; - case 'onlyForContinuous': - result = ShowValueIndicator.onlyForContinuous; + case 'start': + result = TabAlignment.start; break; - case 'onlyForDiscrete': - result = ShowValueIndicator.onlyForDiscrete; + case 'startOffset': + result = TabAlignment.startOffset; break; } } } - return result; - } - - /// Decodes the given [value] to a [Size]. This expects the - /// [value] to have the following structure: - /// - /// ```json - /// { - /// "height": "", - /// "width": "" - /// } - /// ``` - static Size? decodeSize( - dynamic value, { - bool validate = true, - }) { - Size? result; - - if (value is Size) { - result = value; - } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/size', - value: value, - validate: validate, - )); - result = Size( - JsonClass.maybeParseDouble(value['width'])!, - JsonClass.maybeParseDouble(value['height'])!, - ); - } return result; } - /// Decodes the [value] to a [SliderComponentShape]. Supported values are: - /// * `noOverlay` - /// * `noThumb` - static SliderComponentShape? decodeSliderComponentShape( + /// Decodes a [value] to a [TabBarIndicatorSize]. Supported values are: + /// * `label` + /// * `tab` + static TabBarIndicatorSize? decodeTabBarIndicatorSize( dynamic value, { bool validate = true, }) { - SliderComponentShape? result; - if (value is SliderComponentShape) { + TabBarIndicatorSize? result; + if (value is TabBarIndicatorSize) { result = value; } else { _checkSupported( - 'SliderComponentShape', + 'TabBarIndicatorSize', [ - 'noOverlay', - 'noThumb', + 'label', + 'tab', ], value, ); if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/slider_component_shape', + schemaId: '$_baseSchemaUrl/tab_bar_indicator_size', value: value, validate: validate, )); switch (value) { - case 'noOverlay': - result = SliderComponentShape.noOverlay; + case 'label': + result = TabBarIndicatorSize.label; break; - case 'noThumb': - result = SliderComponentShape.noThumb; + case 'tab': + result = TabBarIndicatorSize.tab; break; } } @@ -11016,234 +10500,104 @@ class ThemeDecoder { return result; } - /// Decodes the [value] to a [SliderComponentShape]. Supported values are: - /// * `slideOnly` - /// * `slideThumb` - /// * `tapAndSlide`` - /// * `tapOnly` - static SliderInteraction? decodeSliderInteraction( - dynamic value, { - bool validate = false, - }) { - SliderInteraction? result; - if (value is SliderInteraction) { - result = value; - } else { - _checkSupported( - 'SliderInteraction', - [ - 'slideOnly', - 'slideThumb', - 'tapAndSlide', - 'tapOnly', - ], - value, - ); - - if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/slider_interaction', - value: value, - validate: validate, - )); - switch (value) { - case 'slideOnly': - result = SliderInteraction.slideOnly; - break; - case 'slideThumb': - result = SliderInteraction.slideThumb; - break; - case 'tapAndSlide': - result = SliderInteraction.tapAndSlide; - break; - case 'tapOnly': - result = SliderInteraction.tapOnly; - break; - } - } - } - - return result; - } - - /// Decodes the given [value] to a [SliderThemeData]. This expects the + /// Decodes the given [value] to a [TabBarTheme]. This expects the /// [value] to have the following structure: /// /// ```json /// { - /// "activeTickMarkColor": "", - /// "activeTrackColor": "", - /// "allowedInteraction": "", - /// "disabledActiveTickMarkColor": "", - /// "disabledActiveTrackColor": "", - /// "disabledInactiveTickMarkColor": "", - /// "disabledInactiveTrackColor": "", - /// "disabledSecondaryActiveTrackColor": "", - /// "disabledThumbColor": "", - /// "inactiveTickMarkColor": "", - /// "inactiveTrackColor": "", - /// "minThumbSeparation": "", - /// "mouseCursor": ">", - /// "overlappingShapeStrokeColor": "", - /// "overlayColor": "", - /// "overlayShape": "", - /// "rangeThumbShape": "", - /// "rangeTickMarkShape": "", - /// "rangeTrackShape": "", - /// "rangeValueIndicatorShape": "", - /// "secondaryActiveTrackColor": "", - /// "showValueIndicator": "", - /// "thumbColor": "", - /// "thumbShape": "", - /// "tickMarkShape": "", - /// "trackHeight": "", - /// "trackShape": "", - /// "valueIndicatorColor": "", - /// "valueIndicatorShape": "", - /// "valueIndicatorTextStyle": "" + /// "dividerColor": "", + /// "dividerHeight": "", + /// "indicatorColor": "", + /// "indicatorSize": "", + /// "labelPadding": "", + /// "labelColor": "", + /// "labelStyle": "", + /// "mouseCursor": ">", + /// "overlayColor": ">", + /// "splashFactory": "", + /// "tabAlignment": "" + /// "unselectedLabelColor": "", + /// "unselectedLabelStyle": "", /// } /// ``` /// /// See also: /// * [decodeColor] - /// * [decodeMaterialStatePropertyMouseCursor] - /// * [decodeShowValueIndicator] - /// * [decodeSliderComponentShape] - /// * [decodeSliderInteraction] - /// * [decodeSliderTickMarkShape] - /// * [decodeRangeSliderThumbShape] - /// * [decodeRangeSliderTickMarkShape] - /// * [decodeRangeSliderTrackShape] - /// * [decodeRangeSliderValueIndicatorShape] - static SliderThemeData? decodeSliderThemeData( + /// * [decodeEdgeInsetsGeometry] + /// * [decodeInteractiveInkFeatureFactory] + /// * [decodeWidgetStatePropertyColor] + /// * [decodeWidgetStatePropertyMouseCursor] + /// * [decodeTabBarAlignment] + /// * [decodeTabBarIndicatorSize] + /// * [decodeTextStyle] + static TabBarTheme? decodeTabBarTheme( dynamic value, { bool validate = true, }) { - SliderThemeData? result; + TabBarTheme? result; - if (value is SliderThemeData) { + if (value is TabBarTheme) { result = value; } else if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/slider_theme_data', + schemaId: '$_baseSchemaUrl/tab_bar_theme', value: value, validate: validate, )); - result = SliderThemeData( - activeTickMarkColor: decodeColor( - value['activeTickMarkColor'], - validate: false, - ), - activeTrackColor: decodeColor( - value['activeTrackColor'], - validate: false, - ), - allowedInteraction: decodeSliderInteraction( - value['allowedInteraction'], - validate: false, - ), - disabledActiveTickMarkColor: decodeColor( - value['disabledActiveTickMarkColor'], - validate: false, - ), - disabledActiveTrackColor: decodeColor( - value['disabledActiveTrackColor'], - validate: false, - ), - disabledInactiveTickMarkColor: decodeColor( - value['disabledInactiveTickMarkColor'], + assert( + value['indicator'] == null, + 'TabBarTheme.indicator is not supported', + ); + result = TabBarTheme( + dividerColor: decodeColor( + value['dividerColor'], validate: false, ), - disabledInactiveTrackColor: decodeColor( - value['disabledInactiveTrackColor'], + dividerHeight: JsonClass.maybeParseDouble(value['dividerHeight']), + // @unencodable + // indicator + indicatorColor: decodeColor( + value['indicatorColor'], validate: false, ), - disabledSecondaryActiveTrackColor: decodeColor( - value['disabledSecondaryActiveTrackColor'], + indicatorSize: decodeTabBarIndicatorSize( + value['indicatorSize'], validate: false, ), - disabledThumbColor: decodeColor( - value['disabledThumbColor'], + labelPadding: decodeEdgeInsetsGeometry( + value['labelPadding'], validate: false, ), - inactiveTickMarkColor: decodeColor( - value['inactiveTickMarkColor'], + labelColor: decodeColor( + value['labelColor'], validate: false, ), - inactiveTrackColor: decodeColor( - value['inactiveTrackColor'], + labelStyle: decodeTextStyle( + value['labelStyle'], validate: false, ), - minThumbSeparation: - JsonClass.maybeParseDouble(value['minThumbSeparation']), - mouseCursor: decodeMaterialStatePropertyMouseCursor( + mouseCursor: decodeWidgetStatePropertyMouseCursor( value['mouseCursor'], validate: false, ), - overlappingShapeStrokeColor: decodeColor( - value['overlappingShapeStrokeColor'], - validate: false, - ), - overlayColor: decodeColor( + overlayColor: decodeWidgetStatePropertyColor( value['overlayColor'], validate: false, ), - overlayShape: decodeSliderComponentShape( - value['overlayShape'], - validate: false, - ), - rangeThumbShape: decodeRangeSliderThumbShape( - value['rangeThumbShape'], - validate: false, - ), - rangeTickMarkShape: decodeRangeSliderTickMarkShape( - value['rangeTickMarkShape'], - validate: false, - ), - rangeTrackShape: decodeRangeSliderTrackShape( - value['rangeTrackShape'], - validate: false, - ), - rangeValueIndicatorShape: decodeRangeSliderValueIndicatorShape( - value['rangeValueIndicatorShape'], - validate: false, - ), - secondaryActiveTrackColor: decodeColor( - value['secondaryActiveTrackColor'], - validate: false, - ), - showValueIndicator: decodeShowValueIndicator( - value['showValueIndicator'], - validate: false, - ), - thumbColor: decodeColor( - value['thumbColor'], - validate: false, - ), - // thumbSelector: @unencodable - thumbShape: decodeSliderComponentShape( - value['thumbShape'], - validate: false, - ), - tickMarkShape: decodeSliderTickMarkShape( - value['tickMarkShape'], - validate: false, - ), - trackHeight: JsonClass.maybeParseDouble(value['trackHeight']), - trackShape: decodeSliderTrackShape( - value['trackShape'], + tabAlignment: decodeTabAlignment( + value['tabAlignment'], validate: false, ), - valueIndicatorColor: decodeColor( - value['valueIndicatorColor'], + splashFactory: decodeInteractiveInkFeatureFactory( + value['splashFactory'], validate: false, ), - valueIndicatorShape: decodeSliderComponentShape( - value['valueIndicatorShape'], + unselectedLabelColor: decodeColor( + value['unselectedLabelColor'], validate: false, ), - valueIndicatorTextStyle: decodeTextStyle( - value['valueIndicatorTextStyle'], + unselectedLabelStyle: decodeTextStyle( + value['unselectedLabelStyle'], validate: false, ), ); @@ -11252,133 +10606,212 @@ class ThemeDecoder { return result; } - /// Decodes the [value] to a [SliderTickMarkShape]. Supported values are: - /// * `noTickMark` - static SliderTickMarkShape? decodeSliderTickMarkShape( + /// Decodes the given [value] to a [TableBorder]. This expects the + /// [value] to have the following structure: + /// + /// ```json + /// { + /// "borderRadius": "", + /// "bottom": "", + /// "horizontalInside": "", + /// "left": "", + /// "right": "", + /// "top": "", + /// "verticalInside": "", + /// } + /// ``` + /// + /// See also: + /// * [decodeBorderRadius] + /// * [decodeBorderSide] + static TableBorder? decodeTableBorder( dynamic value, { bool validate = true, }) { - SliderTickMarkShape? result; - if (value is SliderTickMarkShape) { - result = value; - } else { - _checkSupported( - 'SliderTickMarkShape', - [ - 'noTickMark', - ], - value, - ); + TableBorder? result; - if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/slider_tick_mark_shape', - value: value, - validate: validate, - )); - switch (value) { - case 'noTickMark': - result = SliderTickMarkShape.noTickMark; - break; - } - } + if (value is TableBorder) { + result = value; + } else if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/table_border', + value: value, + validate: validate, + )); + result = TableBorder( + borderRadius: decodeBorderRadius( + value['borderRadius'], + validate: false, + ) ?? + BorderRadius.zero, + bottom: decodeBorderSide( + value['bottom'], + validate: false, + ) ?? + BorderSide.none, + horizontalInside: decodeBorderSide( + value['horizontalInside'], + validate: false, + ) ?? + BorderSide.none, + left: decodeBorderSide( + value['left'], + validate: false, + ) ?? + BorderSide.none, + right: decodeBorderSide( + value['right'], + validate: false, + ) ?? + BorderSide.none, + top: decodeBorderSide( + value['top'], + validate: false, + ) ?? + BorderSide.none, + verticalInside: decodeBorderSide( + value['verticalInside'], + validate: false, + ) ?? + BorderSide.none, + ); } + return result; } - /// Decodes the given [value] to a [SliderTrackShape]. This expects the - /// [value] to have an attribute named "type" that is one of the following - /// values: - /// * `rectangular` - /// * `rounded` - /// - /// The schema for the rest of the attributes depends on the "type". - /// - /// Type: `rectangular` - /// ```json - /// { - /// "type": "rectangular" - /// } - /// ``` + /// Decodes the given [value] to a [TableColumnWidth]. This expects the + /// [value] to have the following structure: /// - /// Type: `rounded` /// ```json /// { - /// "type": "rounded" + /// "a": "", + /// "b": "", + /// "type": "<"fixed" | "flex" | "fraction" | "intrinsic" | "max" | "min">", + /// "value": "" /// } /// ``` - static SliderTrackShape? decodeSliderTrackShape( + static TableColumnWidth? decodeTableColumnWidth( dynamic value, { bool validate = true, }) { - SliderTrackShape? result; - if (value is SliderTrackShape) { + TableColumnWidth? result; + + if (value is TableColumnWidth) { result = value; - } else { - assert(value == null || value['type'] is String); - _checkSupported( - 'type', - [ - 'rectangular', - 'rounded', - ], - value == null ? null : value['type'], - ); + } else if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/table_column_width', + value: value, + validate: validate, + )); + final type = value['type']; - if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/slider_track_shape', - value: value, - validate: validate, - )); - final String? type = value['type']; - switch (type) { - case 'rectangular': - result = const RectangularSliderTrackShape(); - break; + switch (type) { + case 'fixed': + result = + FixedColumnWidth(JsonClass.maybeParseDouble(value['value'])!); + break; - case 'rounded': - result = const RoundedRectSliderTrackShape(); - break; - } + case 'flex': + result = FlexColumnWidth( + JsonClass.maybeParseDouble(value['value']) ?? 1.0, + ); + break; + + case 'fraction': + result = FractionColumnWidth( + JsonClass.maybeParseDouble(value['value'])!, + ); + break; + + case 'intrinsic': + result = IntrinsicColumnWidth( + flex: JsonClass.maybeParseDouble(value['value']), + ); + break; + + case 'max': + result = MaxColumnWidth( + decodeTableColumnWidth(value['a'], validate: false)!, + decodeTableColumnWidth(value['b'], validate: false)!, + ); + break; + + case 'min': + result = MinColumnWidth( + decodeTableColumnWidth(value['a'], validate: false)!, + decodeTableColumnWidth(value['b'], validate: false)!, + ); + break; + + default: + throw Exception( + '[decodeTableColumnWidth]: unknown type encountered: [$type]', + ); } } return result; } - /// Decodes a [value] to a [SmartDashesType]. Supported values are: - /// * `disabled` - /// * `enabled` - static SmartDashesType? decodeSmartDashesType( + /// Decodes a [value] to a [TargetPlatform]. Supported values are: + /// * `android` + /// * `fuchsia` + /// * `iOS` + /// * `linux` + /// * `macOS` + /// * `windows` + static TargetPlatform? decodeTargetPlatform( dynamic value, { bool validate = true, }) { - SmartDashesType? result; - if (value is SmartDashesType) { + TargetPlatform? result; + if (value is TargetPlatform) { result = value; } else { _checkSupported( - 'SmartDashesType', + 'TargetPlatform', [ - 'disabled', - 'enabled', + 'android', + 'fuchsia', + 'iOS', + 'linux', + 'macOS', + 'windows', ], value, ); if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/smart_dashes_type', + schemaId: '$_baseSchemaUrl/target_platform', value: value, validate: validate, )); switch (value) { - case 'disabled': - result = SmartDashesType.disabled; + case 'android': + result = TargetPlatform.android; break; - case 'enabled': - result = SmartDashesType.enabled; + + case 'fuchsia': + result = TargetPlatform.fuchsia; + break; + + case 'iOS': + result = TargetPlatform.iOS; + break; + + case 'linux': + result = TargetPlatform.linux; + break; + + case 'macOS': + result = TargetPlatform.macOS; + break; + + case 'windows': + result = TargetPlatform.windows; break; } } @@ -11387,38 +10820,58 @@ class ThemeDecoder { return result; } - /// Decodes a [value] to a [SmartQuotesType]. Supported values are: - /// * `disabled` - /// * `enabled` - static SmartQuotesType? decodeSmartQuotesType( + /// Decodes the [value] to a [TextAlign]. Supported values are: + /// * `center` + /// * `end` + /// * `justify` + /// * `left` + /// * `right` + /// * `start` + static TextAlign? decodeTextAlign( dynamic value, { bool validate = true, }) { - SmartQuotesType? result; - if (value is SmartQuotesType) { + TextAlign? result; + if (value is TextAlign) { result = value; } else { _checkSupported( - 'SmartQuotesType', + 'TextAlign', [ - 'disabled', - 'enabled', + 'center', + 'end', + 'justify', + 'left', + 'right', + 'start', ], value, ); if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/smart_quotes_type', + schemaId: '$_baseSchemaUrl/text_align', value: value, validate: validate, )); switch (value) { - case 'disabled': - result = SmartQuotesType.disabled; - break; - case 'enabled': - result = SmartQuotesType.enabled; + case 'center': + result = TextAlign.center; + break; + case 'end': + result = TextAlign.end; + break; + case 'justify': + result = TextAlign.justify; + break; + case 'left': + result = TextAlign.left; + break; + case 'right': + result = TextAlign.right; + break; + case 'start': + result = TextAlign.start; break; } } @@ -11427,39 +10880,73 @@ class ThemeDecoder { return result; } - /// Decodes a [value] to a [SnackBarBehavior]. Supported values are: - /// * `fixed` - /// * `floating` - static SnackBarBehavior? decodeSnackBarBehavior( + /// Decodes the [value] to a [TextAlignVertical]. Supported values are: + /// * `bottom` + /// * `center` + /// * `top` + static TextAlignVertical? decodeTextAlignVertical( dynamic value, { bool validate = true, }) { - SnackBarBehavior? result; - if (value is SnackBarBehavior) { + TextAlignVertical? result; + + if (value is TextAlignVertical) { + result = value; + } else if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/text_align_vertical', + value: value, + validate: validate, + )); + switch (value) { + case 'bottom': + result = TextAlignVertical.bottom; + break; + case 'center': + result = TextAlignVertical.center; + break; + case 'top': + result = TextAlignVertical.top; + break; + } + } + + return result; + } + + /// Decodes the [value] to a [TextBaseline]. Supported values are: + /// * `alphabetic` + /// * `ideographic` + static TextBaseline? decodeTextBaseline( + dynamic value, { + bool validate = true, + }) { + TextBaseline? result; + if (value is TextBaseline) { result = value; } else { _checkSupported( - 'SnackBarBehavior', + 'TextBaseline', [ - 'fixed', - 'floating', + 'alphabetic', + 'ideographic', ], value, ); if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/snack_bar_behavior', + schemaId: '$_baseSchemaUrl/text_baseline', value: value, validate: validate, )); switch (value) { - case 'fixed': - result = SnackBarBehavior.fixed; + case 'alphabetic': + result = TextBaseline.alphabetic; break; - case 'floating': - result = SnackBarBehavior.floating; + case 'ideographic': + result = TextBaseline.ideographic; break; } } @@ -11468,353 +10955,140 @@ class ThemeDecoder { return result; } - /// Decodes the given [value] to a [SnackBarThemeData]. This expects the - /// [value] to have the following structure: + /// Decodes the given [value] to an [TextButtonThemeData]. This expects the + /// given [value] to be of the following structure: /// /// ```json /// { - /// "actionBackgroundColor": "", - /// "actionOverflowThreshold": "", - /// "actionTextColor": "", - /// "backgroundColor": "", - /// "behavior": "", - /// "closeIconColor": "", - /// "contentTextStyle": "", - /// "disabledActionBackgroundColor": "", - /// "disabledActionTextColor": "", - /// "elevation": "", - /// "insetPadding": "", - /// "shape": "", - /// "showCloseIcon": "", - /// "width": "" + /// "style": "" /// } /// ``` /// /// See also: - /// * [decodeColor] - /// * [decodeEdgeInsets] - /// * [decodeSnackBarBehavior] - /// * [decodeShapeBorder] - /// * [decodeTextStyle] - static SnackBarThemeData? decodeSnackBarThemeData( + /// * [decodeButtonStyle] + static TextButtonThemeData? decodeTextButtonThemeData( dynamic value, { bool validate = true, }) { - SnackBarThemeData? result; + TextButtonThemeData? result; - if (value is SnackBarThemeData) { + if (value is TextButtonThemeData) { result = value; } else if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/snack_bar_theme_data', + schemaId: '$_baseSchemaUrl/text_button_theme_data', value: value, validate: validate, )); - result = SnackBarThemeData( - actionBackgroundColor: decodeColor( - value['actionBackgroundColor'], - validate: false, - ), - actionOverflowThreshold: JsonClass.maybeParseDouble( - value['actionOverflowThreshold'], - ), - actionTextColor: decodeColor( - value['actionTextColor'], - validate: false, - ), - backgroundColor: decodeColor( - value['backgroundColor'], - validate: false, - ), - behavior: decodeSnackBarBehavior( - value['behavior'], - validate: false, - ), - closeIconColor: decodeColor( - value['closeIconColor'], - validate: false, - ), - contentTextStyle: decodeTextStyle( - value['contentTextStyle'], - validate: false, - ), - disabledActionBackgroundColor: decodeColor( - value['disabledActionBackgroundColor'], - validate: false, - ), - disabledActionTextColor: decodeColor( - value['disabledActionTextColor'], - validate: false, - ), - elevation: JsonClass.maybeParseDouble(value['elevation']), - insetPadding: decodeEdgeInsets( - value['insetPadding'], - validate: false, - ), - shape: decodeShapeBorder( - value['shape'], + result = TextButtonThemeData( + style: decodeButtonStyle( + value['style'], validate: false, ), - showCloseIcon: JsonClass.maybeParseBool(value['showCloseIcon']), - width: JsonClass.maybeParseDouble(value['width']), ); } return result; } - /// Decodes a [value] to a [StackFit]. Supported values are: - /// * `expand` - /// * `loose` - /// * `passthrough` - static StackFit? decodeStackFit( + /// Decodes the [value] to a [TextCapitalization]. Supported values are: + /// * `characters` + /// * `none` + /// * `sentences` + /// * `words` + static TextCapitalization? decodeTextCapitalization( dynamic value, { bool validate = true, }) { - StackFit? result; - - if (value is StackFit) { + TextCapitalization? result; + if (value is TextCapitalization) { result = value; - } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/stack_fit', - value: value, - validate: validate, - )); - switch (value) { - case 'expand': - result = StackFit.expand; - break; + } else { + _checkSupported( + 'TextCapitalization', + [ + 'characters', + 'none', + 'sentences', + 'words', + ], + value, + ); - case 'loose': - result = StackFit.loose; - break; + if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/text_capitalization', + value: value, + validate: validate, + )); + switch (value) { + case 'characters': + result = TextCapitalization.characters; + break; - case 'passthrough': - result = StackFit.passthrough; - break; + case 'none': + result = TextCapitalization.none; + break; + + case 'sentences': + result = TextCapitalization.sentences; + break; + + case 'words': + result = TextCapitalization.words; + break; + } } } return result; } - /// Decodes the given [value] into a [StrutStyle]. If the value is `null` - /// then `null` will be returned. Otherwise, this expects a Map like value - /// that in JSON would look like: - /// - /// ```json - /// { - /// "fontFamily": "", - /// "fontFamilyFallback": "", - /// "fontSize": "", - /// "fontStyle": "", - /// "fontWeight": "" - /// "forceStrutHeight": "", - /// "height": "", - /// "leading": "", - /// "leadingDistribution": "", - /// "package": "" - /// } - /// ``` - /// - /// See also: - /// * [decodeFontStyle] - /// * [decodeFontWeight] - /// * [decodeTextLeadingDistribution] - static StrutStyle? decodeStrutStyle( + /// Decodes the [value] to a [TextDecoration]. Supported values are: + /// * `lineThrough` + /// * `none` + /// * `overline` + /// * `underline` + static TextDecoration? decodeTextDecoration( dynamic value, { bool validate = true, }) { - StrutStyle? result; - - if (value is StrutStyle) { - result = value; - } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/strut_style', - value: value, - validate: validate, - )); - result = StrutStyle( - fontFamily: value['fontFamily'], - fontFamilyFallback: _decodeStringList( - value['fontFamilyFallback'], - (value) => value, - ), - fontSize: JsonClass.maybeParseDouble(value['fontSize']), - fontStyle: decodeFontStyle( - value['fontStyle'], - validate: false, - ), - fontWeight: decodeFontWeight( - value['fontWeight'], - validate: false, - ), - forceStrutHeight: JsonClass.maybeParseBool(value['forceStrutHeight']), - height: JsonClass.maybeParseDouble(value['height']), - leading: JsonClass.maybeParseDouble(value['leading']), - leadingDistribution: decodeTextLeadingDistribution( - value['leadingDistribution'], - validate: false, - ), - package: value['package'], - ); - } - - return result; - } - - /// Decodes the given [value] to an [SwitchThemeData]. This expects the given - /// [value] to follow the structure below: - /// - /// ```json - /// { - /// "materialTapTargetSize": "", - /// "mouseCursor": ">", - /// "overlayColor": ">", - /// "splashRadius": "", - /// "thumbColor": ">", - /// "trackColor": ">", - /// "trackOutlineColor": ">" - /// "trackOutlineWidth": ">" - /// } - /// ``` - /// - /// See also: - /// * [decodeColor] - /// * [decodeMaterialStatePropertyColor] - /// * [decodeMaterialStatePropertyDouble] - /// * [decodeMaterialStatePropertyMouseCursor] - /// * [decodeMaterialTapTargetSize] - /// * [decodeMouseCursor] - static SwitchThemeData? decodeSwitchThemeData( - dynamic value, { - bool validate = true, - }) { - SwitchThemeData? result; - - if (value is SwitchThemeData) { - result = value; - } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/switch_theme_data', - value: value, - validate: validate, - )); - - result = SwitchThemeData( - materialTapTargetSize: decodeMaterialTapTargetSize( - value['materialTapTargetSize'], - validate: false, - ), - mouseCursor: decodeMaterialStatePropertyMouseCursor( - value['mouseCursor'], - validate: false, - ), - overlayColor: decodeMaterialStatePropertyColor( - value['overlayColor'], - validate: false, - ), - splashRadius: JsonClass.maybeParseDouble(value['splashRadius']), - thumbColor: decodeMaterialStatePropertyColor( - value['thumbColor'], - validate: false, - ), - thumbIcon: decodeMaterialStatePropertyIcon( - value['thumbIcon'], - validate: false, - ), - trackColor: decodeMaterialStatePropertyColor( - value['trackColor'], - validate: false, - ), - trackOutlineColor: decodeMaterialStatePropertyColor( - value['trackOutlineColor'], - validate: false, - ), - trackOutlineWidth: decodeMaterialStatePropertyDouble( - value['trackOutlineWidth'], - validate: false, - ), - ); - } - - return result; - } - - /// Decodes a [value] to a [SystemUiOverlayStyle]. Supported values are: - /// * `dark` - /// * `light` - static SystemUiOverlayStyle? decodeSystemUiOverlayStyle( - dynamic value, { - bool validate = true, - }) { - SystemUiOverlayStyle? result; - if (value is SystemUiOverlayStyle) { + TextDecoration? result; + if (value is TextDecoration) { result = value; - } else if (value is Map) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/system_ui_overlay_style', - value: value, - validate: validate, - )); - - result = SystemUiOverlayStyle( - statusBarBrightness: decodeBrightness( - value['statusBarBrightness'], - validate: false, - ), - statusBarColor: decodeColor( - value['statusBarColor'], - validate: false, - ), - statusBarIconBrightness: decodeBrightness( - value['statusBarIconBrightness'], - validate: false, - ), - systemNavigationBarColor: decodeColor( - value['systemNavigationBarColor'], - validate: false, - ), - systemNavigationBarContrastEnforced: JsonClass.maybeParseBool( - value['systemNavigationBarContrastEnforced'], - ), - systemNavigationBarDividerColor: decodeColor( - value['systemNavigationBarDividerColor'], - validate: false, - ), - systemNavigationBarIconBrightness: decodeBrightness( - value['systemNavigationBarIconBrightness'], - validate: false, - ), - systemStatusBarContrastEnforced: JsonClass.maybeParseBool( - value['systemStatusBarContrastEnforced'], - ), - ); } else { _checkSupported( - 'SystemUiOverlayStyle', + 'TextDecoration', [ - 'dark', - 'light', + 'lineThrough', + 'none', + 'overline', + 'underline', ], value, ); if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/system_ui_overlay_style', + schemaId: '$_baseSchemaUrl/text_decoration', value: value, validate: validate, )); switch (value) { - case 'dark': - result = SystemUiOverlayStyle.dark; + case 'lineThrough': + result = TextDecoration.lineThrough; break; - case 'light': - result = SystemUiOverlayStyle.light; + case 'none': + result = TextDecoration.none; + break; + + case 'overline': + result = TextDecoration.overline; + break; + + case 'underline': + result = TextDecoration.underline; break; } } @@ -11823,51 +11097,57 @@ class ThemeDecoder { return result; } - /// Decodes a [value] to a [TabAlignment]. Supported values are: - /// * `center` - /// * `fill` - /// * `start` - /// * `startOffset` - static TabAlignment? decodeTabAlignment( + /// Decodes the [value] to a [TextDecorationStyle]. Supported values are: + /// * `dashed` + /// * `dotted` + /// * `double` + /// * `solid` + /// * `wavy` + static TextDecorationStyle? decodeTextDecorationStyle( dynamic value, { bool validate = true, }) { - TabAlignment? result; - if (value is TabAlignment) { + TextDecorationStyle? result; + if (value is TextDecorationStyle) { result = value; } else { _checkSupported( - 'TabAlignment', + 'TextDecorationStyle', [ - 'center', - 'fill', - 'start', - 'startOffset', + 'dashed', + 'dotted', + 'double', + 'solid', + 'wavy', ], value, ); if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/tab_alignment', + schemaId: '$_baseSchemaUrl/text_decoration_style', value: value, validate: validate, )); switch (value) { - case 'center': - result = TabAlignment.center; + case 'dashed': + result = TextDecorationStyle.dashed; break; - case 'fill': - result = TabAlignment.fill; + case 'dotted': + result = TextDecorationStyle.dotted; break; - case 'start': - result = TabAlignment.start; + case 'double': + result = TextDecorationStyle.double; break; - case 'startOffset': - result = TabAlignment.startOffset; + case 'solid': + result = TextDecorationStyle.solid; + break; + + case 'wavy': + result = TextDecorationStyle.wavy; break; } } @@ -11876,39 +11156,39 @@ class ThemeDecoder { return result; } - /// Decodes a [value] to a [TabBarIndicatorSize]. Supported values are: - /// * `label` - /// * `tab` - static TabBarIndicatorSize? decodeTabBarIndicatorSize( + /// Decodes the [value] to a [TextDirection]. Supported values are: + /// * `ltr` + /// * `rtl` + static TextDirection? decodeTextDirection( dynamic value, { bool validate = true, }) { - TabBarIndicatorSize? result; - if (value is TabBarIndicatorSize) { + TextDirection? result; + if (value is TextDirection) { result = value; } else { _checkSupported( - 'TabBarIndicatorSize', + 'TextDirection', [ - 'label', - 'tab', + 'ltr', + 'rtl', ], value, ); if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/tab_bar_indicator_size', + schemaId: '$_baseSchemaUrl/text_direction', value: value, validate: validate, )); switch (value) { - case 'label': - result = TabBarIndicatorSize.label; + case 'ltr': + result = TextDirection.ltr; break; - case 'tab': - result = TabBarIndicatorSize.tab; + case 'rtl': + result = TextDirection.rtl; break; } } @@ -11917,378 +11197,286 @@ class ThemeDecoder { return result; } - /// Decodes the given [value] to a [TabBarTheme]. This expects the - /// [value] to have the following structure: - /// - /// ```json + /// Decodes the given [value] into a [TextHeightBehavior]. If the value is + /// `null` then `null` will be returned. Otherwise, this expects a Map like + /// value that in JSON would look like: + /// + /// ```json /// { - /// "dividerColor": "", - /// "dividerHeight": "", - /// "indicatorColor": "", - /// "indicatorSize": "", - /// "labelPadding": "", - /// "labelColor": "", - /// "labelStyle": "", - /// "mouseCursor": ">", - /// "overlayColor": ">", - /// "splashFactory": "", - /// "tabAlignment": "" - /// "unselectedLabelColor": "", - /// "unselectedLabelStyle": "", + /// "applyHeightToFirstAscent": "", + /// "applyHeightToLastDescent": "", + /// "leadingDistribution": "" /// } /// ``` - /// - /// See also: - /// * [decodeColor] - /// * [decodeEdgeInsetsGeometry] - /// * [decodeInteractiveInkFeatureFactory] - /// * [decodeMaterialStatePropertyColor] - /// * [decodeMaterialStatePropertyMouseCursor] - /// * [decodeTabBarAlignment] - /// * [decodeTabBarIndicatorSize] - /// * [decodeTextStyle] - static TabBarTheme? decodeTabBarTheme( + static TextHeightBehavior? decodeTextHeightBehavior( dynamic value, { bool validate = true, }) { - TabBarTheme? result; + TextHeightBehavior? result; - if (value is TabBarTheme) { + if (value is TextHeightBehavior) { result = value; } else if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/tab_bar_theme', + schemaId: '$_baseSchemaUrl/text_height_behavior', value: value, validate: validate, )); - assert( - value['indicator'] == null, - 'TabBarTheme.indicator is not supported', - ); - result = TabBarTheme( - dividerColor: decodeColor( - value['dividerColor'], - validate: false, - ), - dividerHeight: JsonClass.maybeParseDouble(value['dividerHeight']), - // @unencodable - // indicator - indicatorColor: decodeColor( - value['indicatorColor'], - validate: false, - ), - indicatorSize: decodeTabBarIndicatorSize( - value['indicatorSize'], - validate: false, - ), - labelPadding: decodeEdgeInsetsGeometry( - value['labelPadding'], - validate: false, - ), - labelColor: decodeColor( - value['labelColor'], - validate: false, - ), - labelStyle: decodeTextStyle( - value['labelStyle'], - validate: false, - ), - mouseCursor: decodeMaterialStatePropertyMouseCursor( - value['mouseCursor'], - validate: false, - ), - overlayColor: decodeMaterialStatePropertyColor( - value['overlayColor'], - validate: false, - ), - tabAlignment: decodeTabAlignment( - value['tabAlignment'], - validate: false, - ), - splashFactory: decodeInteractiveInkFeatureFactory( - value['splashFactory'], - validate: false, - ), - unselectedLabelColor: decodeColor( - value['unselectedLabelColor'], - validate: false, + result = TextHeightBehavior( + applyHeightToFirstAscent: JsonClass.parseBool( + value['applyHeightToLastDescent'], + whenNull: true, ), - unselectedLabelStyle: decodeTextStyle( - value['unselectedLabelStyle'], - validate: false, + applyHeightToLastDescent: JsonClass.parseBool( + value['applyHeightToLastDescent'], + whenNull: true, ), + leadingDistribution: decodeTextLeadingDistribution( + value['leadingDistribution'], + validate: false, + ) ?? + TextLeadingDistribution.proportional, ); } return result; } - /// Decodes the given [value] to a [TableBorder]. This expects the - /// [value] to have the following structure: - /// - /// ```json - /// { - /// "borderRadius": "", - /// "bottom": "", - /// "horizontalInside": "", - /// "left": "", - /// "right": "", - /// "top": "", - /// "verticalInside": "", - /// } - /// ``` - /// - /// See also: - /// * [decodeBorderRadius] - /// * [decodeBorderSide] - static TableBorder? decodeTableBorder( + /// Decodes the [value] to a [TextInputAction]. Supported values are: + /// * `continueAction` + /// * `done` + /// * `emergencyCall` + /// * `go` + /// * `join` + /// * `newline` + /// * `next` + /// * `none` + /// * `previous` + /// * `route` + /// * `search` + /// * `send` + /// * `unspecified` + static TextInputAction? decodeTextInputAction( dynamic value, { bool validate = true, }) { - TableBorder? result; - - if (value is TableBorder) { + TextInputAction? result; + if (value is TextInputAction) { result = value; - } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/table_border', - value: value, - validate: validate, - )); - result = TableBorder( - borderRadius: decodeBorderRadius( - value['borderRadius'], - validate: false, - ) ?? - BorderRadius.zero, - bottom: decodeBorderSide( - value['bottom'], - validate: false, - ) ?? - BorderSide.none, - horizontalInside: decodeBorderSide( - value['horizontalInside'], - validate: false, - ) ?? - BorderSide.none, - left: decodeBorderSide( - value['left'], - validate: false, - ) ?? - BorderSide.none, - right: decodeBorderSide( - value['right'], - validate: false, - ) ?? - BorderSide.none, - top: decodeBorderSide( - value['top'], - validate: false, - ) ?? - BorderSide.none, - verticalInside: decodeBorderSide( - value['verticalInside'], - validate: false, - ) ?? - BorderSide.none, + } else { + _checkSupported( + 'TextInputAction', + [ + 'continueAction', + 'done', + 'emergencyCall', + 'go', + 'join', + 'newline', + 'next', + 'none', + 'previous', + 'route', + 'search', + 'send', + 'unspecified', + ], + value, ); - } - return result; - } + if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/text_input_action', + value: value, + validate: validate, + )); - /// Decodes the given [value] to a [TableColumnWidth]. This expects the - /// [value] to have the following structure: - /// - /// ```json - /// { - /// "a": "", - /// "b": "", - /// "type": "<"fixed" | "flex" | "fraction" | "intrinsic" | "max" | "min">", - /// "value": "" - /// } - /// ``` - static TableColumnWidth? decodeTableColumnWidth( - dynamic value, { - bool validate = true, - }) { - TableColumnWidth? result; + switch (value) { + case 'continueAction': + result = TextInputAction.continueAction; + break; - if (value is TableColumnWidth) { - result = value; - } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/table_column_width', - value: value, - validate: validate, - )); - final type = value['type']; + case 'done': + result = TextInputAction.done; + break; - switch (type) { - case 'fixed': - result = - FixedColumnWidth(JsonClass.maybeParseDouble(value['value'])!); - break; + case 'emergencyCall': + result = TextInputAction.emergencyCall; + break; - case 'flex': - result = FlexColumnWidth( - JsonClass.maybeParseDouble(value['value']) ?? 1.0, - ); - break; + case 'go': + result = TextInputAction.go; + break; - case 'fraction': - result = FractionColumnWidth( - JsonClass.maybeParseDouble(value['value'])!, - ); - break; + case 'join': + result = TextInputAction.join; + break; - case 'intrinsic': - result = IntrinsicColumnWidth( - flex: JsonClass.maybeParseDouble(value['value']), - ); - break; + case 'newline': + result = TextInputAction.newline; + break; - case 'max': - result = MaxColumnWidth( - decodeTableColumnWidth(value['a'], validate: false)!, - decodeTableColumnWidth(value['b'], validate: false)!, - ); - break; + case 'next': + result = TextInputAction.next; + break; - case 'min': - result = MinColumnWidth( - decodeTableColumnWidth(value['a'], validate: false)!, - decodeTableColumnWidth(value['b'], validate: false)!, - ); - break; + case 'none': + result = TextInputAction.none; + break; - default: - throw Exception( - '[decodeTableColumnWidth]: unknown type encountered: [$type]', - ); + case 'previous': + result = TextInputAction.previous; + break; + + case 'route': + result = TextInputAction.route; + break; + + case 'search': + result = TextInputAction.search; + break; + + case 'send': + result = TextInputAction.send; + break; + + case 'unspecified': + result = TextInputAction.unspecified; + break; + } } } return result; } - /// Decodes a [value] to a [TargetPlatform]. Supported values are: - /// * `android` - /// * `fuchsia` - /// * `iOS` - /// * `linux` - /// * `macOS` - /// * `windows` - static TargetPlatform? decodeTargetPlatform( + /// Decodes the [value] to a [TextInputType]. Supported values are: + /// * `datetime` + /// * `emailAddress` + /// * `multiline` + /// * `name` + /// * `none` + /// * `number` + /// * `phone` + /// * `streetAddress` + /// * `text` + /// * `url` + /// * `visiblePassword` + static TextInputType? decodeTextInputType( dynamic value, { bool validate = true, }) { - TargetPlatform? result; - if (value is TargetPlatform) { + TextInputType? result; + if (value is TextInputType) { result = value; } else { _checkSupported( - 'TargetPlatform', + 'TextInputType', [ - 'android', - 'fuchsia', - 'iOS', - 'linux', - 'macOS', - 'windows', + 'datetime', + 'emailAddress', + 'multiline', + 'name', + 'none', + 'number', + 'phone', + 'streetAddress', + 'text', + 'url', + 'visiblePassword', ], value, ); if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/target_platform', + schemaId: '$_baseSchemaUrl/text_input_type', value: value, validate: validate, )); switch (value) { - case 'android': - result = TargetPlatform.android; + case 'datetime': + result = TextInputType.datetime; break; - case 'fuchsia': - result = TargetPlatform.fuchsia; + case 'emailAddress': + result = TextInputType.emailAddress; break; - case 'iOS': - result = TargetPlatform.iOS; + case 'multiline': + result = TextInputType.multiline; break; - case 'linux': - result = TargetPlatform.linux; + case 'name': + result = TextInputType.name; break; - case 'macOS': - result = TargetPlatform.macOS; + case 'none': + result = TextInputType.none; break; - case 'windows': - result = TargetPlatform.windows; + case 'number': + result = TextInputType.number; + break; + + case 'phone': + result = TextInputType.phone; + break; + + case 'streetAddress': + result = TextInputType.streetAddress; + break; + + case 'text': + result = TextInputType.text; + break; + + case 'url': + result = TextInputType.url; + break; + + case 'visiblePassword': + result = TextInputType.visiblePassword; break; } } } - return result; } - /// Decodes the [value] to a [TextAlign]. Supported values are: - /// * `center` - /// * `end` - /// * `justify` - /// * `left` - /// * `right` - /// * `start` - static TextAlign? decodeTextAlign( + /// Decodes the [value] to a [TextLeadingDistribution]. Supported values are: + /// * `even` + /// * `proportional` + static TextLeadingDistribution? decodeTextLeadingDistribution( dynamic value, { bool validate = true, }) { - TextAlign? result; - if (value is TextAlign) { + TextLeadingDistribution? result; + if (value is TextLeadingDistribution) { result = value; } else { _checkSupported( - 'TextAlign', + 'TextLeadingDistribution', [ - 'center', - 'end', - 'justify', - 'left', - 'right', - 'start', + 'even', + 'proportional', ], value, ); if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/text_align', + schemaId: '$_baseSchemaUrl/text_leading_distribution', value: value, validate: validate, )); switch (value) { - case 'center': - result = TextAlign.center; - break; - case 'end': - result = TextAlign.end; - break; - case 'justify': - result = TextAlign.justify; - break; - case 'left': - result = TextAlign.left; - break; - case 'right': - result = TextAlign.right; + case 'even': + result = TextLeadingDistribution.even; break; - case 'start': - result = TextAlign.start; + + case 'proportional': + result = TextLeadingDistribution.proportional; break; } } @@ -12297,73 +11485,48 @@ class ThemeDecoder { return result; } - /// Decodes the [value] to a [TextAlignVertical]. Supported values are: - /// * `bottom` - /// * `center` - /// * `top` - static TextAlignVertical? decodeTextAlignVertical( - dynamic value, { - bool validate = true, - }) { - TextAlignVertical? result; - - if (value is TextAlignVertical) { - result = value; - } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/text_align_vertical', - value: value, - validate: validate, - )); - switch (value) { - case 'bottom': - result = TextAlignVertical.bottom; - break; - case 'center': - result = TextAlignVertical.center; - break; - case 'top': - result = TextAlignVertical.top; - break; - } - } - - return result; - } - - /// Decodes the [value] to a [TextBaseline]. Supported values are: - /// * `alphabetic` - /// * `ideographic` - static TextBaseline? decodeTextBaseline( + /// Decodes the [value] to a [TextOverflow]. Supported values are: + /// * `clip` + /// * `ellipsis` + /// * `fade` + /// * `visible` + static TextOverflow? decodeTextOverflow( dynamic value, { bool validate = true, }) { - TextBaseline? result; - if (value is TextBaseline) { + TextOverflow? result; + if (value is TextOverflow) { result = value; } else { _checkSupported( - 'TextBaseline', + 'TextOverflow', [ - 'alphabetic', - 'ideographic', + 'clip', + 'ellipsis', + 'fade', + 'visible', ], value, ); if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/text_baseline', + schemaId: '$_baseSchemaUrl/text_overflow', value: value, validate: validate, )); switch (value) { - case 'alphabetic': - result = TextBaseline.alphabetic; + case 'clip': + result = TextOverflow.clip; break; - - case 'ideographic': - result = TextBaseline.ideographic; + case 'ellipsis': + result = TextOverflow.ellipsis; + break; + case 'fade': + result = TextOverflow.fade; + break; + case 'visible': + result = TextOverflow.visible; break; } } @@ -12372,34 +11535,44 @@ class ThemeDecoder { return result; } - /// Decodes the given [value] to an [TextButtonThemeData]. This expects the + /// Decodes the given [value] to an [TextSelectionThemeData]. This expects the /// given [value] to be of the following structure: /// /// ```json /// { - /// "style": "" + /// "cursorColor": "", + /// "selectionColor": "", + /// "selectionHandleColor": "" /// } /// ``` /// /// See also: - /// * [decodeButtonStyle] - static TextButtonThemeData? decodeTextButtonThemeData( + /// * [decodeColor] + static TextSelectionThemeData? decodeTextSelectionThemeData( dynamic value, { bool validate = true, }) { - TextButtonThemeData? result; + TextSelectionThemeData? result; - if (value is TextButtonThemeData) { + if (value is TextSelectionThemeData) { result = value; } else if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/text_button_theme_data', + schemaId: '$_baseSchemaUrl/text_selection_theme_data', value: value, validate: validate, )); - result = TextButtonThemeData( - style: decodeButtonStyle( - value['style'], + result = TextSelectionThemeData( + cursorColor: decodeColor( + value['cursorColor'], + validate: false, + ), + selectionColor: decodeColor( + value['selectionColor'], + validate: false, + ), + selectionHandleColor: decodeColor( + value['selectionHandleColor'], validate: false, ), ); @@ -12408,1296 +11581,706 @@ class ThemeDecoder { return result; } - /// Decodes the [value] to a [TextCapitalization]. Supported values are: - /// * `characters` - /// * `none` - /// * `sentences` - /// * `words` - static TextCapitalization? decodeTextCapitalization( + /// Decodes a given Map-like [value] into a [TextStyle]. This expects the + /// given [value] to have the following structure: + /// + /// ```json + /// { + /// "children": ">", + /// "locale": "", + /// "mouseCursor": "", + /// "onEnter": "", + /// "onExit": "", + /// "recognizer": "", + /// "semanticsLabel": "", + /// "spellOut": "", + /// "style": "", + /// "text": "" + /// } + /// ``` + /// + /// See Also: + /// * [decodeLocale] + /// * [decodeMouseCursor] + /// * [decodeTextStyle] + static TextSpan? decodeTextSpan( dynamic value, { bool validate = true, }) { - TextCapitalization? result; - if (value is TextCapitalization) { - result = value; - } else { - _checkSupported( - 'TextCapitalization', - [ - 'characters', - 'none', - 'sentences', - 'words', - ], - value, - ); - - if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/text_capitalization', - value: value, - validate: validate, - )); - switch (value) { - case 'characters': - result = TextCapitalization.characters; - break; - - case 'none': - result = TextCapitalization.none; - break; - - case 'sentences': - result = TextCapitalization.sentences; - break; - - case 'words': - result = TextCapitalization.words; - break; - } - } - } - - return result; - } + TextSpan? result; - /// Decodes the [value] to a [TextDecoration]. Supported values are: - /// * `lineThrough` - /// * `none` - /// * `overline` - /// * `underline` - static TextDecoration? decodeTextDecoration( - dynamic value, { - bool validate = true, - }) { - TextDecoration? result; - if (value is TextDecoration) { + if (value is TextSpan) { result = value; - } else { - _checkSupported( - 'TextDecoration', - [ - 'lineThrough', - 'none', - 'overline', - 'underline', - ], - value, - ); - - if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/text_decoration', - value: value, - validate: validate, - )); - switch (value) { - case 'lineThrough': - result = TextDecoration.lineThrough; - break; - - case 'none': - result = TextDecoration.none; - break; - - case 'overline': - result = TextDecoration.overline; - break; + } else if (value is String) { + result = TextSpan(text: value); + } else if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/text_span', + value: value, + validate: validate, + )); - case 'underline': - result = TextDecoration.underline; - break; - } - } + result = TextSpan( + children: (value['children'] as List?) + ?.map((e) => decodeTextSpan(e, validate: false)!) + .toList(), + locale: decodeLocale( + value['locale'], + validate: false, + ), + mouseCursor: decodeMouseCursor( + value['mouseCursor'], + validate: false, + ), + onEnter: value['onEnter'], + onExit: value['onExit'], + recognizer: value['recognizer'], + semanticsLabel: value['semanticsLabel']?.toString(), + spellOut: JsonClass.maybeParseBool(value['spellOut']), + style: decodeTextStyle( + value['style'], + validate: false, + ), + text: value['text']?.toString(), + ); } return result; } - /// Decodes the [value] to a [TextDecorationStyle]. Supported values are: - /// * `dashed` - /// * `dotted` - /// * `double` - /// * `solid` - /// * `wavy` - static TextDecorationStyle? decodeTextDecorationStyle( + /// Decodes a given Map-like [value] into a [TextStyle]. This expects the + /// given [value] to have the following structure: + /// + /// ```json + /// { + /// "backgroundColor": "", + /// "color": "", + /// "decoration": "", + /// "decorationColor": "", + /// "decorationStyle": "", + /// "decorationThickness": "", + /// "fontFamily": "", + /// "fontFamilyFallback": "", + /// "fontFeatures": "", + /// "fontSize": "", + /// "fontStyle": "", + /// "fontWeight": "", + /// "height": "", + /// "inherit": "", + /// "leadingDistribution": "", + /// "letterSpacing": "", + /// "locale": "", + /// "overflow": "", + /// "package": "", + /// "shadows": "", + /// "textBaseline": "", + /// "wordSpacing": "" + /// } + /// ``` + /// + /// See also: + /// * [decodeColor] + /// * [decodeFontFeature] + /// * [decodeFontStyle] + /// * [decodeFontVariation] + /// * [decodeFontWeight] + /// * [decodeLocale] + /// * [decodeShadow] + /// * [decodeTextBaseline] + /// * [decodeTextDecoration] + /// * [decodeTextDecorationStyle] + /// * [decodeTextLeadingDistribution] + /// * [decodeTextOverflow] + static TextStyle? decodeTextStyle( dynamic value, { bool validate = true, }) { - TextDecorationStyle? result; - if (value is TextDecorationStyle) { + TextStyle? result; + + if (value is TextStyle) { result = value; - } else { - _checkSupported( - 'TextDecorationStyle', - [ - 'dashed', - 'dotted', - 'double', - 'solid', - 'wavy', - ], - value, - ); - - if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/text_decoration_style', - value: value, - validate: validate, - )); - switch (value) { - case 'dashed': - result = TextDecorationStyle.dashed; - break; - - case 'dotted': - result = TextDecorationStyle.dotted; - break; - - case 'double': - result = TextDecorationStyle.double; - break; - - case 'solid': - result = TextDecorationStyle.solid; - break; - - case 'wavy': - result = TextDecorationStyle.wavy; - break; - } - } - } - - return result; - } - - /// Decodes the [value] to a [TextDirection]. Supported values are: - /// * `ltr` - /// * `rtl` - static TextDirection? decodeTextDirection( - dynamic value, { - bool validate = true, - }) { - TextDirection? result; - if (value is TextDirection) { - result = value; - } else { - _checkSupported( - 'TextDirection', - [ - 'ltr', - 'rtl', - ], - value, + } else if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/text_style', + value: value, + validate: validate, + )); + result = TextStyle( + // background: @unencodable + backgroundColor: decodeColor( + value['backgroundColor'], + validate: false, + ), + color: decodeColor( + value['color'], + validate: false, + ), + decoration: decodeTextDecoration( + value['decoration'], + validate: false, + ), + decorationColor: decodeColor( + value['decorationColor'], + validate: false, + ), + decorationStyle: decodeTextDecorationStyle( + value['decorationStyle'], + validate: false, + ), + decorationThickness: + JsonClass.maybeParseDouble(value['decorationThickness']), + fontFamily: value['fontFamily'], + fontFamilyFallback: value['fontFamilyFallback'] == null + ? null + : List.from(value['fontFamilyFallback']), + fontFeatures: value['fontFeatures'] == null + ? null + : List.from( + value['fontFeatures'].map( + (value) => decodeFontFeature( + value, + validate: false, + ), + ), + ), + fontVariations: (value['fontVariations'] as List?) + ?.map( + (e) => decodeFontVariation( + e, + validate: false, + )!, + ) + .toList(), + fontWeight: decodeFontWeight( + value['fontWeight'], + validate: false, + ), + fontSize: JsonClass.maybeParseDouble(value['fontSize']), + fontStyle: decodeFontStyle( + value['fontStyle'], + validate: false, + ), + // foreground: @unencodable + height: JsonClass.maybeParseDouble(value['height']), + inherit: JsonClass.parseBool( + value['inherit'], + whenNull: true, + ), + leadingDistribution: decodeTextLeadingDistribution( + value['leadingDistribution'], + validate: false, + ), + letterSpacing: JsonClass.maybeParseDouble(value['letterSpacing']), + locale: decodeLocale( + value['locale'], + validate: false, + ), + overflow: decodeTextOverflow( + value['overflow'], + validate: false, + ), + package: value['package'], + shadows: value['shadows'] == null + ? null + : List.from( + value['shadows'].map( + (value) => decodeShadow( + value, + validate: false, + ), + ), + ), + textBaseline: decodeTextBaseline( + value['textBaseline'], + validate: false, + ), + wordSpacing: JsonClass.maybeParseDouble(value['wordSpacing']), ); - - if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/text_direction', - value: value, - validate: validate, - )); - switch (value) { - case 'ltr': - result = TextDirection.ltr; - break; - - case 'rtl': - result = TextDirection.rtl; - break; - } - } } return result; } - /// Decodes the given [value] into a [TextHeightBehavior]. If the value is - /// `null` then `null` will be returned. Otherwise, this expects a Map like - /// value that in JSON would look like: + /// Decodes the given [value] to a [TextTheme]. This expects the [value] to + /// have one of the following structures: /// + /// ## 2018 version /// ```json /// { - /// "applyHeightToFirstAscent": "", - /// "applyHeightToLastDescent": "", - /// "leadingDistribution": "" + /// "bodyText1": "", + /// "bodyText2": "", + /// "button": "", + /// "caption": "", + /// "headline1": "", + /// "headline2": "", + /// "headline3": "", + /// "headline4": "", + /// "headline5": "", + /// "headline6": "", + /// "overline": "", + /// "subtitle1": "", + /// "subtitle2": "" /// } /// ``` - static TextHeightBehavior? decodeTextHeightBehavior( + /// + /// ## 2021 version + /// ```json + /// { + /// "bodyLarge": "", + /// "bodyMedium": "", + /// "bodySmall": "", + /// "displayLarge": "", + /// "displayMedium": "", + /// "displaySmall": "", + /// "headlineLarge": "", + /// "headlineMedium": "", + /// "headlineSmall": "", + /// "labelLarge": "", + /// "labelMedium": "", + /// "labelSmall": "", + /// "titleLarge": "", + /// "titleMedium": "", + /// "titleSmall": "" + /// } + /// ``` + /// + /// See also: + /// * [decodeTextStyle] + static TextTheme? decodeTextTheme( dynamic value, { bool validate = true, }) { - TextHeightBehavior? result; + TextTheme? result; - if (value is TextHeightBehavior) { + if (value is TextTheme) { result = value; } else if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/text_height_behavior', + schemaId: '$_baseSchemaUrl/text_theme', value: value, validate: validate, )); - result = TextHeightBehavior( - applyHeightToFirstAscent: JsonClass.parseBool( - value['applyHeightToLastDescent'], - whenNull: true, + result = TextTheme( + bodyLarge: decodeTextStyle( + value['bodyLarge'] ?? value['bodyText1'], + validate: false, ), - applyHeightToLastDescent: JsonClass.parseBool( - value['applyHeightToLastDescent'], - whenNull: true, + bodyMedium: decodeTextStyle( + value['bodyMedium'] ?? value['bodyText2'], + validate: false, ), - leadingDistribution: decodeTextLeadingDistribution( - value['leadingDistribution'], - validate: false, - ) ?? - TextLeadingDistribution.proportional, - ); - } + bodySmall: decodeTextStyle( + value['bodySmall'] ?? value['caption'], + validate: false, + ), + // bodyText1: @deprecated, + // bodyText2: @deprecated, + // button: @deprecated, + // caption: @deprecated, - return result; - } - - /// Decodes the [value] to a [TextInputAction]. Supported values are: - /// * `continueAction` - /// * `done` - /// * `emergencyCall` - /// * `go` - /// * `join` - /// * `newline` - /// * `next` - /// * `none` - /// * `previous` - /// * `route` - /// * `search` - /// * `send` - /// * `unspecified` - static TextInputAction? decodeTextInputAction( - dynamic value, { - bool validate = true, - }) { - TextInputAction? result; - if (value is TextInputAction) { - result = value; - } else { - _checkSupported( - 'TextInputAction', - [ - 'continueAction', - 'done', - 'emergencyCall', - 'go', - 'join', - 'newline', - 'next', - 'none', - 'previous', - 'route', - 'search', - 'send', - 'unspecified', - ], - value, + displayLarge: decodeTextStyle( + value['displayLarge'] ?? value['headline1'], + validate: false, + ), + displayMedium: decodeTextStyle( + value['displayMedium'] ?? value['headline2'], + validate: false, + ), + displaySmall: decodeTextStyle( + value['displaySmall'] ?? value['headline3'], + validate: false, + ), + // headline1: @deprecated, + // headline2: @deprecated, + // headline3: @deprecated, + // headline4: @deprecated, + // headline5: @deprecated, + // headline6: @deprecated, + headlineLarge: decodeTextStyle( + value['headlineLarge'] ?? value[''], + validate: false, + ), + headlineMedium: decodeTextStyle( + value['headlineMedium'] ?? value['headline4'], + validate: false, + ), + headlineSmall: decodeTextStyle( + value['headlineSmall'] ?? value['headline5'], + validate: false, + ), + labelLarge: decodeTextStyle( + value['labelLarge'] ?? value['button'], + validate: false, + ), + labelMedium: decodeTextStyle( + value['labelMedium'] ?? value[''], + validate: false, + ), + labelSmall: decodeTextStyle( + value['labelSmall'] ?? value['overline'], + validate: false, + ), + // overline: @deprecated, + // subtitle1: @deprecated, + // subtitle2: @deprecated, + titleLarge: decodeTextStyle( + value['titleLarge'] ?? value['headline6'], + validate: false, + ), + titleMedium: decodeTextStyle( + value['titleMedium'] ?? value['subtitle1'], + validate: false, + ), + titleSmall: decodeTextStyle( + value['titleSmall'] ?? value['subtitle2'], + validate: false, + ), ); - - if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/text_input_action', - value: value, - validate: validate, - )); - - switch (value) { - case 'continueAction': - result = TextInputAction.continueAction; - break; - - case 'done': - result = TextInputAction.done; - break; - - case 'emergencyCall': - result = TextInputAction.emergencyCall; - break; - - case 'go': - result = TextInputAction.go; - break; - - case 'join': - result = TextInputAction.join; - break; - - case 'newline': - result = TextInputAction.newline; - break; - - case 'next': - result = TextInputAction.next; - break; - - case 'none': - result = TextInputAction.none; - break; - - case 'previous': - result = TextInputAction.previous; - break; - - case 'route': - result = TextInputAction.route; - break; - - case 'search': - result = TextInputAction.search; - break; - - case 'send': - result = TextInputAction.send; - break; - - case 'unspecified': - result = TextInputAction.unspecified; - break; - } - } } return result; } - /// Decodes the [value] to a [TextInputType]. Supported values are: - /// * `datetime` - /// * `emailAddress` - /// * `multiline` - /// * `name` - /// * `none` - /// * `number` - /// * `phone` - /// * `streetAddress` - /// * `text` - /// * `url` - /// * `visiblePassword` - static TextInputType? decodeTextInputType( + /// Decodes the [value] to a [TextWidthBasis]. Supported values are: + /// * `longestLine` + /// * `parent` + static TextWidthBasis? decodeTextWidthBasis( dynamic value, { bool validate = true, }) { - TextInputType? result; - if (value is TextInputType) { + TextWidthBasis? result; + + if (value is TextWidthBasis) { result = value; } else { _checkSupported( - 'TextInputType', + 'TextWidthBasis', [ - 'datetime', - 'emailAddress', - 'multiline', - 'name', - 'none', - 'number', - 'phone', - 'streetAddress', - 'text', - 'url', - 'visiblePassword', + 'longestLine', + 'parent', ], value, ); if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/text_input_type', + schemaId: '$_baseSchemaUrl/text_width_basis', value: value, validate: validate, )); switch (value) { - case 'datetime': - result = TextInputType.datetime; - break; - - case 'emailAddress': - result = TextInputType.emailAddress; - break; - - case 'multiline': - result = TextInputType.multiline; - break; - - case 'name': - result = TextInputType.name; - break; - - case 'none': - result = TextInputType.none; - break; - - case 'number': - result = TextInputType.number; - break; - - case 'phone': - result = TextInputType.phone; - break; - - case 'streetAddress': - result = TextInputType.streetAddress; - break; - - case 'text': - result = TextInputType.text; - break; - - case 'url': - result = TextInputType.url; + case 'longestLine': + result = TextWidthBasis.longestLine; break; - - case 'visiblePassword': - result = TextInputType.visiblePassword; + case 'parent': + result = TextWidthBasis.parent; break; } } } + return result; } - /// Decodes the [value] to a [TextLeadingDistribution]. Supported values are: - /// * `even` - /// * `proportional` - static TextLeadingDistribution? decodeTextLeadingDistribution( - dynamic value, { - bool validate = true, - }) { - TextLeadingDistribution? result; - if (value is TextLeadingDistribution) { - result = value; - } else { - _checkSupported( - 'TextLeadingDistribution', - [ - 'even', - 'proportional', - ], - value, - ); - - if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/text_leading_distribution', - value: value, - validate: validate, - )); - switch (value) { - case 'even': - result = TextLeadingDistribution.even; - break; - - case 'proportional': - result = TextLeadingDistribution.proportional; - break; - } - } - } - - return result; - } - - /// Decodes the [value] to a [TextOverflow]. Supported values are: - /// * `clip` - /// * `ellipsis` - /// * `fade` - /// * `visible` - static TextOverflow? decodeTextOverflow( - dynamic value, { - bool validate = true, - }) { - TextOverflow? result; - if (value is TextOverflow) { - result = value; - } else { - _checkSupported( - 'TextOverflow', - [ - 'clip', - 'ellipsis', - 'fade', - 'visible', - ], - value, - ); - - if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/text_overflow', - value: value, - validate: validate, - )); - switch (value) { - case 'clip': - result = TextOverflow.clip; - break; - case 'ellipsis': - result = TextOverflow.ellipsis; - break; - case 'fade': - result = TextOverflow.fade; - break; - case 'visible': - result = TextOverflow.visible; - break; - } - } - } - - return result; - } - - /// Decodes the given [value] to an [TextSelectionThemeData]. This expects the - /// given [value] to be of the following structure: + /// Decodes the given [value] to a [ThemeData]. This expects the [value] to + /// have the following structure: /// /// ```json /// { - /// "cursorColor": "", - /// "selectionColor": "", - /// "selectionHandleColor": "" + /// "actionIconTheme": "", + /// "appBarTheme": "", + /// "applyElevationOverlayColor": "", + /// "badgeTheme": "", + /// "bannerTheme": "", + /// "bottomAppBarTheme": "", + /// "bottomSheetTheme": "", + /// "brightness": "", + /// "buttonBarTheme": "", + /// "buttonTheme": "", + /// "canvasColor": "", + /// "cardColor": "", + /// "cardTheme": "", + /// "checkboxTheme": "", + /// "chipTheme": "", + /// "colorScheme": "", + /// "colorSchemeSeed": "", + /// "cupertinoOverrideTheme": "", + /// "datePickerTheme": "", + /// "dataTableTheme": "", + /// "dialogBackgroundColor": "", + /// "dialogTheme": "", + /// "disabledColor": "", + /// "dividerColor": "", + /// "dividerTheme": "", + /// "drawerTheme": "", + /// "dropdownMenuTheme": "", + /// "elevatedButtonTheme": "", + /// "expansionTileTheme": "", + /// "filledButtonTheme": """, + /// "floatingActionButtonTheme": "", + /// "focusColor": "", + /// "fontFamily": "", + /// "fontFamilyFallback": ">", + /// "highlightColor": "", + /// "hintColor": "", + /// "hoverColor": "", + /// "iconButtonTheme": "", + /// "iconTheme": "", + /// "indicatorColor": "", + /// "inputDecorationTheme": "", + /// "listTileTheme": "", + /// "materialTapTargetSize": "", + /// "menuBarTheme": "", + /// "menuButtonTheme": "", + /// "menuTheme": "", + /// "navigationBarTheme": "", + /// "navigationDrawerTheme": "", + /// "navigationRailTheme": "", + /// "outlinedButtonTheme": "", + /// "package": "", + /// "pageTransitionsTheme": "", + /// "platform": "", + /// "popupMenuTheme": "", + /// "primaryColor": "", + /// "primaryColorDark": "", + /// "primaryColorLight": "", + /// "primaryIconTheme": "", + /// "primarySwatch": "", + /// "primaryTextTheme": "", + /// "progressIndicatorTheme": "", + /// "radioTheme": "", + /// "scaffoldBackgroundColor": "", + /// "scrollbarTheme": "", + /// "searchBarTheme": "", + /// "searchViewTheme": "", + /// "secondaryHeaderColor": "", + /// "segmentedButtonTheme": "", + /// "shadowColor": "", + /// "sliderTheme": "", + /// "snackBarTheme": "", + /// "splashColor": "", + /// "splashFactory": "", + /// "switchTheme": "", + /// "tabBarTheme": "", + /// "textButtonTheme": "", + /// "textSelectionTheme": "", + /// "textTheme": "", + /// "timePickerTheme": "", + /// "toggleButtonsTheme": "", + /// "tooltipTheme": "", + /// "typography": "", + /// "unselectedWidgetColor": "", + /// "useMaterial3": "", + /// "visualDensity": "" /// } /// ``` /// /// See also: + /// * [decodeActionIconTheme] + /// * [decodeAppBarTheme] + /// * [decodeBadgeThemeData] + /// * [decodeBottomAppBarTheme] + /// * [decodeBottomNavigationBarThemeData] + /// * [decodeBottomSheetThemeData] + /// * [decodeBrightness] + /// * [decodeButtonBarThemeData] + /// * [decodeButtonThemeData] + /// * [decodeCardTheme] + /// * [decodeCheckboxThemeData] + /// * [decodeChipThemeData] /// * [decodeColor] - static TextSelectionThemeData? decodeTextSelectionThemeData( + /// * [decodeColorScheme] + /// * [decodeDatePickerThemeData] + /// * [decodeDataTableThemeData] + /// * [decodeDialogTheme] + /// * [decodeDividerThemeData] + /// * [decodeDrawerThemeData] + /// * [decodeElevatedButtonThemeData] + /// * [decodeExpansionTileThemeData] + /// * [decodeFilledButtonThemeData] + /// * [decodeFloatingActionButtonThemeData] + /// * [decodeIconButtonThemeData] + /// * [decodeIconThemeData] + /// * [decodeInputDecorationTheme] + /// * [decodeInteractiveInkFeatureFactory] + /// * [decodeListTileThemeData] + /// * [decodeMaterialBannerThemeData] + /// * [decodeMaterialTapTargetSize] + /// * [decodeMenuBarThemeData] + /// * [decodeMenuButtonThemeData] + /// * [decodeMenuThemeData] + /// * [decodeNavigationBarThemeData] + /// * [decodeNavigationDrawerThemeData] + /// * [decodeNavigationRailThemeData] + /// * [decodeOutlinedButtonThemeData] + /// * [decodePageTransitionsTheme] + /// * [decodePopupMenuThemeData] + /// * [decodeProgressIndicatorThemeData] + /// * [decodeRadioThemeData] + /// * [decodeScrollbarThemeData] + /// * [decodeSearchBarThemeData] + /// * [decodeSearchViewThemeData] + /// * [decodeSegmentedButtonThemeData] + /// * [decodeSliderThemeData] + /// * [decodeSnackBarThemeData] + /// * [decodeSwitchThemeData] + /// * [decodeTabBarTheme] + /// * [decodeTargetPlatform] + /// * [decodeTextButtonThemeData] + /// * [decodeTextSelectionThemeData] + /// * [decodeTimePickerThemeData] + /// * [decodeTextStyle] + /// * [decodeToggleButtonsThemeData] + /// * [decodeTypography] + /// * [decodeVisualDensity] + static ThemeData? decodeThemeData( dynamic value, { bool validate = true, }) { - TextSelectionThemeData? result; + ThemeData? result; - if (value is TextSelectionThemeData) { + if (value is ThemeData) { result = value; } else if (value != null) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/text_selection_theme_data', + schemaId: '$_baseSchemaUrl/theme_data', value: value, validate: validate, )); - result = TextSelectionThemeData( - cursorColor: decodeColor( - value['cursorColor'], + result = ThemeData( + // adaptations: @unencodable, + actionIconTheme: decodeActionIconThemeData( + value['actionIconThemeData'], validate: false, ), - selectionColor: decodeColor( - value['selectionColor'], + appBarTheme: decodeAppBarTheme( + value['appBarTheme'], validate: false, ), - selectionHandleColor: decodeColor( - value['selectionHandleColor'], - validate: false, + applyElevationOverlayColor: JsonClass.maybeParseBool( + value['applyElevationOverlayColor'], ), - ); - } - - return result; - } - - /// Decodes a given Map-like [value] into a [TextStyle]. This expects the - /// given [value] to have the following structure: - /// - /// ```json - /// { - /// "children": ">", - /// "locale": "", - /// "mouseCursor": "", - /// "onEnter": "", - /// "onExit": "", - /// "recognizer": "", - /// "semanticsLabel": "", - /// "spellOut": "", - /// "style": "", - /// "text": "" - /// } - /// ``` - /// - /// See Also: - /// * [decodeLocale] - /// * [decodeMouseCursor] - /// * [decodeTextStyle] - static TextSpan? decodeTextSpan( - dynamic value, { - bool validate = true, - }) { - TextSpan? result; - - if (value is TextSpan) { - result = value; - } else if (value is String) { - result = TextSpan(text: value); - } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/text_span', - value: value, - validate: validate, - )); - - result = TextSpan( - children: (value['children'] as List?) - ?.map((e) => decodeTextSpan(e, validate: false)!) - .toList(), - locale: decodeLocale( - value['locale'], + badgeTheme: decodeBadgeThemeData( + value['badgeTheme'], validate: false, ), - mouseCursor: decodeMouseCursor( - value['mouseCursor'], + bannerTheme: decodeMaterialBannerThemeData( + value['bannerTheme'], validate: false, ), - onEnter: value['onEnter'], - onExit: value['onExit'], - recognizer: value['recognizer'], - semanticsLabel: value['semanticsLabel']?.toString(), - spellOut: JsonClass.maybeParseBool(value['spellOut']), - style: decodeTextStyle( - value['style'], + // bottomAppBarColor: @deprecated, + bottomAppBarTheme: decodeBottomAppBarTheme( + value['bottomAppBarTheme'], validate: false, ), - text: value['text']?.toString(), - ); - } - - return result; - } - - /// Decodes a given Map-like [value] into a [TextStyle]. This expects the - /// given [value] to have the following structure: - /// - /// ```json - /// { - /// "backgroundColor": "", - /// "color": "", - /// "decoration": "", - /// "decorationColor": "", - /// "decorationStyle": "", - /// "decorationThickness": "", - /// "fontFamily": "", - /// "fontFamilyFallback": "", - /// "fontFeatures": "", - /// "fontSize": "", - /// "fontStyle": "", - /// "fontWeight": "", - /// "height": "", - /// "inherit": "", - /// "leadingDistribution": "", - /// "letterSpacing": "", - /// "locale": "", - /// "overflow": "", - /// "package": "", - /// "shadows": "", - /// "textBaseline": "", - /// "wordSpacing": "" - /// } - /// ``` - /// - /// See also: - /// * [decodeColor] - /// * [decodeFontFeature] - /// * [decodeFontStyle] - /// * [decodeFontVariation] - /// * [decodeFontWeight] - /// * [decodeLocale] - /// * [decodeShadow] - /// * [decodeTextBaseline] - /// * [decodeTextDecoration] - /// * [decodeTextDecorationStyle] - /// * [decodeTextLeadingDistribution] - /// * [decodeTextOverflow] - static TextStyle? decodeTextStyle( - dynamic value, { - bool validate = true, - }) { - TextStyle? result; - - if (value is TextStyle) { - result = value; - } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/text_style', - value: value, - validate: validate, - )); - result = TextStyle( - // background: @unencodable - backgroundColor: decodeColor( - value['backgroundColor'], + bottomNavigationBarTheme: decodeBottomNavigationBarThemeData( + value['bottomNavigationBarTheme'], validate: false, ), - color: decodeColor( - value['color'], + bottomSheetTheme: decodeBottomSheetThemeData( + value['bottomSheetTheme'], validate: false, ), - decoration: decodeTextDecoration( - value['decoration'], + brightness: decodeBrightness( + value['brightness'], validate: false, ), - decorationColor: decodeColor( - value['decorationColor'], + buttonBarTheme: decodeButtonBarThemeData( + value['buttonBarTheme'], validate: false, ), - decorationStyle: decodeTextDecorationStyle( - value['decorationStyle'], + buttonTheme: decodeButtonThemeData( + value['buttonTheme'], validate: false, ), - decorationThickness: - JsonClass.maybeParseDouble(value['decorationThickness']), - fontFamily: value['fontFamily'], - fontFamilyFallback: value['fontFamilyFallback'] == null - ? null - : List.from(value['fontFamilyFallback']), - fontFeatures: value['fontFeatures'] == null - ? null - : List.from( - value['fontFeatures'].map( - (value) => decodeFontFeature( - value, - validate: false, - ), - ), - ), - fontVariations: (value['fontVariations'] as List?) - ?.map( - (e) => decodeFontVariation( - e, - validate: false, - )!, - ) - .toList(), - fontWeight: decodeFontWeight( - value['fontWeight'], + canvasColor: decodeColor( + value['canvasColor'], validate: false, ), - fontSize: JsonClass.maybeParseDouble(value['fontSize']), - fontStyle: decodeFontStyle( - value['fontStyle'], + cardColor: decodeColor( + value['cardColor'], validate: false, ), - // foreground: @unencodable - height: JsonClass.maybeParseDouble(value['height']), - inherit: JsonClass.parseBool( - value['inherit'], - whenNull: true, + cardTheme: decodeCardTheme( + value['cardTheme'], + validate: false, ), - leadingDistribution: decodeTextLeadingDistribution( - value['leadingDistribution'], + checkboxTheme: decodeCheckboxThemeData( + value['checkboxTheme'], validate: false, ), - letterSpacing: JsonClass.maybeParseDouble(value['letterSpacing']), - locale: decodeLocale( - value['locale'], + chipTheme: decodeChipThemeData( + value['chipTheme'], validate: false, ), - overflow: decodeTextOverflow( - value['overflow'], + colorScheme: decodeColorScheme( + value['colorScheme'], validate: false, ), - package: value['package'], - shadows: value['shadows'] == null - ? null - : List.from( - value['shadows'].map( - (value) => decodeShadow( - value, - validate: false, - ), - ), - ), - textBaseline: decodeTextBaseline( - value['textBaseline'], + colorSchemeSeed: decodeColor( + value['colorSchemeSeed'], validate: false, ), - wordSpacing: JsonClass.maybeParseDouble(value['wordSpacing']), - ); - } - - return result; - } - - /// Decodes the given [value] to a [TextTheme]. This expects the [value] to - /// have one of the following structures: - /// - /// ## 2018 version - /// ```json - /// { - /// "bodyText1": "", - /// "bodyText2": "", - /// "button": "", - /// "caption": "", - /// "headline1": "", - /// "headline2": "", - /// "headline3": "", - /// "headline4": "", - /// "headline5": "", - /// "headline6": "", - /// "overline": "", - /// "subtitle1": "", - /// "subtitle2": "" - /// } - /// ``` - /// - /// ## 2021 version - /// ```json - /// { - /// "bodyLarge": "", - /// "bodyMedium": "", - /// "bodySmall": "", - /// "displayLarge": "", - /// "displayMedium": "", - /// "displaySmall": "", - /// "headlineLarge": "", - /// "headlineMedium": "", - /// "headlineSmall": "", - /// "labelLarge": "", - /// "labelMedium": "", - /// "labelSmall": "", - /// "titleLarge": "", - /// "titleMedium": "", - /// "titleSmall": "" - /// } - /// ``` - /// - /// See also: - /// * [decodeTextStyle] - static TextTheme? decodeTextTheme( - dynamic value, { - bool validate = true, - }) { - TextTheme? result; - - if (value is TextTheme) { - result = value; - } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/text_theme', - value: value, - validate: validate, - )); - result = TextTheme( - bodyLarge: decodeTextStyle( - value['bodyLarge'] ?? value['bodyText1'], + cupertinoOverrideTheme: decodeCupertinoThemeData( + value['cupertinoOverrideTheme'], validate: false, ), - bodyMedium: decodeTextStyle( - value['bodyMedium'] ?? value['bodyText2'], + datePickerTheme: decodeDatePickerThemeData( + value['datePickerThemeData'], validate: false, ), - bodySmall: decodeTextStyle( - value['bodySmall'] ?? value['caption'], + dataTableTheme: decodeDataTableThemeData( + value['dataTableTheme'], validate: false, ), - // bodyText1: @deprecated, - // bodyText2: @deprecated, - // button: @deprecated, - // caption: @deprecated, - - displayLarge: decodeTextStyle( - value['displayLarge'] ?? value['headline1'], + dialogBackgroundColor: decodeColor( + value['dialogBackgroundColor'], validate: false, ), - displayMedium: decodeTextStyle( - value['displayMedium'] ?? value['headline2'], + dialogTheme: decodeDialogTheme( + value['dialogTheme'], validate: false, ), - displaySmall: decodeTextStyle( - value['displaySmall'] ?? value['headline3'], + disabledColor: decodeColor( + value['disabledColor'], validate: false, ), - // headline1: @deprecated, - // headline2: @deprecated, - // headline3: @deprecated, - // headline4: @deprecated, - // headline5: @deprecated, - // headline6: @deprecated, - headlineLarge: decodeTextStyle( - value['headlineLarge'] ?? value[''], + dividerColor: decodeColor( + value['dividerColor'], validate: false, ), - headlineMedium: decodeTextStyle( - value['headlineMedium'] ?? value['headline4'], + dividerTheme: decodeDividerThemeData( + value['dividerTheme'], validate: false, ), - headlineSmall: decodeTextStyle( - value['headlineSmall'] ?? value['headline5'], + drawerTheme: decodeDrawerThemeData( + value['drawerTheme'], validate: false, ), - labelLarge: decodeTextStyle( - value['labelLarge'] ?? value['button'], + dropdownMenuTheme: decodeDropdownMenuThemeData( + value['dropdownMenuTheme'], validate: false, ), - labelMedium: decodeTextStyle( - value['labelMedium'] ?? value[''], + elevatedButtonTheme: decodeElevatedButtonThemeData( + value['elevatedButtonTheme'], validate: false, ), - labelSmall: decodeTextStyle( - value['labelSmall'] ?? value['overline'], + expansionTileTheme: decodeExpansionTileThemeData( + value['expansionTileTheme'], validate: false, ), - // overline: @deprecated, - // subtitle1: @deprecated, - // subtitle2: @deprecated, - titleLarge: decodeTextStyle( - value['titleLarge'] ?? value['headline6'], + // extensions: @unencodable, + filledButtonTheme: decodeFilledButtonThemeData( + value['filledButtonTheme'], validate: false, ), - titleMedium: decodeTextStyle( - value['titleMedium'] ?? value['subtitle1'], + floatingActionButtonTheme: decodeFloatingActionButtonThemeData( + value['floatingActionButtonTheme'], validate: false, ), - titleSmall: decodeTextStyle( - value['titleSmall'] ?? value['subtitle2'], - validate: false, - ), - ); - } - - return result; - } - - /// Decodes the [value] to a [TextWidthBasis]. Supported values are: - /// * `longestLine` - /// * `parent` - static TextWidthBasis? decodeTextWidthBasis( - dynamic value, { - bool validate = true, - }) { - TextWidthBasis? result; - - if (value is TextWidthBasis) { - result = value; - } else { - _checkSupported( - 'TextWidthBasis', - [ - 'longestLine', - 'parent', - ], - value, - ); - - if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/text_width_basis', - value: value, - validate: validate, - )); - switch (value) { - case 'longestLine': - result = TextWidthBasis.longestLine; - break; - case 'parent': - result = TextWidthBasis.parent; - break; - } - } - } - - return result; - } - - /// Decodes the given [value] to a [ThemeData]. This expects the [value] to - /// have the following structure: - /// - /// ```json - /// { - /// "actionIconTheme": "", - /// "appBarTheme": "", - /// "applyElevationOverlayColor": "", - /// "badgeTheme": "", - /// "bannerTheme": "", - /// "bottomAppBarTheme": "", - /// "bottomSheetTheme": "", - /// "brightness": "", - /// "buttonBarTheme": "", - /// "buttonTheme": "", - /// "canvasColor": "", - /// "cardColor": "", - /// "cardTheme": "", - /// "checkboxTheme": "", - /// "chipTheme": "", - /// "colorScheme": "", - /// "colorSchemeSeed": "", - /// "cupertinoOverrideTheme": "", - /// "datePickerTheme": "", - /// "dataTableTheme": "", - /// "dialogBackgroundColor": "", - /// "dialogTheme": "", - /// "disabledColor": "", - /// "dividerColor": "", - /// "dividerTheme": "", - /// "drawerTheme": "", - /// "dropdownMenuTheme": "", - /// "elevatedButtonTheme": "", - /// "expansionTileTheme": "", - /// "filledButtonTheme": """, - /// "floatingActionButtonTheme": "", - /// "focusColor": "", - /// "fontFamily": "", - /// "fontFamilyFallback": ">", - /// "highlightColor": "", - /// "hintColor": "", - /// "hoverColor": "", - /// "iconButtonTheme": "", - /// "iconTheme": "", - /// "indicatorColor": "", - /// "inputDecorationTheme": "", - /// "listTileTheme": "", - /// "materialTapTargetSize": "", - /// "menuBarTheme": "", - /// "menuButtonTheme": "", - /// "menuTheme": "", - /// "navigationBarTheme": "", - /// "navigationDrawerTheme": "", - /// "navigationRailTheme": "", - /// "outlinedButtonTheme": "", - /// "package": "", - /// "pageTransitionsTheme": "", - /// "platform": "", - /// "popupMenuTheme": "", - /// "primaryColor": "", - /// "primaryColorDark": "", - /// "primaryColorLight": "", - /// "primaryIconTheme": "", - /// "primarySwatch": "", - /// "primaryTextTheme": "", - /// "progressIndicatorTheme": "", - /// "radioTheme": "", - /// "scaffoldBackgroundColor": "", - /// "scrollbarTheme": "", - /// "searchBarTheme": "", - /// "searchViewTheme": "", - /// "secondaryHeaderColor": "", - /// "segmentedButtonTheme": "", - /// "shadowColor": "", - /// "sliderTheme": "", - /// "snackBarTheme": "", - /// "splashColor": "", - /// "splashFactory": "", - /// "switchTheme": "", - /// "tabBarTheme": "", - /// "textButtonTheme": "", - /// "textSelectionTheme": "", - /// "textTheme": "", - /// "timePickerTheme": "", - /// "toggleButtonsTheme": "", - /// "tooltipTheme": "", - /// "typography": "", - /// "unselectedWidgetColor": "", - /// "useMaterial3": "", - /// "visualDensity": "" - /// } - /// ``` - /// - /// See also: - /// * [decodeActionIconTheme] - /// * [decodeAppBarTheme] - /// * [decodeBadgeThemeData] - /// * [decodeBottomAppBarTheme] - /// * [decodeBottomNavigationBarThemeData] - /// * [decodeBottomSheetThemeData] - /// * [decodeBrightness] - /// * [decodeButtonBarThemeData] - /// * [decodeButtonThemeData] - /// * [decodeCardTheme] - /// * [decodeCheckboxThemeData] - /// * [decodeChipThemeData] - /// * [decodeColor] - /// * [decodeColorScheme] - /// * [decodeDatePickerThemeData] - /// * [decodeDataTableThemeData] - /// * [decodeDialogTheme] - /// * [decodeDividerThemeData] - /// * [decodeDrawerThemeData] - /// * [decodeElevatedButtonThemeData] - /// * [decodeExpansionTileThemeData] - /// * [decodeFilledButtonThemeData] - /// * [decodeFloatingActionButtonThemeData] - /// * [decodeIconButtonThemeData] - /// * [decodeIconThemeData] - /// * [decodeInputDecorationTheme] - /// * [decodeInteractiveInkFeatureFactory] - /// * [decodeListTileThemeData] - /// * [decodeMaterialBannerThemeData] - /// * [decodeMaterialTapTargetSize] - /// * [decodeMenuBarThemeData] - /// * [decodeMenuButtonThemeData] - /// * [decodeMenuThemeData] - /// * [decodeNavigationBarThemeData] - /// * [decodeNavigationDrawerThemeData] - /// * [decodeNavigationRailThemeData] - /// * [decodeOutlinedButtonThemeData] - /// * [decodePageTransitionsTheme] - /// * [decodePopupMenuThemeData] - /// * [decodeProgressIndicatorThemeData] - /// * [decodeRadioThemeData] - /// * [decodeScrollbarThemeData] - /// * [decodeSearchBarThemeData] - /// * [decodeSearchViewThemeData] - /// * [decodeSegmentedButtonThemeData] - /// * [decodeSliderThemeData] - /// * [decodeSnackBarThemeData] - /// * [decodeSwitchThemeData] - /// * [decodeTabBarTheme] - /// * [decodeTargetPlatform] - /// * [decodeTextButtonThemeData] - /// * [decodeTextSelectionThemeData] - /// * [decodeTimePickerThemeData] - /// * [decodeTextStyle] - /// * [decodeToggleButtonsThemeData] - /// * [decodeTypography] - /// * [decodeVisualDensity] - static ThemeData? decodeThemeData( - dynamic value, { - bool validate = true, - }) { - ThemeData? result; - - if (value is ThemeData) { - result = value; - } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/theme_data', - value: value, - validate: validate, - )); - result = ThemeData( - // adaptations: @unencodable, - actionIconTheme: decodeActionIconThemeData( - value['actionIconThemeData'], - validate: false, - ), - appBarTheme: decodeAppBarTheme( - value['appBarTheme'], - validate: false, - ), - applyElevationOverlayColor: JsonClass.maybeParseBool( - value['applyElevationOverlayColor'], - ), - badgeTheme: decodeBadgeThemeData( - value['badgeTheme'], - validate: false, - ), - bannerTheme: decodeMaterialBannerThemeData( - value['bannerTheme'], - validate: false, - ), - // bottomAppBarColor: @deprecated, - bottomAppBarTheme: decodeBottomAppBarTheme( - value['bottomAppBarTheme'], - validate: false, - ), - bottomNavigationBarTheme: decodeBottomNavigationBarThemeData( - value['bottomNavigationBarTheme'], - validate: false, - ), - bottomSheetTheme: decodeBottomSheetThemeData( - value['bottomSheetTheme'], - validate: false, - ), - brightness: decodeBrightness( - value['brightness'], - validate: false, - ), - buttonBarTheme: decodeButtonBarThemeData( - value['buttonBarTheme'], - validate: false, - ), - buttonTheme: decodeButtonThemeData( - value['buttonTheme'], - validate: false, - ), - canvasColor: decodeColor( - value['canvasColor'], - validate: false, - ), - cardColor: decodeColor( - value['cardColor'], - validate: false, - ), - cardTheme: decodeCardTheme( - value['cardTheme'], - validate: false, - ), - checkboxTheme: decodeCheckboxThemeData( - value['checkboxTheme'], - validate: false, - ), - chipTheme: decodeChipThemeData( - value['chipTheme'], - validate: false, - ), - colorScheme: decodeColorScheme( - value['colorScheme'], - validate: false, - ), - colorSchemeSeed: decodeColor( - value['colorSchemeSeed'], - validate: false, - ), - cupertinoOverrideTheme: decodeCupertinoThemeData( - value['cupertinoOverrideTheme'], - validate: false, - ), - datePickerTheme: decodeDatePickerThemeData( - value['datePickerThemeData'], - validate: false, - ), - dataTableTheme: decodeDataTableThemeData( - value['dataTableTheme'], - validate: false, - ), - dialogBackgroundColor: decodeColor( - value['dialogBackgroundColor'], - validate: false, - ), - dialogTheme: decodeDialogTheme( - value['dialogTheme'], - validate: false, - ), - disabledColor: decodeColor( - value['disabledColor'], - validate: false, - ), - dividerColor: decodeColor( - value['dividerColor'], - validate: false, - ), - dividerTheme: decodeDividerThemeData( - value['dividerTheme'], - validate: false, - ), - drawerTheme: decodeDrawerThemeData( - value['drawerTheme'], - validate: false, - ), - dropdownMenuTheme: decodeDropdownMenuThemeData( - value['dropdownMenuTheme'], - validate: false, - ), - elevatedButtonTheme: decodeElevatedButtonThemeData( - value['elevatedButtonTheme'], - validate: false, - ), - expansionTileTheme: decodeExpansionTileThemeData( - value['expansionTileTheme'], - validate: false, - ), - // extensions: @unencodable, - filledButtonTheme: decodeFilledButtonThemeData( - value['filledButtonTheme'], - validate: false, - ), - floatingActionButtonTheme: decodeFloatingActionButtonThemeData( - value['floatingActionButtonTheme'], - validate: false, - ), - focusColor: decodeColor( - value['focusColor'], + focusColor: decodeColor( + value['focusColor'], validate: false, ), fontFamily: value['fontFamily'], @@ -13911,581 +12494,1988 @@ class ThemeDecoder { return result; } - /// Decodes the [value] to a [TileMode]. Supported values are: - /// * `clamp` - /// * `decal` - /// * `mirror` - /// * `repeated` - static TileMode? decodeTileMode( + /// Decodes the [value] to a [TileMode]. Supported values are: + /// * `clamp` + /// * `decal` + /// * `mirror` + /// * `repeated` + static TileMode? decodeTileMode( + dynamic value, { + bool validate = true, + }) { + TileMode? result; + if (value is TileMode) { + result = value; + } else { + _checkSupported( + 'TileMode', + [ + 'clamp', + 'decal', + 'mirror', + 'repeated', + ], + value, + ); + + if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/tile_mode', + value: value, + validate: validate, + )); + switch (value) { + case 'clamp': + result = TileMode.clamp; + break; + + case 'decal': + result = TileMode.decal; + break; + + case 'mirror': + result = TileMode.mirror; + break; + + case 'repeated': + result = TileMode.repeated; + break; + } + } + } + + return result; + } + + /// Decodes the given [value] to a [TimePickerThemeData]. This expects the + /// [value] to have the following structure: + /// + /// ```json + /// { + /// "backgroundColor": "", + /// "cancelButtonStyle": "", + /// "confirmButtonStyle": "", + /// "dayPeriodBorderSide": "", + /// "dayPeriodColor": "", + /// "dayPeriodShape": "", + /// "dayPeriodTextColor": "", + /// "dayPeriodTextStyle": "", + /// "dialBackgroundColor": "", + /// "dialHandColor": "", + /// "dialTextColor": "", + /// "dialTextStyle": "", + /// "elevation": "", + /// "entryModeIconColor": "", + /// "helpTextStyle": "", + /// "hourMinuteColor": "", + /// "hourMinuteShape": "", + /// "hourMinuteTextColor": "", + /// "hourMinuteTextStyle": "", + /// "inputDecorationTheme": "", + /// "padding": "", + /// "shape": "" + /// } + /// ``` + /// + /// See also: + /// * [decodeBorderSide] + /// * [decodeButtonStyle] + /// * [decodeColor] + /// * [decodeEdgeInsetsGeometry] + /// * [decodeInputDecorationTheme] + /// * [decodeWidgetStateColor] + /// * [decodeShapeBorder] + /// * [decodeTextStyle] + static TimePickerThemeData? decodeTimePickerThemeData( + dynamic value, { + bool validate = true, + }) { + TimePickerThemeData? result; + + if (value is TimePickerThemeData) { + result = value; + } else if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/time_picker_theme_data', + value: value, + validate: validate, + )); + + result = TimePickerThemeData( + backgroundColor: decodeColor( + value['backgroundColor'], + validate: false, + ), + cancelButtonStyle: decodeButtonStyle( + value['cancelButtonStyle'], + validate: false, + ), + confirmButtonStyle: decodeButtonStyle( + value['confirmButtonStyle'], + validate: false, + ), + dayPeriodBorderSide: decodeBorderSide( + value['dayPeriodBorderSide'], + validate: false, + ), + dayPeriodColor: decodeWidgetStateColor( + value['dayPeriodColor'], + validate: false, + ), + dayPeriodShape: value['dayPeriodShape'] == null + ? null + : decodeShapeBorder( + value['dayPeriodShape'], + validate: false, + ) as OutlinedBorder?, + dayPeriodTextColor: decodeColor( + value['dayPeriodTextColor'], + validate: false, + ), + dayPeriodTextStyle: decodeTextStyle( + value['dayPeriodTextStyle'], + validate: false, + ), + dialBackgroundColor: decodeColor( + value['dialBackgroundColor'], + validate: false, + ), + dialHandColor: decodeColor( + value['dialHandColor'], + validate: false, + ), + dialTextColor: decodeColor( + value['dialTextColor'], + validate: false, + ), + dialTextStyle: decodeTextStyle( + value['dialTextStyle'], + validate: false, + ), + elevation: JsonClass.maybeParseDouble(value['elevation']), + entryModeIconColor: decodeColor( + value['entryModeIconColor'], + validate: false, + ), + helpTextStyle: decodeTextStyle( + value['helpTextStyle'], + validate: false, + ), + hourMinuteColor: decodeColor( + value['hourMinuteColor'], + validate: false, + ), + hourMinuteShape: decodeShapeBorder( + value['hourMinuteShape'], + validate: false, + ), + hourMinuteTextColor: decodeColor( + value['hourMinuteTextColor'], + validate: false, + ), + hourMinuteTextStyle: decodeTextStyle( + value['hourMinuteTextStyle'], + validate: false, + ), + inputDecorationTheme: decodeInputDecorationTheme( + value['inputDecorationTheme'], + validate: false, + ), + padding: decodeEdgeInsetsGeometry(value['padding'], validate: false), + shape: decodeShapeBorder( + value['shape'], + validate: false, + ), + ); + } + + return result; + } + + /// Decodes the given [value] to a [ToggleButtonsThemeData]. This expects the + /// [value] to have the following structure: + /// + /// ```json + /// { + /// "borderColor": "", + /// "borderRadius": "", + /// "borderWidth": "", + /// "color": "", + /// "constraints": "", + /// "disabledBorderColor": "", + /// "disabledColor": "", + /// "fillColor": "", + /// "focusColor": "", + /// "highlightColor": "", + /// "hoverColor": "", + /// "selectedBorderColor": "", + /// "selectedColor": "", + /// "splashColor": "", + /// "textStyle": "" + /// } + /// ``` + /// + /// See also: + /// * [decodeBorderRadius] + /// * [decodeBoxConstraints] + /// * [decodeColor] + /// * [decodeTextStyle] + static ToggleButtonsThemeData? decodeToggleButtonsThemeData( + dynamic value, { + bool validate = true, + }) { + ToggleButtonsThemeData? result; + + if (value is ToggleButtonsThemeData) { + result = value; + } else if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/toggle_buttons_theme_data', + value: value, + validate: validate, + )); + + result = ToggleButtonsThemeData( + borderColor: decodeColor( + value['borderColor'], + validate: false, + ), + borderRadius: decodeBorderRadius( + value['borderRadius'], + validate: false, + ), + borderWidth: JsonClass.maybeParseDouble(value['borderWidth']), + color: decodeColor( + value['color'], + validate: false, + ), + constraints: decodeBoxConstraints( + value['constraints'], + validate: false, + ), + disabledBorderColor: decodeColor( + value['disabledBorderColor'], + validate: false, + ), + disabledColor: decodeColor( + value['disabledColor'], + validate: false, + ), + fillColor: decodeColor( + value['fillColor'], + validate: false, + ), + focusColor: decodeColor( + value['focusColor'], + validate: false, + ), + highlightColor: decodeColor( + value['highlightColor'], + validate: false, + ), + hoverColor: decodeColor( + value['hoverColor'], + validate: false, + ), + selectedBorderColor: decodeColor( + value['selectedBorderColor'], + validate: false, + ), + selectedColor: decodeColor( + value['selectedColor'], + validate: false, + ), + splashColor: decodeColor( + value['splashColor'], + validate: false, + ), + textStyle: decodeTextStyle( + value['textStyle'], + validate: false, + ), + ); + } + + return result; + } + + /// Decodes the given [value] to a [TooltipThemeData]. This expects the + /// [value] to have the following structure: + /// + /// ```json + /// { + /// "enableFeedback": "", + /// "excludeFromSemantics": "", + /// "height": "", + /// "margin": "", + /// "padding": "", + /// "preferBelow": "" + /// "showDuration": "", + /// "textAlign": "", + /// "textStyle": "", + /// "verticalOffset": "", + /// "waitDuration": "" + /// } + /// ``` + /// + /// See also: + /// * [decodeEdgeInsetsGeometry] + /// * [decodeTextAlign] + /// * [decodeTextStyle] + /// * [decodeTooltipTriggerMode] + static TooltipThemeData? decodeTooltipThemeData( + dynamic value, { + bool validate = true, + }) { + TooltipThemeData? result; + + if (value is TooltipThemeData) { + result = value; + } else if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/tooltip_theme_data', + value: value, + validate: validate, + )); + assert( + value['decoration'] == null, + 'TooltipThemeData.decoration is not supported', + ); + result = TooltipThemeData( + // decoration: @unencodable + enableFeedback: JsonClass.maybeParseBool(value['enableFeedback']), + excludeFromSemantics: JsonClass.maybeParseBool( + value['excludeFromSemantics'], + ), + height: JsonClass.maybeParseDouble(value['height']), + margin: decodeEdgeInsetsGeometry( + value['margin'], + validate: false, + ), + padding: decodeEdgeInsetsGeometry( + value['padding'], + validate: false, + ), + preferBelow: JsonClass.maybeParseBool(value['preferBelow']), + showDuration: JsonClass.maybeParseDurationFromMillis( + value['showDuration'], + ), + textAlign: decodeTextAlign( + value['textAlign'], + validate: false, + ), + textStyle: decodeTextStyle( + value['textStyle'], + validate: false, + ), + triggerMode: decodeTooltipTriggerMode( + value['triggerMode'], + validate: false, + ), + verticalOffset: JsonClass.maybeParseDouble(value['verticalOffset']), + waitDuration: + JsonClass.maybeParseDurationFromMillis(value['waitDuration']), + ); + } + + return result; + } + + /// Decodes the [value] to a [TooltipTriggerMode]. Supported values are: + /// * `longPress` + /// * `manual` + /// * `tap` + static TooltipTriggerMode? decodeTooltipTriggerMode( + dynamic value, { + bool validate = true, + }) { + TooltipTriggerMode? result; + + if (value is TooltipTriggerMode) { + result = value; + } else if (value != null) { + _checkSupported( + 'TooltipTriggerMode', + [ + 'longPress', + 'manual', + 'tap', + ], + value, + ); + + switch (value) { + case 'longPress': + result = TooltipTriggerMode.longPress; + break; + + case 'manual': + result = TooltipTriggerMode.manual; + break; + + case 'tap': + result = TooltipTriggerMode.tap; + break; + } + } + + return result; + } + + /// Decodes the given [value] to a [Typography]. This expects the [value] to + /// have the following structure: + /// + /// ```json + /// { + /// "black": "", + /// "dense": "", + /// "englishLike": "", + /// "platform": "", + /// "tall": "", + /// "white": "", + /// } + /// ``` + /// + /// See also: + /// * [decodeTargetPlatform] + /// * [decodeTextTheme] + static Typography? decodeTypography( + dynamic value, { + bool validate = true, + }) { + Typography? result; + + if (value is Typography) { + result = value; + } else if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/typography', + value: value, + validate: validate, + )); + result = Typography.material2018( + black: decodeTextTheme( + value['black'], + validate: false, + ), + dense: decodeTextTheme( + value['dense'], + validate: false, + ), + englishLike: decodeTextTheme( + value['englishLike'], + validate: false, + ), + platform: decodeTargetPlatform( + value['platform'], + validate: false, + ), + tall: decodeTextTheme( + value['tall'], + validate: false, + ), + white: decodeTextTheme( + value['white'], + validate: false, + ), + ); + } + + return result; + } + + /// Decodes the [value] to a [VerticalDirection]. Supported values are: + /// * `down` + /// * `up` + static VerticalDirection? decodeVerticalDirection( + dynamic value, { + bool validate = true, + }) { + VerticalDirection? result; + if (value is VerticalDirection) { + result = value; + } else { + _checkSupported( + 'VerticalDirection', + [ + 'down', + 'up', + ], + value, + ); + + if (value != null) { + switch (value) { + case 'down': + result = VerticalDirection.down; + break; + case 'up': + result = VerticalDirection.up; + break; + } + } + } + + return result; + } + + /// Decodes the [value] to a [VisualDensity]. Supported values are: + /// * `adaptivePlatformDensity` + /// * `comfortable` + /// * `compact` + /// * `standard` + static VisualDensity? decodeVisualDensity( + dynamic value, { + bool validate = true, + }) { + VisualDensity? result; + if (value is VisualDensity) { + result = value; + } else { + _checkSupported( + 'VisualDensity', + [ + 'adaptivePlatformDensity', + 'comfortable', + 'compact', + 'standard', + ], + value, + ); + + if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/visual_density', + value: value, + validate: validate, + )); + switch (value) { + case 'adaptivePlatformDensity': + result = VisualDensity.adaptivePlatformDensity; + break; + + case 'comfortable': + result = VisualDensity.comfortable; + break; + + case 'compact': + result = VisualDensity.compact; + break; + + case 'standard': + result = VisualDensity.standard; + break; + } + } + } + + return result; + } + + /// Decodes a [value] into a [WidgetStateColor]. If the value is a + /// [String] then the value will be used for all states. + /// + /// Alternatively, if the [value] is a [Map] then this expects the following + /// format: + /// + /// ```json + /// { + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "" + /// } + /// ``` + /// + /// The "empty" will be used for when any other value is missing. + static WidgetStateColor? decodeWidgetStateColor( + dynamic value, { + bool validate = true, + }) { + WidgetStateColor? result; + + if (value is WidgetStateColor) { + result = value; + } else if (value is Color) { + result = WidgetStateColor.resolveWith((_) => value); + } else if (value != null) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/widget_state_color', + value: value, + validate: validate, + )); + + result = WidgetStateColor.resolveWith((states) { + Color? result; + + if (value is String) { + result = decodeColor(value, validate: false); + } else if (value is Color) { + result = value; + } else if (states.contains(WidgetState.disabled)) { + result = decodeColor( + value['disabled'], + validate: false, + ); + } else if (states.contains(WidgetState.dragged)) { + result = decodeColor( + value['dragged'], + validate: false, + ); + } else if (states.contains(WidgetState.error)) { + result = decodeColor( + value['error'], + validate: false, + ); + } else if (states.contains(WidgetState.focused)) { + result = decodeColor( + value['focused'], + validate: false, + ); + } else if (states.contains(WidgetState.hovered)) { + result = decodeColor( + value['hovered'], + validate: false, + ); + } else if (states.contains(WidgetState.pressed)) { + result = decodeColor( + value['pressed'], + validate: false, + ); + } else if (states.contains(WidgetState.scrolledUnder)) { + result = decodeColor( + value['scrolledUnder'], + validate: false, + ); + } else if (states.contains(WidgetState.selected)) { + result = decodeColor( + value['selected'], + validate: false, + ); + } + + result ??= decodeColor( + value['empty'], + validate: false, + ); + + if (result == null) { + throw Exception( + 'Unable to decode required Color for WidgetStateColor for state: $states and no "empty" value exists.', + ); + } + + return result; + }); + } + return result; + } + + /// Decodes a [value] into a [double] based [WidgetStateProperty]. This + /// accepts a [double] or a [String] which will be resolved for all states. + /// + /// Alternatively, if the [value] is a [Map] then this expects the following + /// format: + /// + /// ```json + /// { + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "" + /// } + /// ``` + static WidgetStateProperty? decodeWidgetStatePropertyBool( + dynamic value, { + bool validate = true, + }) { + WidgetStateProperty? result; + + if (value is WidgetStateProperty) { + result = value; + } else if (value != null) { + if (value is int || value is double || value is bool || value is String) { + result = WidgetStateProperty.all(JsonClass.parseBool(value)); + } else if (value is Map) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/widget_state_property_bool', + value: value, + validate: validate, + )); + + result = MapWidgetStateProperty.resolveWith((states) { + bool? result; + if (states.contains(WidgetState.disabled)) { + result = JsonClass.maybeParseBool(value['disabled']); + } else if (states.contains(WidgetState.dragged)) { + result = JsonClass.maybeParseBool(value['dragged']); + } else if (states.contains(WidgetState.error)) { + result = JsonClass.maybeParseBool(value['error']); + } else if (states.contains(WidgetState.focused)) { + result = JsonClass.maybeParseBool(value['focused']); + } else if (states.contains(WidgetState.hovered)) { + result = JsonClass.maybeParseBool(value['hovered']); + } else if (states.contains(WidgetState.pressed)) { + result = JsonClass.maybeParseBool(value['pressed']); + } else if (states.contains(WidgetState.scrolledUnder)) { + result = JsonClass.maybeParseBool(value['scrolledUnder']); + } else if (states.contains(WidgetState.selected)) { + result = JsonClass.maybeParseBool(value['selected']); + } else { + result = JsonClass.maybeParseBool(value['empty']); + } + + return result; + }); + } else { + result = WidgetStateProperty.all(value); + } + } + return result; + } + + /// Decodes a [value] into a [BorderSide] based [WidgetStateProperty]. This + /// accepts a [BorderSide] or a [String] which will be resolved for all + /// states. + /// + /// Alternatively, if the [value] is a [Map] then this expects the following + /// format: + /// + /// ```json + /// { + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "" + /// } + /// ``` + /// + /// See also: + /// * [decodeBorderSide] + static WidgetStateProperty? decodeWidgetStatePropertyBorderSide( + dynamic value, { + bool validate = true, + }) { + WidgetStateProperty? result; + + if (value is WidgetStateProperty) { + result = value; + } else if (value != null) { + if (value is BorderSide) { + result = WidgetStateProperty.all(value); + } else if (value is String) { + result = WidgetStateProperty.all( + decodeBorderSide( + value, + validate: false, + ), + ); + } else if (value is Map) { + final testValues = [ + 'disabled', + 'dragged', + 'empty', + 'error', + 'focused', + 'hovered', + 'pressed', + 'scrolledUnder', + 'selected', + ]; + + var isMsp = false; + for (var key in value.keys) { + if (testValues.contains(key)) { + isMsp = true; + break; + } + } + + if (isMsp != true) { + result = WidgetStateProperty.all( + decodeBorderSide( + value, + validate: false, + ), + ); + } else { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/widget_state_property_border_side', + value: value, + validate: validate, + )); + + result = MapWidgetStateProperty.resolveWith((states) { + BorderSide? result; + if (states.contains(WidgetState.disabled)) { + result = decodeBorderSide( + value['disabled'], + validate: false, + ); + } else if (states.contains(WidgetState.dragged)) { + result = decodeBorderSide( + value['dragged'], + validate: false, + ); + } else if (states.contains(WidgetState.error)) { + result = decodeBorderSide( + value['error'], + validate: false, + ); + } else if (states.contains(WidgetState.focused)) { + result = decodeBorderSide( + value['focused'], + validate: false, + ); + } else if (states.contains(WidgetState.hovered)) { + result = decodeBorderSide( + value['hovered'], + validate: false, + ); + } else if (states.contains(WidgetState.pressed)) { + result = decodeBorderSide( + value['pressed'], + validate: false, + ); + } else if (states.contains(WidgetState.scrolledUnder)) { + result = decodeBorderSide( + value['scrolledUnder'], + validate: false, + ); + } else if (states.contains(WidgetState.selected)) { + result = decodeBorderSide( + value['selected'], + validate: false, + ); + } else { + result = decodeBorderSide( + value['empty'], + validate: false, + ); + } + + return result; + }); + } + } else { + result = WidgetStateProperty.all(value); + } + } + return result; + } + + /// Decodes a [value] into a [Color] based [WidgetStateProperty]. This + /// accepts a [Color] or a [String] which will be resolved for all states. + /// + /// Alternatively, if the [value] is a [Map] then this expects the following + /// format: + /// + /// ```json + /// { + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "" + /// } + /// ``` + /// + /// See also: + /// * [decodeColor] + static WidgetStateProperty? decodeWidgetStatePropertyColor( + dynamic value, { + bool validate = true, + }) { + WidgetStateProperty? result; + + if (value is WidgetStateProperty) { + result = value; + } else if (value != null) { + if (value is Color) { + result = WidgetStateProperty.all(value); + } else if (value is String) { + result = WidgetStateProperty.all(decodeColor( + value, + validate: false, + )); + } else if (value is Map) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/widget_state_property_color', + value: value, + validate: validate, + )); + + result = MapWidgetStateProperty.resolveWith((states) { + Color? result; + if (states.contains(WidgetState.disabled)) { + result = decodeColor( + value['disabled'], + validate: false, + ); + } else if (states.contains(WidgetState.dragged)) { + result = decodeColor( + value['dragged'], + validate: false, + ); + } else if (states.contains(WidgetState.error)) { + result = decodeColor( + value['error'], + validate: false, + ); + } else if (states.contains(WidgetState.focused)) { + result = decodeColor( + value['focused'], + validate: false, + ); + } else if (states.contains(WidgetState.pressed)) { + result = decodeColor( + value['pressed'], + validate: false, + ); + } else if (states.contains(WidgetState.hovered)) { + result = decodeColor( + value['hovered'], + validate: false, + ); + } else if (states.contains(WidgetState.scrolledUnder)) { + result = decodeColor( + value['scrolledUnder'], + validate: false, + ); + } else if (states.contains(WidgetState.selected)) { + result = decodeColor( + value['selected'], + validate: false, + ); + } else { + result = decodeColor( + value['empty'], + validate: false, + ); + } + + return result; + }); + } else { + result = WidgetStateProperty.all(value); + } + } + return result; + } + + /// Decodes a [value] into a [double] based [WidgetStateProperty]. This + /// accepts a [double] or a [String] which will be resolved for all states. + /// + /// Alternatively, if the [value] is a [Map] then this expects the following + /// format: + /// + /// ```json + /// { + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "" + /// } + /// ``` + static WidgetStateProperty? decodeWidgetStatePropertyDouble( + dynamic value, { + bool validate = true, + }) { + WidgetStateProperty? result; + + if (value is WidgetStateProperty) { + result = value; + } else if (value != null) { + if (value is int) { + result = WidgetStateProperty.all(value.toDouble()); + } else if (value is double) { + result = WidgetStateProperty.all(value); + } else if (value is String) { + result = WidgetStateProperty.all( + JsonClass.maybeParseDouble(value), + ); + } else if (value is Map) { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/widget_state_property_double', + value: value, + validate: validate, + )); + + result = MapWidgetStateProperty.resolveWith((states) { + double? result; + if (states.contains(WidgetState.disabled)) { + result = JsonClass.maybeParseDouble(value['disabled']); + } else if (states.contains(WidgetState.dragged)) { + result = JsonClass.maybeParseDouble(value['dragged']); + } else if (states.contains(WidgetState.error)) { + result = JsonClass.maybeParseDouble(value['error']); + } else if (states.contains(WidgetState.focused)) { + result = JsonClass.maybeParseDouble(value['focused']); + } else if (states.contains(WidgetState.hovered)) { + result = JsonClass.maybeParseDouble(value['hovered']); + } else if (states.contains(WidgetState.pressed)) { + result = JsonClass.maybeParseDouble(value['pressed']); + } else if (states.contains(WidgetState.scrolledUnder)) { + result = JsonClass.maybeParseDouble(value['scrolledUnder']); + } else if (states.contains(WidgetState.selected)) { + result = JsonClass.maybeParseDouble(value['selected']); + } else { + result = JsonClass.maybeParseDouble(value['empty']); + } + + return result; + }); + } else { + result = WidgetStateProperty.all(value); + } + } + return result; + } + + /// Decodes a [value] into a [EdgeInsetsGeometry] based + /// [WidgetStateProperty]. + /// + /// If the value is a [String], [double], or [int] then this will parse the + /// number and pass it to [EdgeInsets.all] for each state. + /// + /// If the value is an array with two entities, this calls + /// [EdgeInsets.symmetric] with the first element passed as the horizontal and + /// the second as the vertical. + /// + /// If the value is an array with four entities, this calls + /// [EdgeInsets.fromLTRB] passing each element in order. + /// + /// The value may be a [Map] in the following format: + /// ```json + /// { + /// "bottom": "", + /// "left": "", + /// "right": "", + /// "top": "" + /// } + /// ``` + /// + /// Finally, the [value] may be a [Map] in the following format: + /// + /// ```json + /// { + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "" + /// } + /// ``` + /// + /// See also: + /// * [decodeEdgeInsetsGeometry] + static WidgetStateProperty? + decodeWidgetStatePropertyEdgeInsetsGeometry( + dynamic value, { + bool validate = true, + }) { + WidgetStateProperty? result; + + if (value is WidgetStateProperty) { + result = value; + } else if (value != null) { + if (value is EdgeInsetsGeometry) { + result = WidgetStateProperty.all(value); + } else if (value is String || value is List || value is int) { + result = WidgetStateProperty.all( + decodeEdgeInsetsGeometry( + value, + validate: false, + ), + ); + } else if (value is Map) { + final testValues = [ + 'disabled', + 'dragged', + 'empty', + 'error', + 'focused', + 'hovered', + 'pressed', + 'scrolledUnder', + 'selected', + ]; + + var isMsp = false; + for (var key in value.keys) { + if (testValues.contains(key)) { + isMsp = true; + break; + } + } + + if (isMsp != true) { + result = WidgetStateProperty.all( + decodeEdgeInsetsGeometry( + value, + validate: false, + ), + ); + } else { + assert(SchemaValidator.validate( + schemaId: + '$_baseSchemaUrl/widget_state_property_edge_insets_geometry', + value: value, + validate: validate, + )); + + result = MapWidgetStateProperty.resolveWith((states) { + EdgeInsetsGeometry? result; + if (states.contains(WidgetState.disabled)) { + result = decodeEdgeInsetsGeometry( + value['disabled'], + validate: false, + ); + } else if (states.contains(WidgetState.dragged)) { + result = decodeEdgeInsetsGeometry( + value['dragged'], + validate: false, + ); + } else if (states.contains(WidgetState.error)) { + result = decodeEdgeInsetsGeometry( + value['error'], + validate: false, + ); + } else if (states.contains(WidgetState.focused)) { + result = decodeEdgeInsetsGeometry( + value['focused'], + validate: false, + ); + } else if (states.contains(WidgetState.hovered)) { + result = decodeEdgeInsetsGeometry( + value['hovered'], + validate: false, + ); + } else if (states.contains(WidgetState.pressed)) { + result = decodeEdgeInsetsGeometry( + value['pressed'], + validate: false, + ); + } else if (states.contains(WidgetState.scrolledUnder)) { + result = decodeEdgeInsetsGeometry( + value['scrolledUnder'], + validate: false, + ); + } else if (states.contains(WidgetState.selected)) { + result = decodeEdgeInsetsGeometry( + value['selected'], + validate: false, + ); + } else { + result = decodeEdgeInsetsGeometry( + value['empty'], + validate: false, + ); + } + + return result; + }); + } + } else { + result = WidgetStateProperty.all(value); + } + } + return result; + } + + /// Decodes a [value] into a [Icon] based [WidgetStateProperty]. This + /// accepts a [Icon] or a [String] which will be resolved for all states. + /// + /// Alternatively, if the [value] is a [Map] then this expects the following + /// format: + /// + /// ```json + /// { + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "" + /// } + /// ``` + /// + /// See also: + /// * [decodeIconData] + static WidgetStateProperty? decodeWidgetStatePropertyIcon( dynamic value, { bool validate = true, }) { - TileMode? result; - if (value is TileMode) { - result = value; - } else { - _checkSupported( - 'TileMode', - [ - 'clamp', - 'decal', - 'mirror', - 'repeated', - ], - value, - ); + WidgetStateProperty? result; - if (value != null) { + if (value is WidgetStateProperty) { + result = value; + } else if (value != null) { + if (value is Icon) { + result = WidgetStateProperty.all(value); + } else if (value is IconData) { + result = WidgetStateProperty.all(Icon(value)); + } else if (value is Map) { assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/tile_mode', + schemaId: '$_baseSchemaUrl/widget_state_property_icon', value: value, validate: validate, )); - switch (value) { - case 'clamp': - result = TileMode.clamp; - break; - - case 'decal': - result = TileMode.decal; - break; - case 'mirror': - result = TileMode.mirror; - break; + result = MapWidgetStateProperty.resolveWith((states) { + Icon? result; + if (states.contains(WidgetState.disabled)) { + result = decodeIcon( + value['disabled'], + validate: false, + ); + } else if (states.contains(WidgetState.dragged)) { + result = decodeIcon( + value['dragged'], + validate: false, + ); + } else if (states.contains(WidgetState.error)) { + result = decodeIcon( + value['error'], + validate: false, + ); + } else if (states.contains(WidgetState.focused)) { + result = decodeIcon( + value['focused'], + validate: false, + ); + } else if (states.contains(WidgetState.pressed)) { + result = decodeIcon( + value['pressed'], + validate: false, + ); + } else if (states.contains(WidgetState.hovered)) { + result = decodeIcon( + value['hovered'], + validate: false, + ); + } else if (states.contains(WidgetState.scrolledUnder)) { + result = decodeIcon( + value['scrolledUnder'], + validate: false, + ); + } else if (states.contains(WidgetState.selected)) { + result = decodeIcon( + value['selected'], + validate: false, + ); + } else { + result = decodeIcon( + value['empty'], + validate: false, + ); + } - case 'repeated': - result = TileMode.repeated; - break; - } + return result; + }); + } else { + result = WidgetStateProperty.all(value); } } - return result; } - /// Decodes the given [value] to a [TimePickerThemeData]. This expects the - /// [value] to have the following structure: + /// Decodes a [value] into a [IconThemeData] based [WidgetStateProperty]. + /// This accepts a [IconThemeData] or a [String] which will be resolved for + /// all states. + /// + /// Alternatively, if the [value] is a [Map] then this expects the following + /// format: /// /// ```json /// { - /// "backgroundColor": "", - /// "cancelButtonStyle": "", - /// "confirmButtonStyle": "", - /// "dayPeriodBorderSide": "", - /// "dayPeriodColor": "", - /// "dayPeriodShape": "", - /// "dayPeriodTextColor": "", - /// "dayPeriodTextStyle": "", - /// "dialBackgroundColor": "", - /// "dialHandColor": "", - /// "dialTextColor": "", - /// "dialTextStyle": "", - /// "elevation": "", - /// "entryModeIconColor": "", - /// "helpTextStyle": "", - /// "hourMinuteColor": "", - /// "hourMinuteShape": "", - /// "hourMinuteTextColor": "", - /// "hourMinuteTextStyle": "", - /// "inputDecorationTheme": "", - /// "padding": "", - /// "shape": "" + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "" /// } /// ``` /// /// See also: - /// * [decodeBorderSide] - /// * [decodeButtonStyle] - /// * [decodeColor] - /// * [decodeEdgeInsetsGeometry] - /// * [decodeInputDecorationTheme] - /// * [decodeMaterialStateColor] - /// * [decodeShapeBorder] - /// * [decodeTextStyle] - static TimePickerThemeData? decodeTimePickerThemeData( + /// * [decodeIconThemeData] + static WidgetStateProperty? + decodeWidgetStatePropertyIconThemeData( dynamic value, { bool validate = true, }) { - TimePickerThemeData? result; + WidgetStateProperty? result; - if (value is TimePickerThemeData) { + if (value is WidgetStateProperty) { result = value; } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/time_picker_theme_data', - value: value, - validate: validate, - )); + if (value is IconThemeData) { + result = WidgetStateProperty.all(value); + } else if (value is String) { + result = WidgetStateProperty.all( + decodeIconThemeData( + value, + validate: false, + ), + ); + } else if (value is Map) { + final testValues = [ + 'disabled', + 'dragged', + 'empty', + 'error', + 'focused', + 'hovered', + 'pressed', + 'scrolledUnder', + 'selected', + ]; - result = TimePickerThemeData( - backgroundColor: decodeColor( - value['backgroundColor'], - validate: false, - ), - cancelButtonStyle: decodeButtonStyle( - value['cancelButtonStyle'], - validate: false, - ), - confirmButtonStyle: decodeButtonStyle( - value['confirmButtonStyle'], - validate: false, - ), - dayPeriodBorderSide: decodeBorderSide( - value['dayPeriodBorderSide'], - validate: false, - ), - dayPeriodColor: decodeMaterialStateColor( - value['dayPeriodColor'], - validate: false, - ), - dayPeriodShape: value['dayPeriodShape'] == null - ? null - : decodeShapeBorder( - value['dayPeriodShape'], + var isMsp = false; + for (var key in value.keys) { + if (testValues.contains(key)) { + isMsp = true; + break; + } + } + + if (isMsp != true) { + result = WidgetStateProperty.all( + decodeIconThemeData( + value, + validate: false, + ), + ); + } else { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/widget_state_property_icon_theme_data', + value: value, + validate: validate, + )); + + result = MapWidgetStateProperty.resolveWith((states) { + IconThemeData? result; + if (states.contains(WidgetState.disabled)) { + result = decodeIconThemeData( + value['disabled'], + validate: false, + ); + } else if (states.contains(WidgetState.dragged)) { + result = decodeIconThemeData( + value['dragged'], + validate: false, + ); + } else if (states.contains(WidgetState.error)) { + result = decodeIconThemeData( + value['error'], + validate: false, + ); + } else if (states.contains(WidgetState.focused)) { + result = decodeIconThemeData( + value['focused'], + validate: false, + ); + } else if (states.contains(WidgetState.hovered)) { + result = decodeIconThemeData( + value['hovered'], + validate: false, + ); + } else if (states.contains(WidgetState.pressed)) { + result = decodeIconThemeData( + value['pressed'], + validate: false, + ); + } else if (states.contains(WidgetState.scrolledUnder)) { + result = decodeIconThemeData( + value['scrolledUnder'], validate: false, - ) as OutlinedBorder?, - dayPeriodTextColor: decodeColor( - value['dayPeriodTextColor'], - validate: false, - ), - dayPeriodTextStyle: decodeTextStyle( - value['dayPeriodTextStyle'], - validate: false, - ), - dialBackgroundColor: decodeColor( - value['dialBackgroundColor'], - validate: false, - ), - dialHandColor: decodeColor( - value['dialHandColor'], - validate: false, - ), - dialTextColor: decodeColor( - value['dialTextColor'], - validate: false, - ), - dialTextStyle: decodeTextStyle( - value['dialTextStyle'], - validate: false, - ), - elevation: JsonClass.maybeParseDouble(value['elevation']), - entryModeIconColor: decodeColor( - value['entryModeIconColor'], - validate: false, - ), - helpTextStyle: decodeTextStyle( - value['helpTextStyle'], - validate: false, - ), - hourMinuteColor: decodeColor( - value['hourMinuteColor'], - validate: false, - ), - hourMinuteShape: decodeShapeBorder( - value['hourMinuteShape'], - validate: false, - ), - hourMinuteTextColor: decodeColor( - value['hourMinuteTextColor'], - validate: false, - ), - hourMinuteTextStyle: decodeTextStyle( - value['hourMinuteTextStyle'], - validate: false, - ), - inputDecorationTheme: decodeInputDecorationTheme( - value['inputDecorationTheme'], - validate: false, - ), - padding: decodeEdgeInsetsGeometry(value['padding'], validate: false), - shape: decodeShapeBorder( - value['shape'], - validate: false, - ), - ); - } + ); + } else if (states.contains(WidgetState.selected)) { + result = decodeIconThemeData( + value['selected'], + validate: false, + ); + } else { + result = decodeIconThemeData( + value['empty'], + validate: false, + ); + } + return result; + }); + } + } else { + result = WidgetStateProperty.all(value); + } + } return result; } - /// Decodes the given [value] to a [ToggleButtonsThemeData]. This expects the - /// [value] to have the following structure: + /// Decodes a [value] into a [MouseCursor] based [WidgetStateProperty]. + /// This accepts a [MouseCursor] or a [String] which will be resolved for all + /// states. + /// + /// Alternatively, if the [value] is a [Map] then this expects the following + /// format: /// /// ```json /// { - /// "borderColor": "", - /// "borderRadius": "", - /// "borderWidth": "", - /// "color": "", - /// "constraints": "", - /// "disabledBorderColor": "", - /// "disabledColor": "", - /// "fillColor": "", - /// "focusColor": "", - /// "highlightColor": "", - /// "hoverColor": "", - /// "selectedBorderColor": "", - /// "selectedColor": "", - /// "splashColor": "", - /// "textStyle": "" + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "" /// } /// ``` /// /// See also: - /// * [decodeBorderRadius] - /// * [decodeBoxConstraints] - /// * [decodeColor] - /// * [decodeTextStyle] - static ToggleButtonsThemeData? decodeToggleButtonsThemeData( + /// * [decodeMouseCursor] + static WidgetStateProperty? + decodeWidgetStatePropertyMouseCursor( dynamic value, { bool validate = true, }) { - ToggleButtonsThemeData? result; + WidgetStateProperty? result; - if (value is ToggleButtonsThemeData) { + if (value is WidgetStateProperty) { result = value; } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/toggle_buttons_theme_data', - value: value, - validate: validate, - )); - - result = ToggleButtonsThemeData( - borderColor: decodeColor( - value['borderColor'], - validate: false, - ), - borderRadius: decodeBorderRadius( - value['borderRadius'], - validate: false, - ), - borderWidth: JsonClass.maybeParseDouble(value['borderWidth']), - color: decodeColor( - value['color'], - validate: false, - ), - constraints: decodeBoxConstraints( - value['constraints'], - validate: false, - ), - disabledBorderColor: decodeColor( - value['disabledBorderColor'], - validate: false, - ), - disabledColor: decodeColor( - value['disabledColor'], - validate: false, - ), - fillColor: decodeColor( - value['fillColor'], - validate: false, - ), - focusColor: decodeColor( - value['focusColor'], - validate: false, - ), - highlightColor: decodeColor( - value['highlightColor'], - validate: false, - ), - hoverColor: decodeColor( - value['hoverColor'], - validate: false, - ), - selectedBorderColor: decodeColor( - value['selectedBorderColor'], - validate: false, - ), - selectedColor: decodeColor( - value['selectedColor'], - validate: false, - ), - splashColor: decodeColor( - value['splashColor'], - validate: false, - ), - textStyle: decodeTextStyle( - value['textStyle'], + if (value is MouseCursor) { + result = WidgetStateProperty.all(value); + } else if (value is String) { + result = WidgetStateProperty.all(decodeMouseCursor( + value, validate: false, - ), - ); - } + )); + } else if (value is Map) { + final testValues = [ + 'disabled', + 'dragged', + 'empty', + 'error', + 'focused', + 'hovered', + 'pressed', + 'scrolledUnder', + 'selected', + ]; + + var isMsp = false; + for (var key in value.keys) { + if (testValues.contains(key)) { + isMsp = true; + break; + } + } + + if (isMsp != true) { + result = WidgetStateProperty.all( + decodeMouseCursor( + value, + validate: false, + ), + ); + } else { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/widget_state_property_mouse_cursor', + value: value, + validate: validate, + )); + + result = MapWidgetStateProperty.resolveWith((states) { + MouseCursor? result; + if (states.contains(WidgetState.disabled)) { + result = decodeMouseCursor( + value['disabled'], + validate: false, + ); + } else if (states.contains(WidgetState.dragged)) { + result = decodeMouseCursor( + value['dragged'], + validate: false, + ); + } else if (states.contains(WidgetState.error)) { + result = decodeMouseCursor( + value['error'], + validate: false, + ); + } else if (states.contains(WidgetState.focused)) { + result = decodeMouseCursor( + value['focused'], + validate: false, + ); + } else if (states.contains(WidgetState.hovered)) { + result = decodeMouseCursor( + value['hovered'], + validate: false, + ); + } else if (states.contains(WidgetState.pressed)) { + result = decodeMouseCursor( + value['pressed'], + validate: false, + ); + } else if (states.contains(WidgetState.scrolledUnder)) { + result = decodeMouseCursor( + value['scrolledUnder'], + validate: false, + ); + } else if (states.contains(WidgetState.selected)) { + result = decodeMouseCursor( + value['selected'], + validate: false, + ); + } else { + result = decodeMouseCursor( + value['empty'], + validate: false, + ); + } + return result; + }); + } + } else { + result = WidgetStateProperty.all(value); + } + } return result; } - /// Decodes the given [value] to a [TooltipThemeData]. This expects the - /// [value] to have the following structure: + /// Decodes a [value] into a [OutlinedBorder] based [WidgetStateProperty]. + /// This accepts a [OutlinedBorder] or a [String] which will be resolved for + /// all states. + /// + /// Alternatively, if the [value] is a [Map] then this expects the following + /// format: /// /// ```json /// { - /// "enableFeedback": "", - /// "excludeFromSemantics": "", - /// "height": "", - /// "margin": "", - /// "padding": "", - /// "preferBelow": "" - /// "showDuration": "", - /// "textAlign": "", - /// "textStyle": "", - /// "verticalOffset": "", - /// "waitDuration": "" + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "" /// } /// ``` /// /// See also: - /// * [decodeEdgeInsetsGeometry] - /// * [decodeTextAlign] - /// * [decodeTextStyle] - /// * [decodeTooltipTriggerMode] - static TooltipThemeData? decodeTooltipThemeData( + /// * [decodeOutlinedBorder] + static WidgetStateProperty? + decodeWidgetStatePropertyOutlinedBorder( dynamic value, { bool validate = true, }) { - TooltipThemeData? result; + WidgetStateProperty? result; - if (value is TooltipThemeData) { + if (value is WidgetStateProperty) { result = value; } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/tooltip_theme_data', - value: value, - validate: validate, - )); - assert( - value['decoration'] == null, - 'TooltipThemeData.decoration is not supported', - ); - result = TooltipThemeData( - // decoration: @unencodable - enableFeedback: JsonClass.maybeParseBool(value['enableFeedback']), - excludeFromSemantics: JsonClass.maybeParseBool( - value['excludeFromSemantics'], - ), - height: JsonClass.maybeParseDouble(value['height']), - margin: decodeEdgeInsetsGeometry( - value['margin'], - validate: false, - ), - padding: decodeEdgeInsetsGeometry( - value['padding'], - validate: false, - ), - preferBelow: JsonClass.maybeParseBool(value['preferBelow']), - showDuration: JsonClass.maybeParseDurationFromMillis( - value['showDuration'], - ), - textAlign: decodeTextAlign( - value['textAlign'], - validate: false, - ), - textStyle: decodeTextStyle( - value['textStyle'], - validate: false, - ), - triggerMode: decodeTooltipTriggerMode( - value['triggerMode'], - validate: false, - ), - verticalOffset: JsonClass.maybeParseDouble(value['verticalOffset']), - waitDuration: - JsonClass.maybeParseDurationFromMillis(value['waitDuration']), - ); - } + if (value is OutlinedBorder) { + result = WidgetStateProperty.all(value); + } else if (value is String) { + result = WidgetStateProperty.all( + decodeOutlinedBorder( + value, + validate: false, + ), + ); + } else if (value is Map) { + final testValues = [ + 'disabled', + 'dragged', + 'empty', + 'error', + 'focused', + 'hovered', + 'pressed', + 'scrolledUnder', + 'selected', + ]; + + var isMsp = false; + for (var key in value.keys) { + if (testValues.contains(key)) { + isMsp = true; + break; + } + } + + if (isMsp != true) { + result = WidgetStateProperty.all( + decodeOutlinedBorder( + value, + validate: false, + ), + ); + } else { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/widget_state_property_outlined_border', + value: value, + validate: validate, + )); + + result = MapWidgetStateProperty.resolveWith((states) { + OutlinedBorder? result; + if (states.contains(WidgetState.disabled)) { + result = decodeOutlinedBorder( + value['disabled'], + validate: false, + ); + } else if (states.contains(WidgetState.dragged)) { + result = decodeOutlinedBorder( + value['dragged'], + validate: false, + ); + } else if (states.contains(WidgetState.error)) { + result = decodeOutlinedBorder( + value['error'], + validate: false, + ); + } else if (states.contains(WidgetState.focused)) { + result = decodeOutlinedBorder( + value['focused'], + validate: false, + ); + } else if (states.contains(WidgetState.hovered)) { + result = decodeOutlinedBorder( + value['hovered'], + validate: false, + ); + } else if (states.contains(WidgetState.pressed)) { + result = decodeOutlinedBorder( + value['pressed'], + validate: false, + ); + } else if (states.contains(WidgetState.scrolledUnder)) { + result = decodeOutlinedBorder( + value['scrolledUnder'], + validate: false, + ); + } else if (states.contains(WidgetState.selected)) { + result = decodeOutlinedBorder( + value['selected'], + validate: false, + ); + } else { + result = decodeOutlinedBorder( + value['empty'], + validate: false, + ); + } + return result; + }); + } + } else { + result = WidgetStateProperty.all(value); + } + } return result; } - /// Decodes the [value] to a [TooltipTriggerMode]. Supported values are: - /// * `longPress` - /// * `manual` - /// * `tap` - static TooltipTriggerMode? decodeTooltipTriggerMode( + /// Decodes a [value] into a [Size] based [WidgetStateProperty]. This + /// accepts a [Size] or a [String] which will be resolved for all states. + /// + /// Alternatively, if the [value] is a [Map] then this expects the following + /// format: + /// + /// ```json + /// { + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "" + /// } + /// ``` + /// + /// See also: + /// * [decodeSize] + static WidgetStateProperty? decodeWidgetStatePropertySize( dynamic value, { bool validate = true, }) { - TooltipTriggerMode? result; + WidgetStateProperty? result; - if (value is TooltipTriggerMode) { + if (value is WidgetStateProperty) { result = value; } else if (value != null) { - _checkSupported( - 'TooltipTriggerMode', - [ - 'longPress', - 'manual', - 'tap', - ], - value, - ); + if (value is Size) { + result = WidgetStateProperty.all(value); + } else if (value is String) { + result = WidgetStateProperty.all(decodeSize( + value, + validate: false, + )); + } else if (value is Map) { + final testValues = [ + 'disabled', + 'dragged', + 'empty', + 'error', + 'focused', + 'hovered', + 'pressed', + 'scrolledUnder', + 'selected', + ]; - switch (value) { - case 'longPress': - result = TooltipTriggerMode.longPress; - break; + var isMsp = false; + for (var key in value.keys) { + if (testValues.contains(key)) { + isMsp = true; + break; + } + } - case 'manual': - result = TooltipTriggerMode.manual; - break; + if (isMsp != true) { + result = WidgetStateProperty.all(decodeSize( + value, + validate: false, + )); + } else { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/widget_state_property_size', + value: value, + validate: validate, + )); + + result = MapWidgetStateProperty.resolveWith((states) { + Size? result; + if (states.contains(WidgetState.disabled)) { + result = decodeSize( + value['disabled'], + validate: false, + ); + } else if (states.contains(WidgetState.dragged)) { + result = decodeSize( + value['dragged'], + validate: false, + ); + } else if (states.contains(WidgetState.error)) { + result = decodeSize( + value['error'], + validate: false, + ); + } else if (states.contains(WidgetState.focused)) { + result = decodeSize( + value['focused'], + validate: false, + ); + } else if (states.contains(WidgetState.hovered)) { + result = decodeSize( + value['hovered'], + validate: false, + ); + } else if (states.contains(WidgetState.pressed)) { + result = decodeSize( + value['pressed'], + validate: false, + ); + } else if (states.contains(WidgetState.scrolledUnder)) { + result = decodeSize( + value['scrolledUnder'], + validate: false, + ); + } else if (states.contains(WidgetState.selected)) { + result = decodeSize( + value['selected'], + validate: false, + ); + } else { + result = decodeSize( + value['empty'], + validate: false, + ); + } - case 'tap': - result = TooltipTriggerMode.tap; - break; + return result; + }); + } + } else { + result = WidgetStateProperty.all(value); } } - return result; } - /// Decodes the given [value] to a [Typography]. This expects the [value] to - /// have the following structure: + /// Decodes a [value] into a [TextStyle] based [WidgetStateProperty]. This + /// accepts a [TextStyle] or a [String] which will be resolved for all states. + /// + /// Alternatively, if the [value] is a [Map] then this expects the following + /// format: /// /// ```json /// { - /// "black": "", - /// "dense": "", - /// "englishLike": "", - /// "platform": "", - /// "tall": "", - /// "white": "", + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "" /// } /// ``` /// /// See also: - /// * [decodeTargetPlatform] - /// * [decodeTextTheme] - static Typography? decodeTypography( + /// * [decodeTextStyle] + static WidgetStateProperty? decodeWidgetStatePropertyTextStyle( dynamic value, { bool validate = true, }) { - Typography? result; + WidgetStateProperty? result; - if (value is Typography) { + if (value is WidgetStateProperty) { result = value; } else if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/typography', - value: value, - validate: validate, - )); - result = Typography.material2018( - black: decodeTextTheme( - value['black'], - validate: false, - ), - dense: decodeTextTheme( - value['dense'], - validate: false, - ), - englishLike: decodeTextTheme( - value['englishLike'], - validate: false, - ), - platform: decodeTargetPlatform( - value['platform'], - validate: false, - ), - tall: decodeTextTheme( - value['tall'], - validate: false, - ), - white: decodeTextTheme( - value['white'], + if (value is TextStyle) { + result = WidgetStateProperty.all(value); + } else if (value is String) { + result = WidgetStateProperty.all(decodeTextStyle( + value, validate: false, - ), - ); - } - - return result; - } - - /// Decodes the [value] to a [VerticalDirection]. Supported values are: - /// * `down` - /// * `up` - static VerticalDirection? decodeVerticalDirection( - dynamic value, { - bool validate = true, - }) { - VerticalDirection? result; - if (value is VerticalDirection) { - result = value; - } else { - _checkSupported( - 'VerticalDirection', - [ - 'down', - 'up', - ], - value, - ); + )); + } else if (value is Map) { + final testValues = [ + 'disabled', + 'dragged', + 'empty', + 'error', + 'focused', + 'hovered', + 'pressed', + 'scrolledUnder', + 'selected', + ]; - if (value != null) { - switch (value) { - case 'down': - result = VerticalDirection.down; - break; - case 'up': - result = VerticalDirection.up; + var isMsp = false; + for (var key in value.keys) { + if (testValues.contains(key)) { + isMsp = true; break; + } } - } - } - - return result; - } - - /// Decodes the [value] to a [VisualDensity]. Supported values are: - /// * `adaptivePlatformDensity` - /// * `comfortable` - /// * `compact` - /// * `standard` - static VisualDensity? decodeVisualDensity( - dynamic value, { - bool validate = true, - }) { - VisualDensity? result; - if (value is VisualDensity) { - result = value; - } else { - _checkSupported( - 'VisualDensity', - [ - 'adaptivePlatformDensity', - 'comfortable', - 'compact', - 'standard', - ], - value, - ); - - if (value != null) { - assert(SchemaValidator.validate( - schemaId: '$_baseSchemaUrl/visual_density', - value: value, - validate: validate, - )); - switch (value) { - case 'adaptivePlatformDensity': - result = VisualDensity.adaptivePlatformDensity; - break; - case 'comfortable': - result = VisualDensity.comfortable; - break; + if (isMsp != true) { + result = WidgetStateProperty.all( + decodeTextStyle( + value, + validate: false, + ), + ); + } else { + assert(SchemaValidator.validate( + schemaId: '$_baseSchemaUrl/widget_state_property_text_style', + value: value, + validate: validate, + )); - case 'compact': - result = VisualDensity.compact; - break; + result = MapWidgetStateProperty.resolveWith((states) { + TextStyle? result; + if (states.contains(WidgetState.disabled)) { + result = decodeTextStyle( + value['disabled'], + validate: false, + ); + } else if (states.contains(WidgetState.dragged)) { + result = decodeTextStyle( + value['dragged'], + validate: false, + ); + } else if (states.contains(WidgetState.error)) { + result = decodeTextStyle( + value['error'], + validate: false, + ); + } else if (states.contains(WidgetState.focused)) { + result = decodeTextStyle( + value['focused'], + validate: false, + ); + } else if (states.contains(WidgetState.hovered)) { + result = decodeTextStyle( + value['hovered'], + validate: false, + ); + } else if (states.contains(WidgetState.pressed)) { + result = decodeTextStyle( + value['pressed'], + validate: false, + ); + } else if (states.contains(WidgetState.scrolledUnder)) { + result = decodeTextStyle( + value['scrolledUnder'], + validate: false, + ); + } else if (states.contains(WidgetState.selected)) { + result = decodeTextStyle( + value['selected'], + validate: false, + ); + } else { + result = decodeTextStyle( + value['empty'], + validate: false, + ); + } - case 'standard': - result = VisualDensity.standard; - break; + return result; + }); } + } else { + result = WidgetStateProperty.all(value); } } - return result; } diff --git a/json_theme/lib/src/codec/theme_encoder.dart b/json_theme/lib/src/codec/theme_encoder.dart index 96a1d7f..51d0a96 100644 --- a/json_theme/lib/src/codec/theme_encoder.dart +++ b/json_theme/lib/src/codec/theme_encoder.dart @@ -1172,7 +1172,7 @@ class ThemeEncoder { /// } /// ``` /// - /// This won't maintain the [MaterialStateProperty] of each corresponding + /// This won't maintain the [WidgetStateProperty] of each corresponding /// property, instead will resolve them by using an empty set of states, /// returning and encoding the resolved object. /// @@ -1181,14 +1181,14 @@ class ThemeEncoder { /// * [encodeColor] /// * [encodeEdgeInsetsGeometry] /// * [encodeInteractiveInkSplashFactory] - /// * [encodeMaterialStatePropertyBorderSide] - /// * [encodeMaterialStatePropertyColor] - /// * [encodeMaterialStatePropertyDouble] - /// * [encodeMaterialStatePropertyEdgeInsetsGeometry] - /// * [encodeMaterialStatePropertyMouseCursor] - /// * [encodeMaterialStatePropertyOutlinedBorder] - /// * [encodeMaterialStatePropertySize] - /// * [encodeMaterialStatePropertyTextStyle] + /// * [encodeWidgetStatePropertyBorderSide] + /// * [encodeWidgetStatePropertyColor] + /// * [encodeWidgetStatePropertyDouble] + /// * [encodeWidgetStatePropertyEdgeInsetsGeometry] + /// * [encodeWidgetStatePropertyMouseCursor] + /// * [encodeWidgetStatePropertyOutlinedBorder] + /// * [encodeWidgetStatePropertySize] + /// * [encodeWidgetStatePropertyTextStyle] /// * [encodeMaterialTapTargetSize] /// * [encodeMouseCursor] /// * [encodeOutlinedBorder] @@ -1204,37 +1204,37 @@ class ThemeEncoder { result = { 'alignment': encodeAlignmentGeometry(value.alignment), 'animationDuration': value.animationDuration?.inMilliseconds, - 'backgroundColor': encodeMaterialStatePropertyColor( + 'backgroundColor': encodeWidgetStatePropertyColor( value.backgroundColor, ), - 'elevation': encodeMaterialStatePropertyDouble(value.elevation), + 'elevation': encodeWidgetStatePropertyDouble(value.elevation), 'enableFeedback': value.enableFeedback, - 'fixedSize': encodeMaterialStatePropertySize(value.fixedSize), - 'foregroundColor': encodeMaterialStatePropertyColor( + 'fixedSize': encodeWidgetStatePropertySize(value.fixedSize), + 'foregroundColor': encodeWidgetStatePropertyColor( value.foregroundColor, ), - 'iconColor': encodeMaterialStatePropertyColor(value.iconColor), - 'iconSize': encodeMaterialStatePropertyDouble(value.iconSize), - 'maximumSize': encodeMaterialStatePropertySize(value.maximumSize), - 'minimumSize': encodeMaterialStatePropertySize(value.minimumSize), - 'mouseCursor': encodeMaterialStatePropertyMouseCursor( + 'iconColor': encodeWidgetStatePropertyColor(value.iconColor), + 'iconSize': encodeWidgetStatePropertyDouble(value.iconSize), + 'maximumSize': encodeWidgetStatePropertySize(value.maximumSize), + 'minimumSize': encodeWidgetStatePropertySize(value.minimumSize), + 'mouseCursor': encodeWidgetStatePropertyMouseCursor( value.mouseCursor, ), - 'overlayColor': encodeMaterialStatePropertyColor(value.overlayColor), - 'padding': encodeMaterialStatePropertyEdgeInsetsGeometry(value.padding), - 'shadowColor': encodeMaterialStatePropertyColor(value.shadowColor), - 'shape': encodeMaterialStatePropertyOutlinedBorder(value.shape), - 'side': encodeMaterialStatePropertyBorderSide(value.side), + 'overlayColor': encodeWidgetStatePropertyColor(value.overlayColor), + 'padding': encodeWidgetStatePropertyEdgeInsetsGeometry(value.padding), + 'shadowColor': encodeWidgetStatePropertyColor(value.shadowColor), + 'shape': encodeWidgetStatePropertyOutlinedBorder(value.shape), + 'side': encodeWidgetStatePropertyBorderSide(value.side), 'splashFactory': encodeInteractiveInkFeatureFactory( value.splashFactory, ), - 'surfaceTintColor': encodeMaterialStatePropertyColor( + 'surfaceTintColor': encodeWidgetStatePropertyColor( value.surfaceTintColor, ), 'tapTargetSize': encodeMaterialTapTargetSize( value.tapTargetSize, ), - 'textStyle': encodeMaterialStatePropertyTextStyle(value.textStyle), + 'textStyle': encodeWidgetStatePropertyTextStyle(value.textStyle), 'visualDensity': encodeVisualDensity( value.visualDensity, ), @@ -1386,19 +1386,19 @@ class ThemeEncoder { if (value != null) { result = { - 'checkColor': encodeMaterialStatePropertyColor( + 'checkColor': encodeWidgetStatePropertyColor( value.checkColor, ), - 'fillColor': encodeMaterialStatePropertyColor( + 'fillColor': encodeWidgetStatePropertyColor( value.fillColor, ), 'materialTapTargetSize': encodeMaterialTapTargetSize( value.materialTapTargetSize, ), - 'mouseCursor': encodeMaterialStatePropertyMouseCursor( + 'mouseCursor': encodeWidgetStatePropertyMouseCursor( value.mouseCursor, ), - 'overlayColor': encodeMaterialStatePropertyColor( + 'overlayColor': encodeWidgetStatePropertyColor( value.overlayColor, ), 'shape': encodeOutlinedBorder(value.shape), @@ -1445,7 +1445,7 @@ class ThemeEncoder { /// * [encodeColor] /// * [encodeEdgeInsetsGeometry] /// * [encodeIconThemeData] - /// * [encodeMaterialStateProperty] + /// * [encodeWidgetStateProperty] /// * [encodeShapeBorder] /// * [encodeTextStyle] static Map? encodeChipThemeData(ChipThemeData? value) { @@ -1456,7 +1456,7 @@ class ThemeEncoder { 'backgroundColor': encodeColor(value.backgroundColor), 'brightness': encodeBrightness(value.brightness), 'checkmarkColor': encodeColor(value.checkmarkColor), - 'color': encodeMaterialStatePropertyColor(value.color), + 'color': encodeWidgetStatePropertyColor(value.color), 'deleteIconColor': encodeColor(value.deleteIconColor), 'disabledColor': encodeColor(value.disabledColor), 'elevation': value.elevation, @@ -1560,7 +1560,7 @@ class ThemeEncoder { /// "shadow": "", /// "surface": "", /// "surfaceTint": "", - /// "surfaceVariant": "", + /// "surfaceContainerHighest": "", /// "tertiary": "", /// "tertiaryContainer": "" /// } @@ -1574,13 +1574,13 @@ class ThemeEncoder { if (value != null) { result = { - 'background': encodeColor(value.background), + 'background': encodeColor(value.surface), 'brightness': encodeBrightness(value.brightness), 'error': encodeColor(value.error), 'errorContainer': encodeColor(value.errorContainer), 'inversePrimary': encodeColor(value.inversePrimary), 'inverseSurface': encodeColor(value.inverseSurface), - 'onBackground': encodeColor(value.onBackground), + 'onBackground': encodeColor(value.onSurface), 'onError': encodeColor(value.onError), 'onErrorContainer': encodeColor(value.onErrorContainer), 'onInverseSurface': encodeColor(value.onInverseSurface), @@ -1601,8 +1601,8 @@ class ThemeEncoder { 'secondaryContainer': encodeColor(value.secondaryContainer), 'shadow': encodeColor(value.shadow), 'surface': encodeColor(value.surface), + 'surfaceContainerHighest': encodeColor(value.surfaceContainerHighest), 'surfaceTint': encodeColor(value.surfaceTint), - 'surfaceVariant': encodeColor(value.surfaceVariant), 'tertiary': encodeColor(value.tertiary), 'tertiaryContainer': encodeColor(value.tertiaryContainer), }; @@ -1796,7 +1796,7 @@ class ThemeEncoder { /// * [encodeBorderSide] /// * [encodeColor] /// * [encodeInputDecorationTheme] - /// * [encodeMaterialStatePropertyColor] + /// * [encodeWidgetStatePropertyColor] /// * [encodeShapeBorder] /// * [encodeTextStyle] static Map? encodeDatePickerThemeData( @@ -1808,13 +1808,13 @@ class ThemeEncoder { result = { 'backgroundColor': encodeColor(value.backgroundColor), 'cancelButtonStyle': encodeButtonStyle(value.cancelButtonStyle), - 'dayBackgroundColor': encodeMaterialStatePropertyColor( + 'dayBackgroundColor': encodeWidgetStatePropertyColor( value.dayBackgroundColor, ), - 'dayForegroundColor': encodeMaterialStatePropertyColor( + 'dayForegroundColor': encodeWidgetStatePropertyColor( value.dayForegroundColor, ), - 'dayOverlayColor': encodeMaterialStatePropertyColor( + 'dayOverlayColor': encodeWidgetStatePropertyColor( value.dayOverlayColor, ), 'dayStyle': encodeTextStyle(value.dayStyle), @@ -1851,27 +1851,27 @@ class ThemeEncoder { 'rangeSelectionBackgroundColor': encodeColor( value.rangeSelectionBackgroundColor, ), - 'rangeSelectionOverlayColor': encodeMaterialStatePropertyColor( + 'rangeSelectionOverlayColor': encodeWidgetStatePropertyColor( value.rangeSelectionOverlayColor, ), 'shadowColor': encodeColor(value.shadowColor), 'shape': encodeShapeBorder(value.shape), 'surfaceTintColor': encodeColor(value.surfaceTintColor), - 'todayBackgroundColor': encodeMaterialStatePropertyColor( + 'todayBackgroundColor': encodeWidgetStatePropertyColor( value.todayBackgroundColor, ), 'todayBorder': encodeBorderSide(value.todayBorder), - 'todayForegroundColor': encodeMaterialStatePropertyColor( + 'todayForegroundColor': encodeWidgetStatePropertyColor( value.todayForegroundColor, ), 'weekdayStyle': encodeTextStyle(value.weekdayStyle), - 'yearBackgroundColor': encodeMaterialStatePropertyColor( + 'yearBackgroundColor': encodeWidgetStatePropertyColor( value.yearBackgroundColor, ), - 'yearForegroundColor': encodeMaterialStatePropertyColor( + 'yearForegroundColor': encodeWidgetStatePropertyColor( value.yearForegroundColor, ), - 'yearOverlayColor': encodeMaterialStatePropertyColor( + 'yearOverlayColor': encodeWidgetStatePropertyColor( value.yearOverlayColor, ), 'yearStyle': encodeTextStyle(value.yearStyle), @@ -1902,7 +1902,7 @@ class ThemeEncoder { /// } /// ``` /// - /// This won't maintain the [MaterialStateProperty] of each corresponding + /// This won't maintain the [WidgetStateProperty] of each corresponding /// property, instead will resolve them by using an empty set of states, /// returning and encoding the resolved object. /// @@ -1918,10 +1918,10 @@ class ThemeEncoder { result = { 'checkboxHorizontalMargin': value.checkboxHorizontalMargin, 'columnSpacing': value.columnSpacing, - 'dataRowColor': encodeMaterialStatePropertyColor( + 'dataRowColor': encodeWidgetStatePropertyColor( value.dataRowColor, ), - 'dataRowCursor': encodeMaterialStatePropertyMouseCursor( + 'dataRowCursor': encodeWidgetStatePropertyMouseCursor( value.dataRowCursor, ), 'dataRowMaxHeight': value.dataRowMaxHeight, @@ -1935,10 +1935,10 @@ class ThemeEncoder { : value.decoration as BoxDecoration, ), 'dividerThickness': value.dividerThickness, - 'headingCellCursor': encodeMaterialStatePropertyMouseCursor( + 'headingCellCursor': encodeWidgetStatePropertyMouseCursor( value.headingCellCursor, ), - 'headingRowColor': encodeMaterialStatePropertyColor( + 'headingRowColor': encodeWidgetStatePropertyColor( value.headingRowColor, ), 'headingRowHeight': value.headingRowHeight, @@ -2558,7 +2558,7 @@ class ThemeEncoder { /// See also: /// * [encodeBoxConstraints] /// * [encodeColor] - /// * [encodeMaterialStatePropertyMouseCursor] + /// * [encodeWidgetStatePropertyMouseCursor] /// * [encodeShapeBorder] /// * [encodeTextStyle] static Map? encodeFloatingActionButtonThemeData( @@ -2590,7 +2590,7 @@ class ThemeEncoder { 'largeSizeConstraints': encodeBoxConstraints( value.largeSizeConstraints, ), - 'mouseCursor': encodeMaterialStatePropertyMouseCursor( + 'mouseCursor': encodeWidgetStatePropertyMouseCursor( value.mouseCursor, ), 'shape': encodeShapeBorder(value.shape), @@ -3455,7 +3455,7 @@ class ThemeEncoder { ), 'minLeadingWidth': value.minLeadingWidth, 'minVerticalPadding': value.minVerticalPadding, - 'mouseCursor': encodeMaterialStatePropertyMouseCursor( + 'mouseCursor': encodeWidgetStatePropertyMouseCursor( value.mouseCursor, ), 'selectedColor': encodeColor(value.selectedColor), @@ -3634,760 +3634,263 @@ class ThemeEncoder { return _stripDynamicNull(result); } - /// Encodes the [value] into a JSON representation. + /// Encodes the given [value] to the String representation. Supported values + /// are: + /// * `padded` + /// * `shrinkWrap` /// + /// All other values, including `null`, will result in `null`. + static String? encodeMaterialTapTargetSize(MaterialTapTargetSize? value) { + String? result; + + if (value != null) { + switch (value) { + case MaterialTapTargetSize.padded: + result = 'padded'; + break; + case MaterialTapTargetSize.shrinkWrap: + result = 'shrinkWrap'; + break; + } + } + + return _stripDynamicNull(result); + } + + /// Encodes the given [value] to the String representation. Supported values + /// are: + /// * `button` + /// * `canvas` + /// * `card` + /// * `circle` + /// * `transparency` /// - /// ```json - /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "" - /// } - /// ``` + /// All other values, including `null`, will result in `null`. + static String? encodeMaterialType(MaterialType? value) { + String? result; + + if (value != null) { + switch (value) { + case MaterialType.button: + result = 'button'; + break; + case MaterialType.canvas: + result = 'canvas'; + break; + case MaterialType.card: + result = 'card'; + break; + case MaterialType.circle: + result = 'circle'; + break; + case MaterialType.transparency: + result = 'transparency'; + break; + } + } + + return _stripDynamicNull(result); + } + + /// Encodes the [value] to a [Matrix4]. This will encode the [value] into a 16 + /// element [List] of [double]. /// - /// See also: - /// * [encodeColor] - static Map? encodeMaterialStateColor( - MaterialStateColor? value, { + /// The array takes the following format: + /// ``` + /// [ + /// x0, + /// x1, + /// x2, + /// x3, + /// y0, + /// y1, + /// y2, + /// y3, + /// z0, + /// z1, + /// z2, + /// z3, + /// w0, + /// w1, + /// w2, + /// w3 + /// ] + /// ``` + static List? encodeMatrix4(Matrix4? value) { + List? result; + + if (value != null) { + result = [ + value.row0.x, + value.row1.x, + value.row2.x, + value.row3.x, + value.row0.y, + value.row1.y, + value.row2.y, + value.row3.y, + value.row0.z, + value.row1.z, + value.row2.z, + value.row3.z, + value.row0.w, + value.row1.w, + value.row2.w, + value.row3.w, + ]; + } + + return _stripDynamicNull(result); + } + + /// Encodes the [value] to a [MaxLengthEnforcement]. Supported values are: + /// * `enforced` + /// * `none` + /// * `truncateAfterCompositionEnds` + static String? encodeMaxLengthEnforcement( + MaxLengthEnforcement? value, { bool validate = true, }) { - Map? result; - + String? result; if (value != null) { - result = { - 'disabled': encodeColor(value.resolve({MaterialState.disabled})), - 'dragged': encodeColor(value.resolve({MaterialState.dragged})), - 'empty': encodeColor(value.resolve({})), - 'error': encodeColor(value.resolve({MaterialState.error})), - 'focused': encodeColor(value.resolve({MaterialState.focused})), - 'hovered': encodeColor(value.resolve({MaterialState.hovered})), - 'pressed': encodeColor(value.resolve({MaterialState.pressed})), - 'scrolledUnder': encodeColor(value.resolve( - {MaterialState.scrolledUnder}, - )), - 'selected': encodeColor(value.resolve({MaterialState.selected})), - }; + switch (value) { + case MaxLengthEnforcement.enforced: + result = 'enforced'; + break; + case MaxLengthEnforcement.none: + result = 'none'; + break; + case MaxLengthEnforcement.truncateAfterCompositionEnds: + result = 'truncateAfterCompositionEnds'; + break; + } } return _stripDynamicNull(result); } - /// Encodes the [value] into a JSON representation. - /// + /// Encodes the given [value] to an JSON map. /// /// ```json /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "" + /// "style": "" /// } /// ``` - static Map? encodeMaterialStatePropertyBool( - MaterialStateProperty? value, { - bool validate = true, - }) { + /// + /// See also: + /// * [encodeMenuStyle] + static Map? encodeMenuBarThemeData(MenuBarThemeData? value) { Map? result; if (value != null) { result = { - 'disabled': value.resolve({MaterialState.disabled}), - 'dragged': value.resolve({MaterialState.dragged}), - 'empty': value.resolve({}), - 'error': value.resolve({MaterialState.error}), - 'focused': value.resolve({MaterialState.focused}), - 'hovered': value.resolve({MaterialState.hovered}), - 'pressed': value.resolve({MaterialState.pressed}), - 'scrolledUnder': value.resolve({MaterialState.scrolledUnder}), - 'selected': value.resolve({MaterialState.selected}), + 'style': encodeMenuStyle( + value.style, + ), }; } return _stripDynamicNull(result); } - /// Encodes the [value] into a JSON representation. - /// + /// Encodes the given [value] to an JSON map. /// /// ```json /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "" + /// "style": "", /// } /// ``` /// /// See also: - /// * [encodeBorderSide] - static Map? encodeMaterialStatePropertyBorderSide( - MaterialStateProperty? value, { - bool validate = true, - }) { + /// * [encodeButtonStyle] + static Map? encodeMenuButtonThemeData( + MenuButtonThemeData? value, + ) { Map? result; if (value != null) { result = { - 'disabled': encodeBorderSide(value.resolve({MaterialState.disabled})), - 'dragged': encodeBorderSide(value.resolve({MaterialState.dragged})), - 'empty': encodeBorderSide(value.resolve({})), - 'error': encodeBorderSide(value.resolve({MaterialState.error})), - 'focused': encodeBorderSide(value.resolve({MaterialState.focused})), - 'hovered': encodeBorderSide(value.resolve({MaterialState.hovered})), - 'pressed': encodeBorderSide(value.resolve({MaterialState.pressed})), - 'scrolledUnder': encodeBorderSide(value.resolve( - {MaterialState.scrolledUnder}, - )), - 'selected': encodeBorderSide(value.resolve({MaterialState.selected})), + 'style': encodeButtonStyle(value.style), }; } return _stripDynamicNull(result); } - /// Encodes the [value] into a JSON representation. - /// + /// Encodes the given [value] to an JSON map. /// /// ```json /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "" + /// "alignment": "", + /// "backgroundColor": ">", + /// "elevation": ">", + /// "fixedSize": ">", + /// "maximumSize": ">", + /// "minimumSize": ">", + /// "padding": ">", + /// "shadowColor": ">", + /// "shape": ">", + /// "side": ">", + /// "surfaceTintColor": ">", + /// "visualDensity": "", /// } /// ``` /// /// See also: - /// * [encodeColor] - static Map? encodeMaterialStatePropertyColor( - MaterialStateProperty? value, { - bool validate = true, - }) { + /// * [encodeAlignment] + /// * [encodeWidgetStatePropertyBorderSide] + /// * [encodeWidgetStatePropertyColor] + /// * [encodeWidgetStatePropertyDouble] + /// * [encodeWidgetStatePropertyEdgeInsetsGeometry] + /// * [encodeWidgetStatePropertyMouseCursor] + /// * [encodeWidgetStatePropertySize] + /// * [encodeVisualDensity] + static Map? encodeMenuStyle(MenuStyle? value) { Map? result; if (value != null) { result = { - 'disabled': encodeColor(value.resolve({MaterialState.disabled})), - 'dragged': encodeColor(value.resolve({MaterialState.dragged})), - 'empty': encodeColor(value.resolve({})), - 'error': encodeColor(value.resolve({MaterialState.error})), - 'focused': encodeColor(value.resolve({MaterialState.focused})), - 'hovered': encodeColor(value.resolve({MaterialState.hovered})), - 'pressed': encodeColor(value.resolve({MaterialState.pressed})), - 'scrolledUnder': encodeColor(value.resolve( - {MaterialState.scrolledUnder}, - )), - 'selected': encodeColor(value.resolve({MaterialState.selected})), + 'alignment': encodeAlignmentGeometry(value.alignment), + 'backgroundColor': encodeWidgetStatePropertyColor( + value.backgroundColor, + ), + 'elevation': encodeWidgetStatePropertyDouble(value.elevation), + 'fixedSize': encodeWidgetStatePropertySize(value.fixedSize), + 'maximumSize': encodeWidgetStatePropertySize(value.maximumSize), + 'minimumSize': encodeWidgetStatePropertySize(value.minimumSize), + 'mouseCursor': encodeWidgetStatePropertyMouseCursor( + value.mouseCursor, + ), + 'padding': encodeWidgetStatePropertyEdgeInsetsGeometry(value.padding), + 'shadowColor': encodeWidgetStatePropertyColor(value.shadowColor), + 'shape': encodeWidgetStatePropertyOutlinedBorder(value.shape), + 'side': encodeWidgetStatePropertyBorderSide(value.side), + 'surfaceTintColor': encodeWidgetStatePropertyColor( + value.surfaceTintColor, + ), + 'visualDensity': encodeVisualDensity(value.visualDensity), }; } return _stripDynamicNull(result); } - /// Encodes the [value] into a JSON representation. - /// + /// Encodes the given [value] to an JSON map. /// /// ```json /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "" + /// "style": "" /// } /// ``` - static Map? encodeMaterialStatePropertyDouble( - MaterialStateProperty? value, { - bool validate = true, - }) { + /// + /// See also: + /// * [encodeMenuStyle] + static Map? encodeMenuThemeData(MenuThemeData? value) { Map? result; if (value != null) { result = { - 'disabled': value.resolve({MaterialState.disabled}), - 'dragged': value.resolve({MaterialState.dragged}), - 'empty': value.resolve({}), - 'error': value.resolve({MaterialState.error}), - 'focused': value.resolve({MaterialState.focused}), - 'hovered': value.resolve({MaterialState.hovered}), - 'pressed': value.resolve({MaterialState.pressed}), - 'scrolledUnder': value.resolve({MaterialState.scrolledUnder}), - 'selected': value.resolve({MaterialState.selected}), - }; - } - - return _stripDynamicNull(result); - } - - /// Encodes the [value] into a JSON representation. - /// - /// - /// ```json - /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "" - /// } - /// ``` - /// - /// See also: - /// * [encodeEdgeInsetsGeometry] - static Map? encodeMaterialStatePropertyEdgeInsetsGeometry( - MaterialStateProperty? value, { - bool validate = true, - }) { - Map? result; - - if (value != null) { - result = { - 'disabled': encodeEdgeInsetsGeometry( - value.resolve({MaterialState.disabled}) as EdgeInsets?, - ), - 'dragged': encodeEdgeInsetsGeometry( - value.resolve({MaterialState.dragged}) as EdgeInsets?, - ), - 'empty': encodeEdgeInsetsGeometry( - value.resolve({}) as EdgeInsets?, - ), - 'error': encodeEdgeInsetsGeometry( - value.resolve({MaterialState.error}) as EdgeInsets?, - ), - 'focused': encodeEdgeInsetsGeometry( - value.resolve({MaterialState.focused}) as EdgeInsets?, - ), - 'hovered': encodeEdgeInsetsGeometry( - value.resolve({MaterialState.hovered}) as EdgeInsets?, - ), - 'pressed': encodeEdgeInsetsGeometry( - value.resolve({MaterialState.pressed}) as EdgeInsets?, - ), - 'scrolledUnder': encodeEdgeInsetsGeometry( - value.resolve({MaterialState.scrolledUnder}) as EdgeInsets?, - ), - 'selected': encodeEdgeInsetsGeometry( - value.resolve({MaterialState.selected}) as EdgeInsets?, - ), - }; - } - - return _stripDynamicNull(result); - } - - /// Encodes the [value] into a JSON representation. - /// - /// - /// ```json - /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "" - /// } - /// ``` - /// - /// See also: - /// * [encodeIconThemeData] - static Map? encodeMaterialStatePropertyIconThemeData( - MaterialStateProperty? value, { - bool validate = true, - }) { - Map? result; - - if (value != null) { - result = { - 'disabled': encodeIconThemeData( - value.resolve({MaterialState.disabled}), - ), - 'dragged': encodeIconThemeData(value.resolve({MaterialState.dragged})), - 'empty': encodeIconThemeData(value.resolve({})), - 'error': encodeIconThemeData(value.resolve({MaterialState.error})), - 'focused': encodeIconThemeData(value.resolve({MaterialState.focused})), - 'hovered': encodeIconThemeData(value.resolve({MaterialState.hovered})), - 'pressed': encodeIconThemeData(value.resolve({MaterialState.pressed})), - 'scrolledUnder': encodeIconThemeData( - value.resolve({MaterialState.selected}), - ), - 'selected': encodeIconThemeData( - value.resolve({MaterialState.selected}), - ), - }; - } - - return _stripDynamicNull(result); - } - - /// Encodes the [value] into a JSON representation. - /// - /// - /// ```json - /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "" - /// } - /// ``` - /// - /// See also: - /// * [encodeMouseCursor] - static Map? encodeMaterialStatePropertyMouseCursor( - MaterialStateProperty? value, { - bool validate = true, - }) { - Map? result; - - if (value != null) { - result = { - 'disabled': encodeMouseCursor(value.resolve({MaterialState.disabled})), - 'dragged': encodeMouseCursor(value.resolve({MaterialState.dragged})), - 'empty': encodeMouseCursor(value.resolve({})), - 'error': encodeMouseCursor(value.resolve({MaterialState.error})), - 'focused': encodeMouseCursor(value.resolve({MaterialState.focused})), - 'hovered': encodeMouseCursor(value.resolve({MaterialState.hovered})), - 'pressed': encodeMouseCursor(value.resolve({MaterialState.pressed})), - 'scrolledUnder': encodeMouseCursor(value.resolve( - {MaterialState.scrolledUnder}, - )), - 'selected': encodeMouseCursor(value.resolve({MaterialState.selected})), - }; - } - - return _stripDynamicNull(result); - } - - /// Encodes the [value] into a JSON representation. - /// - /// - /// ```json - /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "" - /// } - /// ``` - /// - /// See also: - /// * [encodeOutlinedBorder] - static Map? encodeMaterialStatePropertyOutlinedBorder( - MaterialStateProperty? value, { - bool validate = true, - }) { - Map? result; - - if (value != null) { - result = { - 'disabled': encodeOutlinedBorder( - value.resolve({MaterialState.disabled}), - ), - 'dragged': encodeOutlinedBorder(value.resolve({MaterialState.dragged})), - 'empty': encodeOutlinedBorder(value.resolve({})), - 'error': encodeOutlinedBorder(value.resolve({MaterialState.error})), - 'focused': encodeOutlinedBorder(value.resolve({MaterialState.focused})), - 'hovered': encodeOutlinedBorder(value.resolve({MaterialState.hovered})), - 'pressed': encodeOutlinedBorder(value.resolve({MaterialState.pressed})), - 'scrolledUnder': encodeOutlinedBorder( - value.resolve({MaterialState.scrolledUnder}), - ), - 'selected': encodeOutlinedBorder( - value.resolve({MaterialState.selected}), - ), - }; - } - - return _stripDynamicNull(result); - } - - /// Encodes the [value] into a JSON representation. - /// - /// - /// ```json - /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "" - /// } - /// ``` - /// - /// See also: - /// * [encodeSize] - static Map? encodeMaterialStatePropertySize( - MaterialStateProperty? value, { - bool validate = true, - }) { - Map? result; - - if (value != null) { - result = { - 'disabled': encodeSize(value.resolve({MaterialState.disabled})), - 'dragged': encodeSize(value.resolve({MaterialState.dragged})), - 'empty': encodeSize(value.resolve({})), - 'error': encodeSize(value.resolve({MaterialState.error})), - 'focused': encodeSize(value.resolve({MaterialState.focused})), - 'hovered': encodeSize(value.resolve({MaterialState.hovered})), - 'pressed': encodeSize(value.resolve({MaterialState.pressed})), - 'scrolledUnder': - encodeSize(value.resolve({MaterialState.scrolledUnder})), - 'selected': encodeSize(value.resolve({MaterialState.selected})), - }; - } - - return _stripDynamicNull(result); - } - - /// Encodes the [value] into a JSON representation. - /// - /// - /// ```json - /// { - /// "disabled": "", - /// "dragged": "", - /// "empty": "", - /// "error": "", - /// "focused": "", - /// "hovered": "", - /// "pressed": "", - /// "scrolledUnder": "", - /// "selected": "", - /// } - /// ``` - /// - /// See also: - /// * [encodeTextStyle] - static Map? encodeMaterialStatePropertyTextStyle( - MaterialStateProperty? value, { - bool validate = true, - }) { - Map? result; - - if (value != null) { - result = { - 'disabled': encodeTextStyle(value.resolve({MaterialState.disabled})), - 'dragged': encodeTextStyle(value.resolve({MaterialState.dragged})), - 'empty': encodeTextStyle(value.resolve({})), - 'error': encodeTextStyle(value.resolve({MaterialState.error})), - 'focused': encodeTextStyle(value.resolve({MaterialState.focused})), - 'hovered': encodeTextStyle(value.resolve({MaterialState.hovered})), - 'pressed': encodeTextStyle(value.resolve({MaterialState.pressed})), - 'scrolledUnder': encodeTextStyle(value.resolve( - {MaterialState.scrolledUnder}, - )), - 'selected': encodeTextStyle(value.resolve({MaterialState.selected})), - }; - } - - return _stripDynamicNull(result); - } - - /// Encodes the given [value] to the String representation. Supported values - /// are: - /// * `padded` - /// * `shrinkWrap` - /// - /// All other values, including `null`, will result in `null`. - static String? encodeMaterialTapTargetSize(MaterialTapTargetSize? value) { - String? result; - - if (value != null) { - switch (value) { - case MaterialTapTargetSize.padded: - result = 'padded'; - break; - case MaterialTapTargetSize.shrinkWrap: - result = 'shrinkWrap'; - break; - } - } - - return _stripDynamicNull(result); - } - - /// Encodes the given [value] to the String representation. Supported values - /// are: - /// * `button` - /// * `canvas` - /// * `card` - /// * `circle` - /// * `transparency` - /// - /// All other values, including `null`, will result in `null`. - static String? encodeMaterialType(MaterialType? value) { - String? result; - - if (value != null) { - switch (value) { - case MaterialType.button: - result = 'button'; - break; - case MaterialType.canvas: - result = 'canvas'; - break; - case MaterialType.card: - result = 'card'; - break; - case MaterialType.circle: - result = 'circle'; - break; - case MaterialType.transparency: - result = 'transparency'; - break; - } - } - - return _stripDynamicNull(result); - } - - /// Encodes the [value] to a [Matrix4]. This will encode the [value] into a 16 - /// element [List] of [double]. - /// - /// The array takes the following format: - /// ``` - /// [ - /// x0, - /// x1, - /// x2, - /// x3, - /// y0, - /// y1, - /// y2, - /// y3, - /// z0, - /// z1, - /// z2, - /// z3, - /// w0, - /// w1, - /// w2, - /// w3 - /// ] - /// ``` - static List? encodeMatrix4(Matrix4? value) { - List? result; - - if (value != null) { - result = [ - value.row0.x, - value.row1.x, - value.row2.x, - value.row3.x, - value.row0.y, - value.row1.y, - value.row2.y, - value.row3.y, - value.row0.z, - value.row1.z, - value.row2.z, - value.row3.z, - value.row0.w, - value.row1.w, - value.row2.w, - value.row3.w, - ]; - } - - return _stripDynamicNull(result); - } - - /// Encodes the [value] to a [MaxLengthEnforcement]. Supported values are: - /// * `enforced` - /// * `none` - /// * `truncateAfterCompositionEnds` - static String? encodeMaxLengthEnforcement( - MaxLengthEnforcement? value, { - bool validate = true, - }) { - String? result; - if (value != null) { - switch (value) { - case MaxLengthEnforcement.enforced: - result = 'enforced'; - break; - case MaxLengthEnforcement.none: - result = 'none'; - break; - case MaxLengthEnforcement.truncateAfterCompositionEnds: - result = 'truncateAfterCompositionEnds'; - break; - } - } - - return _stripDynamicNull(result); - } - - /// Encodes the given [value] to an JSON map. - /// - /// ```json - /// { - /// "style": "" - /// } - /// ``` - /// - /// See also: - /// * [encodeMenuStyle] - static Map? encodeMenuBarThemeData(MenuBarThemeData? value) { - Map? result; - - if (value != null) { - result = { - 'style': encodeMenuStyle( - value.style, - ), - }; - } - - return _stripDynamicNull(result); - } - - /// Encodes the given [value] to an JSON map. - /// - /// ```json - /// { - /// "style": "", - /// } - /// ``` - /// - /// See also: - /// * [encodeButtonStyle] - static Map? encodeMenuButtonThemeData( - MenuButtonThemeData? value, - ) { - Map? result; - - if (value != null) { - result = { - 'style': encodeButtonStyle(value.style), - }; - } - - return _stripDynamicNull(result); - } - - /// Encodes the given [value] to an JSON map. - /// - /// ```json - /// { - /// "alignment": "", - /// "backgroundColor": ">", - /// "elevation": ">", - /// "fixedSize": ">", - /// "maximumSize": ">", - /// "minimumSize": ">", - /// "padding": ">", - /// "shadowColor": ">", - /// "shape": ">", - /// "side": ">", - /// "surfaceTintColor": ">", - /// "visualDensity": "", - /// } - /// ``` - /// - /// See also: - /// * [encodeAlignment] - /// * [encodeMaterialStatePropertyBorderSide] - /// * [encodeMaterialStatePropertyColor] - /// * [encodeMaterialStatePropertyDouble] - /// * [encodeMaterialStatePropertyEdgeInsetsGeometry] - /// * [encodeMaterialStatePropertyMouseCursor] - /// * [encodeMaterialStatePropertySize] - /// * [encodeVisualDensity] - static Map? encodeMenuStyle(MenuStyle? value) { - Map? result; - - if (value != null) { - result = { - 'alignment': encodeAlignmentGeometry(value.alignment), - 'backgroundColor': encodeMaterialStatePropertyColor( - value.backgroundColor, - ), - 'elevation': encodeMaterialStatePropertyDouble(value.elevation), - 'fixedSize': encodeMaterialStatePropertySize(value.fixedSize), - 'maximumSize': encodeMaterialStatePropertySize(value.maximumSize), - 'minimumSize': encodeMaterialStatePropertySize(value.minimumSize), - 'mouseCursor': encodeMaterialStatePropertyMouseCursor( - value.mouseCursor, - ), - 'padding': encodeMaterialStatePropertyEdgeInsetsGeometry(value.padding), - 'shadowColor': encodeMaterialStatePropertyColor(value.shadowColor), - 'shape': encodeMaterialStatePropertyOutlinedBorder(value.shape), - 'side': encodeMaterialStatePropertyBorderSide(value.side), - 'surfaceTintColor': encodeMaterialStatePropertyColor( - value.surfaceTintColor, - ), - 'visualDensity': encodeVisualDensity(value.visualDensity), - }; - } - - return _stripDynamicNull(result); - } - - /// Encodes the given [value] to an JSON map. - /// - /// ```json - /// { - /// "style": "" - /// } - /// ``` - /// - /// See also: - /// * [encodeMenuStyle] - static Map? encodeMenuThemeData(MenuThemeData? value) { - Map? result; - - if (value != null) { - result = { - 'style': encodeMenuStyle(value.style), + 'style': encodeMenuStyle(value.style), }; } @@ -4448,12 +3951,12 @@ class ThemeEncoder { result = { 'type': 'uncontrolled', }; - } else if (MaterialStateMouseCursor.clickable == value) { + } else if (WidgetStateMouseCursor.clickable == value) { result = { 'cursor': 'clickable', 'type': 'material', }; - } else if (MaterialStateMouseCursor.textable == value) { + } else if (WidgetStateMouseCursor.textable == value) { result = { 'cursor': 'textable', 'type': 'material', @@ -4663,8 +4166,8 @@ class ThemeEncoder { /// /// See also: /// * [encodeColor] - /// * [encodeMaterialStatePropertyIconThemeData] - /// * [encodeMaterialStatePropertyTextStyle] + /// * [encodeWidgetStatePropertyIconThemeData] + /// * [encodeWidgetStatePropertyTextStyle] /// * [encodeNavigationDestinationLabelBehavior] static Map? encodeNavigationBarThemeData( NavigationBarThemeData? value, @@ -4676,7 +4179,7 @@ class ThemeEncoder { 'backgroundColor': encodeColor(value.backgroundColor), 'elevation': value.elevation, 'height': value.height, - 'iconTheme': encodeMaterialStatePropertyIconThemeData( + 'iconTheme': encodeWidgetStatePropertyIconThemeData( value.iconTheme, ), 'indicatorColor': encodeColor(value.indicatorColor), @@ -4684,7 +4187,7 @@ class ThemeEncoder { 'labelBehavior': encodeNavigationDestinationLabelBehavior( value.labelBehavior, ), - 'labelTextStyle': encodeMaterialStatePropertyTextStyle( + 'labelTextStyle': encodeWidgetStatePropertyTextStyle( value.labelTextStyle, ), 'shadowColor': encodeColor(value.shadowColor), @@ -5174,8 +4677,8 @@ class ThemeEncoder { /// /// See also: /// * [encodeColor] - /// * [encodeMaterialStatePropertyMouseCursor] - /// * [encodeMaterialStatePropertyTextStyle] + /// * [encodeWidgetStatePropertyMouseCursor] + /// * [encodeWidgetStatePropertyTextStyle] /// * [encodePopupMenuPosition] /// * [encodeShapeBorder] /// * [encodeTextStyle] @@ -5191,10 +4694,10 @@ class ThemeEncoder { 'enableFeedback': value.enableFeedback, 'iconColor': encodeColor(value.iconColor), 'iconSize': value.iconSize, - 'labelTextStyle': encodeMaterialStatePropertyTextStyle( + 'labelTextStyle': encodeWidgetStatePropertyTextStyle( value.labelTextStyle, ), - 'mouseCursor': encodeMaterialStatePropertyMouseCursor( + 'mouseCursor': encodeWidgetStatePropertyMouseCursor( value.mouseCursor, ), 'position': encodePopupMenuPosition(value.position), @@ -5266,16 +4769,16 @@ class ThemeEncoder { if (value != null) { result = { - 'fillColor': encodeMaterialStatePropertyColor( + 'fillColor': encodeWidgetStatePropertyColor( value.fillColor, ), 'materialTapTargetSize': encodeMaterialTapTargetSize( value.materialTapTargetSize, ), - 'mouseCursor': encodeMaterialStatePropertyMouseCursor( + 'mouseCursor': encodeWidgetStatePropertyMouseCursor( value.mouseCursor, ), - 'overlayColor': encodeMaterialStatePropertyColor( + 'overlayColor': encodeWidgetStatePropertyColor( value.overlayColor, ), 'splashRadius': value.splashRadius, @@ -5607,9 +5110,9 @@ class ThemeEncoder { /// ``` /// /// See also: - /// * [encodeMaterialStatePropertyBool] - /// * [encodeMaterialStatePropertyColor] - /// * [encodeMaterialStatePropertyDouble] + /// * [encodeWidgetStatePropertyBool] + /// * [encodeWidgetStatePropertyColor] + /// * [encodeWidgetStatePropertyDouble] /// * [encodeRadius] static Map? encodeScrollbarThemeData( ScrollbarThemeData? value, @@ -5623,18 +5126,18 @@ class ThemeEncoder { 'mainAxisMargin': value.mainAxisMargin, 'minThumbLength': value.minThumbLength, 'radius': encodeRadius(value.radius), - 'thickness': encodeMaterialStatePropertyDouble( + 'thickness': encodeWidgetStatePropertyDouble( value.thickness, ), - 'thumbColor': encodeMaterialStatePropertyColor(value.thumbColor), - 'thumbVisibility': encodeMaterialStatePropertyBool( + 'thumbColor': encodeWidgetStatePropertyColor(value.thumbColor), + 'thumbVisibility': encodeWidgetStatePropertyBool( value.thumbVisibility, ), - 'trackBorderColor': encodeMaterialStatePropertyColor( + 'trackBorderColor': encodeWidgetStatePropertyColor( value.trackBorderColor, ), - 'trackColor': encodeMaterialStatePropertyColor(value.trackColor), - 'trackVisibility': encodeMaterialStatePropertyBool( + 'trackColor': encodeWidgetStatePropertyColor(value.trackColor), + 'trackVisibility': encodeWidgetStatePropertyBool( value.trackVisibility, ), }; @@ -5665,12 +5168,12 @@ class ThemeEncoder { /// /// See also: /// * [encodeBoxConstraints] - /// * [encodeMaterialStatePropertyBorderSide] - /// * [encodeMaterialStatePropertyColor] - /// * [encodeMaterialStatePropertyDouble] - /// * [encodeMaterialStatePropertyEdgeInsetsGeometry] - /// * [encodeMaterialStatePropertyOutlinedBorder] - /// * [encodeMaterialStatePropertyTextStyle] + /// * [encodeWidgetStatePropertyBorderSide] + /// * [encodeWidgetStatePropertyColor] + /// * [encodeWidgetStatePropertyDouble] + /// * [encodeWidgetStatePropertyEdgeInsetsGeometry] + /// * [encodeWidgetStatePropertyOutlinedBorder] + /// * [encodeWidgetStatePropertyTextStyle] static Map? encodeSearchBarThemeData( SearchBarThemeData? value, ) { @@ -5678,21 +5181,21 @@ class ThemeEncoder { if (value != null) { result = { - 'backgroundColor': encodeMaterialStatePropertyColor( + 'backgroundColor': encodeWidgetStatePropertyColor( value.backgroundColor, ), 'constraints': encodeBoxConstraints(value.constraints), - 'elevation': encodeMaterialStatePropertyDouble(value.elevation), - 'hintStyle': encodeMaterialStatePropertyTextStyle(value.hintStyle), - 'overlayColor': encodeMaterialStatePropertyColor(value.overlayColor), - 'padding': encodeMaterialStatePropertyEdgeInsetsGeometry(value.padding), - 'shadowColor': encodeMaterialStatePropertyColor(value.shadowColor), - 'shape': encodeMaterialStatePropertyOutlinedBorder(value.shape), - 'side': encodeMaterialStatePropertyBorderSide(value.side), - 'surfaceTintColor': encodeMaterialStatePropertyColor( + 'elevation': encodeWidgetStatePropertyDouble(value.elevation), + 'hintStyle': encodeWidgetStatePropertyTextStyle(value.hintStyle), + 'overlayColor': encodeWidgetStatePropertyColor(value.overlayColor), + 'padding': encodeWidgetStatePropertyEdgeInsetsGeometry(value.padding), + 'shadowColor': encodeWidgetStatePropertyColor(value.shadowColor), + 'shape': encodeWidgetStatePropertyOutlinedBorder(value.shape), + 'side': encodeWidgetStatePropertyBorderSide(value.side), + 'surfaceTintColor': encodeWidgetStatePropertyColor( value.surfaceTintColor, ), - 'textStyle': encodeMaterialStatePropertyTextStyle(value.textStyle), + 'textStyle': encodeWidgetStatePropertyTextStyle(value.textStyle), 'textCapitalization': encodeTextCapitalization( value.textCapitalization, ), @@ -6052,7 +5555,7 @@ class ThemeEncoder { /// /// See also: /// * [encodeColor] - /// * [encodeMaterialStatePropertyMouseCursor] + /// * [encodeWidgetStatePropertyMouseCursor] /// * [encodeShowValueIndicator] /// * [encodeSliderComponentShape] /// * [encodeSliderInteraction] @@ -6085,7 +5588,7 @@ class ThemeEncoder { 'inactiveTickMarkColor': encodeColor(value.inactiveTickMarkColor), 'inactiveTrackColor': encodeColor(value.inactiveTrackColor), 'minThumbSeparation': (value.minThumbSeparation), - 'mouseCursor': encodeMaterialStatePropertyMouseCursor( + 'mouseCursor': encodeWidgetStatePropertyMouseCursor( value.mouseCursor, ), 'overlappingShapeStrokeColor': encodeColor( @@ -6395,9 +5898,9 @@ class ThemeEncoder { /// /// See also: /// * [encodeColor] - /// * [encodeMaterialStatePropertyColor] - /// * [encodeMaterialStatePropertyDouble] - /// * [encodeMaterialStatePropertyMouseCursor] + /// * [encodeWidgetStatePropertyColor] + /// * [encodeWidgetStatePropertyDouble] + /// * [encodeWidgetStatePropertyMouseCursor] /// * [encodeMaterialTapTargetSize] /// * [encodeMouseCursor] static Map? encodeSwitchThemeData( @@ -6411,23 +5914,23 @@ class ThemeEncoder { 'materialTapTargetSize': encodeMaterialTapTargetSize( value.materialTapTargetSize, ), - 'mouseCursor': encodeMaterialStatePropertyMouseCursor( + 'mouseCursor': encodeWidgetStatePropertyMouseCursor( value.mouseCursor, ), - 'overlayColor': encodeMaterialStatePropertyColor( + 'overlayColor': encodeWidgetStatePropertyColor( value.overlayColor, ), 'splashRadius': value.splashRadius, - 'thumbColor': encodeMaterialStatePropertyColor( + 'thumbColor': encodeWidgetStatePropertyColor( value.thumbColor, ), - 'trackColor': encodeMaterialStatePropertyColor( + 'trackColor': encodeWidgetStatePropertyColor( value.trackColor, ), - 'trackOutlineColor': encodeMaterialStatePropertyColor( + 'trackOutlineColor': encodeWidgetStatePropertyColor( value.trackColor, ), - 'trackOutlineWidth': encodeMaterialStatePropertyDouble( + 'trackOutlineWidth': encodeWidgetStatePropertyDouble( value.trackOutlineWidth, ), }; @@ -6573,8 +6076,8 @@ class ThemeEncoder { /// * [encodeColor] /// * [encodeEdgeInsetsGeometry] /// * [encodeInteractiveInkFeatureFactory] - /// * [encodeMaterialStatePropertyMouseCursor] - /// * [encodeMaterialStatePropertyMouseCursor] + /// * [encodeWidgetStatePropertyMouseCursor] + /// * [encodeWidgetStatePropertyMouseCursor] /// * [encodeTabAlignment] /// * [encodeTabBarIndicatorSize] /// * [encodeTextStyle] @@ -6591,10 +6094,10 @@ class ThemeEncoder { encodeEdgeInsetsGeometry(value.labelPadding as EdgeInsets?), 'labelColor': encodeColor(value.labelColor), 'labelStyle': encodeTextStyle(value.labelStyle), - 'mouseCursor': encodeMaterialStatePropertyMouseCursor( + 'mouseCursor': encodeWidgetStatePropertyMouseCursor( value.mouseCursor, ), - 'overlayColor': encodeMaterialStatePropertyColor( + 'overlayColor': encodeWidgetStatePropertyColor( value.overlayColor, ), 'splashFactory': encodeInteractiveInkFeatureFactory( @@ -6961,21 +6464,195 @@ class ThemeEncoder { } /// Encodes the [value] into a String representation. Supported values are: - /// * `ltr` - /// * `rtl` + /// * `ltr` + /// * `rtl` + /// + /// All other values, including `null`, will result in `null`. + static String? encodeTextDirection(TextDirection? value) { + String? result; + + if (value != null) { + switch (value) { + case TextDirection.ltr: + result = 'ltr'; + break; + + case TextDirection.rtl: + result = 'rtl'; + break; + } + } + + return _stripDynamicNull(result); + } + + /// Encodes the [value] into a String representation. Supported values are: + /// * `continueAction` + /// * `done` + /// * `emergencyCall` + /// * `go` + /// * `join` + /// * `newline` + /// * `next` + /// * `none` + /// * `previous` + /// * `route` + /// * `search` + /// * `send` + /// * `unspecified` + /// + /// All other values, including `null`, will result in `null`. + static String? encodeTextInputAction(TextInputAction? value) { + String? result; + + if (value != null) { + switch (value) { + case TextInputAction.continueAction: + result = 'continueAction'; + break; + + case TextInputAction.done: + result = 'done'; + break; + + case TextInputAction.emergencyCall: + result = 'emergencyCall'; + break; + + case TextInputAction.go: + result = 'go'; + break; + + case TextInputAction.join: + result = 'join'; + break; + + case TextInputAction.newline: + result = 'newline'; + break; + + case TextInputAction.next: + result = 'next'; + break; + + case TextInputAction.none: + result = 'none'; + break; + + case TextInputAction.previous: + result = 'previous'; + break; + + case TextInputAction.route: + result = 'route'; + break; + + case TextInputAction.search: + result = 'search'; + break; + + case TextInputAction.send: + result = 'send'; + break; + + case TextInputAction.unspecified: + result = 'unspecified'; + break; + } + } + + return _stripDynamicNull(result); + } + + /// Encodes the [value] into a String representation. Supported values are: + /// * `datetime` + /// * `emailAddress` + /// * `multiline` + /// * `name` + /// * `none` + /// * `number` + /// * `phone` + /// * `streetAddress` + /// * `text` + /// * `url` + /// * `visiblePassword` + /// + /// All other values, including `null`, will result in `null`. + static String? encodeTextInputType(TextInputType? value) { + String? result; + + if (value != null) { + if (value.index == TextInputType.datetime.index) { + result = 'datetime'; + } else if (value.index == TextInputType.emailAddress.index) { + result = 'emailAddress'; + } else if (value.index == TextInputType.multiline.index) { + result = 'multiline'; + } else if (value.index == TextInputType.name.index) { + result = 'name'; + } else if (value.index == TextInputType.none.index) { + result = 'none'; + } else if (value.index == TextInputType.number.index) { + result = 'number'; + } else if (value.index == TextInputType.phone.index) { + result = 'phone'; + } else if (value.index == TextInputType.streetAddress.index) { + result = 'streetAddress'; + } else if (value.index == TextInputType.text.index) { + result = 'text'; + } else if (value.index == TextInputType.url.index) { + result = 'url'; + } else if (value.index == TextInputType.visiblePassword.index) { + result = 'visiblePassword'; + } + } + + return _stripDynamicNull(result); + } + + /// Encodes the given [value] to the JSON representation. + /// + /// ```json + /// { + /// "applyHeightToFirstAscent": "", + /// "applyHeightToLastDescent": "", + /// "leadingDistribution": "" + /// } + /// ``` + static Map? encodeTextHeightBehavior( + TextHeightBehavior? value, + ) { + Map? result; + + if (value != null) { + result = { + 'applyHeightToFirstAscent': value.applyHeightToFirstAscent, + 'applyHeightToLastDescent': value.applyHeightToLastDescent, + 'leadingDistribution': encodeTextLeadingDistribution( + value.leadingDistribution, + ), + }; + } + + return _stripDynamicNull(result); + } + + /// Encodes the [value] into a String representation. Supported values are: + /// * `even` + /// * `proportional` /// /// All other values, including `null`, will result in `null`. - static String? encodeTextDirection(TextDirection? value) { + static String? encodeTextLeadingDistribution(TextLeadingDistribution? value) { String? result; if (value != null) { switch (value) { - case TextDirection.ltr: - result = 'ltr'; + case TextLeadingDistribution.even: + result = 'even'; break; - case TextDirection.rtl: - result = 'rtl'; + case TextLeadingDistribution.proportional: + result = 'proportional'; break; } } @@ -6984,205 +6661,563 @@ class ThemeEncoder { } /// Encodes the [value] into a String representation. Supported values are: - /// * `continueAction` - /// * `done` - /// * `emergencyCall` - /// * `go` - /// * `join` - /// * `newline` - /// * `next` - /// * `none` - /// * `previous` - /// * `route` - /// * `search` - /// * `send` - /// * `unspecified` + /// * `clip` + /// * `ellipsis` + /// * `fade` + /// * `visible` /// /// All other values, including `null`, will result in `null`. - static String? encodeTextInputAction(TextInputAction? value) { + static String? encodeTextOverflow(TextOverflow? value) { String? result; if (value != null) { switch (value) { - case TextInputAction.continueAction: - result = 'continueAction'; + case TextOverflow.clip: + result = 'clip'; break; - case TextInputAction.done: - result = 'done'; + case TextOverflow.ellipsis: + result = 'ellipsis'; break; - case TextInputAction.emergencyCall: - result = 'emergencyCall'; + case TextOverflow.fade: + result = 'fade'; break; - case TextInputAction.go: - result = 'go'; + case TextOverflow.visible: + result = 'visible'; break; + } + } - case TextInputAction.join: - result = 'join'; - break; + return _stripDynamicNull(result); + } - case TextInputAction.newline: - result = 'newline'; - break; + /// Encodes a given [value] into a JSON compatible Map structure. This will + /// return the following structure: + /// + /// ```json + /// "cursorColor": "", + /// "selectionColor": "", + /// "selectionHandleColor": "" + /// ``` + /// + /// See also: + /// * [encodeColor] + static Map? encodeTextSelectionThemeData( + TextSelectionThemeData? value, + ) { + Map? result; - case TextInputAction.next: - result = 'next'; - break; + if (value != null) { + result = { + 'cursorColor': encodeColor( + value.cursorColor, + ), + 'selectionColor': encodeColor( + value.selectionColor, + ), + 'selectionHandleColor': encodeColor( + value.selectionHandleColor, + ), + }; + } - case TextInputAction.none: - result = 'none'; - break; + return _stripDynamicNull(result); + } - case TextInputAction.previous: - result = 'previous'; - break; + /// Encodes a [TextStyle] object into a JSON map: + /// + /// ```json + /// { + /// "children": ">", + /// "locale": "", + /// "mouseCursor": "", + /// "onEnter": "", + /// "onExit": "", + /// "recognizer": "", + /// "semanticsLabel": "", + /// "spellOut": "", + /// "style": "", + /// "text": "" + /// } + /// ``` + /// + /// See Also: + /// * [encodeLocale] + /// * [encodeMouseCursor] + /// * [encodeTextStyle] + static Map? encodeTextSpan(TextSpan? value) { + Map? result; - case TextInputAction.route: - result = 'route'; - break; + if (value != null) { + result = { + 'children': value.children + ?.whereType() + .map((e) => encodeTextSpan(e)!) + .toList(), + 'locale': encodeLocale(value.locale), + 'mouseCursor': encodeMouseCursor(value.mouseCursor), + // 'onEnter': @unencodable, + // 'onExit': @unencodable, + // 'recognizer': @unencodable, + 'semanticsLabel': value.semanticsLabel, + 'spellOut': value.spellOut, + 'style': encodeTextStyle(value.style), + 'text': value.text, + }; + } - case TextInputAction.search: - result = 'search'; - break; + return _stripDynamicNull(result); + } - case TextInputAction.send: - result = 'send'; - break; + /// Encodes a given [value] into a JSON compatible Map structure. This will + /// return the following structure: + /// + /// ```json + /// { + /// "backgroundColor": "", + /// "color": "", + /// "decoration": "", + /// "decorationColor": "", + /// "decorationStyle": "", + /// "decorationThickness": "", + /// "fontFamily": value['fontFamily'], + /// "fontFamilyFallback": "", + /// "fontFeatures": "", + /// "fontSize": "", + /// "fontStyle": "", + /// "fontVariation": "", + /// "fontWeight": "", + /// "height": "", + /// "inherit": "", + /// "leadingDistribution": "", + /// "letterSpacing": "", + /// "locale": "", + /// "overflow": "", + /// "package": "", + /// "shadows": "", + /// "textBaseline": "", + /// "wordSpacing": "" + /// } + /// ``` + /// + /// See also: + /// * [encodeColor] + /// * [encodeFontFeature] + /// * [encodeFontStyle] + /// * [encodeFontVariation] + /// * [encodeFontWeight] + /// * [encodeLocale] + /// * [encodeShadow] + /// * [encodeTextBaseline] + /// * [encodeTextDecoration] + /// * [encodeTextDecorationStyle] + /// * [encodeTextLeadingDistribution] + /// * [encodeTextOverflow] + static Map? encodeTextStyle(TextStyle? value) { + Map? result; + + if (value != null) { + result = { + 'backgroundColor': encodeColor(value.backgroundColor), + 'color': encodeColor(value.color), + 'decoration': encodeTextDecoration(value.decoration), + 'decorationColor': encodeColor(value.decorationColor), + 'decorationStyle': encodeTextDecorationStyle(value.decorationStyle), + 'decorationThickness': value.decorationThickness, + 'fontFamily': value.fontFamily, + 'fontFamilyFallback': value.fontFamilyFallback, + 'fontFeatures': value.fontFeatures + ?.map( + (value) => encodeFontFeature(value), + ) + .toList(), + 'fontSize': value.fontSize, + 'fontStyle': encodeFontStyle(value.fontStyle), + 'fontVariations': value.fontVariations + ?.map( + (e) => encodeFontVariation(e), + ) + .toList(), + 'fontWeight': encodeFontWeight(value.fontWeight), + 'height': value.height, + 'inherit': value.inherit, + 'leadingDistribution': encodeTextLeadingDistribution( + value.leadingDistribution, + ), + 'letterSpacing': value.letterSpacing, + 'locale': encodeLocale(value.locale), + 'overflow': encodeTextOverflow(value.overflow), + 'shadows': value.shadows + ?.map( + (value) => encodeShadow(value), + ) + .toList(), + 'textBaseline': encodeTextBaseline(value.textBaseline), + 'wordSpacing': value.wordSpacing, + }; + } + + return _stripDynamicNull(result); + } + + /// Encodes the given [value] to a JSON compatible Map. The returned Map will + /// have the following structure: + /// + /// ```json + /// { + /// "bodyLarge": "", + /// "bodyMedium": "", + /// "bodySmall": "", + /// "displayLarge": "", + /// "displayMedium": "", + /// "displaySmall": "", + /// "headlineLarge": "", + /// "headlineMedium": "", + /// "headlineSmall": "", + /// "labelLarge": "", + /// "labelMedium": "", + /// "labelSmall": "", + /// "titleLarge": "", + /// "titleMedium": "", + /// "titleSmall": "" + /// } + /// ``` + /// + /// See also: + /// * [encodeTextStyle] + static Map? encodeTextTheme(TextTheme? value) { + Map? result; - case TextInputAction.unspecified: - result = 'unspecified'; - break; - } + if (value != null) { + result = { + 'bodyLarge': encodeTextStyle(value.bodyLarge), + 'bodyMedium': encodeTextStyle(value.bodyMedium), + 'bodySmall': encodeTextStyle(value.bodySmall), + 'displayLarge': encodeTextStyle(value.displayLarge), + 'displayMedium': encodeTextStyle(value.displayMedium), + 'displaySmall': encodeTextStyle(value.displaySmall), + 'headlineLarge': encodeTextStyle(value.headlineLarge), + 'headlineMedium': encodeTextStyle(value.headlineMedium), + 'headlineSmall': encodeTextStyle(value.headlineSmall), + 'labelLarge': encodeTextStyle(value.labelLarge), + 'labelMedium': encodeTextStyle(value.labelMedium), + 'labelSmall': encodeTextStyle(value.labelSmall), + 'titleLarge': encodeTextStyle(value.titleLarge), + 'titleMedium': encodeTextStyle(value.titleMedium), + 'titleSmall': encodeTextStyle(value.titleSmall), + }; } return _stripDynamicNull(result); } /// Encodes the [value] into a String representation. Supported values are: - /// * `datetime` - /// * `emailAddress` - /// * `multiline` - /// * `name` - /// * `none` - /// * `number` - /// * `phone` - /// * `streetAddress` - /// * `text` - /// * `url` - /// * `visiblePassword` + /// * `longestLine` + /// * `parent` /// /// All other values, including `null`, will result in `null`. - static String? encodeTextInputType(TextInputType? value) { + static String? encodeTextWidthBasis(TextWidthBasis? value) { String? result; if (value != null) { - if (value.index == TextInputType.datetime.index) { - result = 'datetime'; - } else if (value.index == TextInputType.emailAddress.index) { - result = 'emailAddress'; - } else if (value.index == TextInputType.multiline.index) { - result = 'multiline'; - } else if (value.index == TextInputType.name.index) { - result = 'name'; - } else if (value.index == TextInputType.none.index) { - result = 'none'; - } else if (value.index == TextInputType.number.index) { - result = 'number'; - } else if (value.index == TextInputType.phone.index) { - result = 'phone'; - } else if (value.index == TextInputType.streetAddress.index) { - result = 'streetAddress'; - } else if (value.index == TextInputType.text.index) { - result = 'text'; - } else if (value.index == TextInputType.url.index) { - result = 'url'; - } else if (value.index == TextInputType.visiblePassword.index) { - result = 'visiblePassword'; + switch (value) { + case TextWidthBasis.longestLine: + result = 'longestLine'; + break; + case TextWidthBasis.parent: + result = 'parent'; + break; } } return _stripDynamicNull(result); } - /// Encodes the given [value] to the JSON representation. + /// Encodes the given [value] to a JSON compatible Map. The returned Map will + /// have the following structure: /// /// ```json /// { - /// "applyHeightToFirstAscent": "", - /// "applyHeightToLastDescent": "", - /// "leadingDistribution": "" + /// "actionIconThemeData": "", + /// "appBarTheme": "", + /// "applyElevationOverlayColor": "", + /// "badgeTheme": "", + /// "bannerTheme": "", + /// "bottomAppBarTheme": "", + /// "bottomSheetTheme": "", + /// "brightness": "", + /// "buttonBarTheme": "", + /// "buttonTheme": "", + /// "canvasColor": "", + /// "cardColor": "", + /// "cardTheme": "", + /// "checkboxTheme": "", + /// "chipTheme": "", + /// "colorScheme": "", + /// "colorSchemeSeed": "", + /// "cupertinoOverrideTheme": "", + /// "datePickerTheme": "", + /// "dataTableTheme": "", + /// "dialogBackgroundColor": "", + /// "dialogTheme": "", + /// "disabledColor": "", + /// "dividerColor": "", + /// "dividerTheme": "", + /// "drawerTheme": "", + /// "dropdownMenuTheme": "", + /// "elevatedButtonTheme": "", + /// "expansionTileTheme": "", + /// "filledButtonTheme": """, + /// "floatingActionButtonTheme": "", + /// "focusColor": "", + /// "fontFamily": "", + /// "fontFamilyFallback": ">", + /// "highlightColor": "", + /// "hintColor": "", + /// "hoverColor": "", + /// "iconButtonTheme": "", + /// "iconTheme": "", + /// "indicatorColor": "", + /// "inputDecorationTheme": "", + /// "listTileTheme": "", + /// "materialTapTargetSize": "", + /// "menuBarTheme": "", + /// "menuButtonTheme": "", + /// "menuTheme": "", + /// "navigationBarTheme": "", + /// "navigationDrawerTheme": "", + /// "navigationRailTheme": "", + /// "outlinedButtonTheme": "", + /// "package": "", + /// "pageTransitionsTheme": "", + /// "platform": "", + /// "popupMenuTheme": "", + /// "primaryColor": "", + /// "primaryColorDark": "", + /// "primaryColorLight": "", + /// "primaryIconTheme": "", + /// "primarySwatch": "", + /// "primaryTextTheme": "", + /// "progressIndicatorTheme": "", + /// "radioTheme": "", + /// "scaffoldBackgroundColor": "", + /// "scrollbarTheme": "", + /// "searchBarTheme": "", + /// "searchViewTheme": "", + /// "secondaryHeaderColor": "", + /// "segmentedButtonTheme": "", + /// "shadowColor": "", + /// "sliderTheme": "", + /// "snackBarTheme": "", + /// "splashColor": "", + /// "splashFactory": "", + /// "switchTheme": "", + /// "tabBarTheme": "", + /// "textButtonTheme": "", + /// "textSelectionTheme": "", + /// "textTheme": "", + /// "timePickerTheme": "", + /// "toggleButtonsTheme": "", + /// "tooltipTheme": "", + /// "typography": "", + /// "unselectedWidgetColor": "", + /// "useMaterial3": "", + /// "visualDensity": "" /// } /// ``` - static Map? encodeTextHeightBehavior( - TextHeightBehavior? value, - ) { - Map? result; - - if (value != null) { - result = { - 'applyHeightToFirstAscent': value.applyHeightToFirstAscent, - 'applyHeightToLastDescent': value.applyHeightToLastDescent, - 'leadingDistribution': encodeTextLeadingDistribution( - value.leadingDistribution, - ), - }; - } - - return _stripDynamicNull(result); - } - - /// Encodes the [value] into a String representation. Supported values are: - /// * `even` - /// * `proportional` /// - /// All other values, including `null`, will result in `null`. - static String? encodeTextLeadingDistribution(TextLeadingDistribution? value) { - String? result; + /// See also: + /// * [encodeActionIconThemeData] + /// * [encodeAppBarTheme] + /// * [encodeBadgeThemeData] + /// * [encodeBrightness] + /// * [encodeBottomAppBarTheme] + /// * [encodeBottomSheetThemeData] + /// * [encodeButtonBarThemeData] + /// * [encodeButtonThemeData] + /// * [encodeCardTheme] + /// * [encodeCheckboxThemeData] + /// * [encodeChipThemeData] + /// * [encodeColor] + /// * [encodeColorScheme] + /// * [encodeDatePickerThemeData] + /// * [encodeDataTableThemeData] + /// * [encodeDialogTheme] + /// * [encodeDividerThemeData] + /// * [encodeDrawerThemeData] + /// * [encodeElevatedButtonThemeData] + /// * [encodeExpansionTileThemeData] + /// * [encodeFilledButtonThemeData] + /// * [encodeFloatingActionButtonThemeData] + /// * [encodeIconButtonThemeData] + /// * [encodeIconThemeData] + /// * [encodeInputDecorationTheme] + /// * [encodeInteractiveInkFeatureFactory] + /// * [encodeListTileThemeData] + /// * [encodeMaterialBannerThemeData] + /// * [encodeMaterialTapTargetSize] + /// * [encodeMenuBarThemeData] + /// * [encodeMenuButtonThemeData] + /// * [encodeMenuThemeData] + /// * [encodeNavigationBarThemeData] + /// * [encodeNavigationRailThemeData] + /// * [encodeOutlinedButtonThemeData] + /// * [encodePopupMenuThemeData] + /// * [encodeRadioThemeData] + /// * [encodeSearchBarThemeData] + /// * [encodeSearchViewThemeData] + /// * [encodeSegmentedButtonThemeData] + /// * [encodeSliderThemeData] + /// * [encodeSnackBarThemeData] + /// * [encodeSwitchThemeData] + /// * [encodeTabBarTheme] + /// * [encodeTargetPlatform] + /// * [encodeTextButtonThemeData] + /// * [encodeTextSelectionThemeData] + /// * [encodeTextStyle] + /// * [encodeToggleButtonsThemeData] + /// * [encodeTypography] + /// * [encodeVisualDensity] + static Map? encodeThemeData(ThemeData? value) { + Map? result; if (value != null) { - switch (value) { - case TextLeadingDistribution.even: - result = 'even'; - break; - - case TextLeadingDistribution.proportional: - result = 'proportional'; - break; - } + result = { + 'actionIconTheme': encodeActionIconThemeData(value.actionIconTheme), + 'appBarTheme': encodeAppBarTheme(value.appBarTheme), + 'applyElevationOverlayColor': value.applyElevationOverlayColor, + 'badgeTheme': encodeBadgeThemeData(value.badgeTheme), + 'bannerTheme': encodeMaterialBannerThemeData(value.bannerTheme), + 'bottomAppBarTheme': encodeBottomAppBarTheme(value.bottomAppBarTheme), + 'bottomNavigationBarTheme': encodeBottomNavigationBarThemeData( + value.bottomNavigationBarTheme, + ), + 'bottomSheetTheme': encodeBottomSheetThemeData(value.bottomSheetTheme), + 'brightness': encodeBrightness(value.brightness), + 'buttonBarTheme': encodeButtonBarThemeData(value.buttonBarTheme), + 'buttonTheme': encodeButtonThemeData(value.buttonTheme), + 'canvasColor': encodeColor(value.canvasColor), + 'cardColor': encodeColor(value.cardColor), + 'cardTheme': encodeCardTheme(value.cardTheme), + 'checkboxTheme': encodeCheckboxThemeData(value.checkboxTheme), + 'chipTheme': encodeChipThemeData(value.chipTheme), + 'colorScheme': encodeColorScheme(value.colorScheme), + // 'colorSchemeSeed': @nonexistant, + 'cupertinoOverrideTheme': encodeCupertinoThemeData( + value.cupertinoOverrideTheme, + ), + 'datePickerThemeData': encodeDatePickerThemeData(value.datePickerTheme), + 'dataTableTheme': encodeDataTableThemeData(value.dataTableTheme), + 'dialogBackgroundColor': encodeColor(value.dialogBackgroundColor), + 'dialogTheme': encodeDialogTheme(value.dialogTheme), + 'disabledColor': encodeColor(value.disabledColor), + 'dividerColor': encodeColor(value.dividerColor), + 'dividerTheme': encodeDividerThemeData(value.dividerTheme), + 'drawerTheme': encodeDrawerThemeData(value.drawerTheme), + 'elevatedButtonTheme': encodeElevatedButtonThemeData( + value.elevatedButtonTheme, + ), + 'expansionTileThemeData': encodeExpansionTileThemeData( + value.expansionTileTheme, + ), + 'filledButtonTheme': encodeFilledButtonThemeData( + value.filledButtonTheme, + ), + 'floatingActionButtonTheme': encodeFloatingActionButtonThemeData( + value.floatingActionButtonTheme, + ), + 'focusColor': encodeColor(value.focusColor), + 'highlightColor': encodeColor(value.highlightColor), + 'hintColor': encodeColor(value.hintColor), + 'hoverColor': encodeColor(value.hoverColor), + 'iconButtonTheme': encodeIconButtonThemeData(value.iconButtonTheme), + 'iconTheme': encodeIconThemeData(value.iconTheme), + 'indicatorColor': encodeColor(value.indicatorColor), + 'inputDecorationTheme': encodeInputDecorationTheme( + value.inputDecorationTheme, + ), + 'listTileTheme': encodeListTileThemeData(value.listTileTheme), + 'materialTapTargetSize': encodeMaterialTapTargetSize( + value.materialTapTargetSize, + ), + 'menuBarTheme': encodeMenuBarThemeData(value.menuBarTheme), + 'menuButtonTheme': encodeMenuButtonThemeData(value.menuButtonTheme), + 'menuTheme': encodeMenuThemeData(value.menuTheme), + 'navigationBarTheme': encodeNavigationBarThemeData( + value.navigationBarTheme, + ), + 'navigationRailTheme': encodeNavigationRailThemeData( + value.navigationRailTheme, + ), + 'outlinedButtonTheme': encodeOutlinedButtonThemeData( + value.outlinedButtonTheme, + ), + 'platform': encodeTargetPlatform(value.platform), + 'popupMenuTheme': encodePopupMenuThemeData(value.popupMenuTheme), + 'primaryColor': encodeColor(value.primaryColor), + 'primaryColorDark': encodeColor(value.primaryColorDark), + 'primaryColorLight': encodeColor(value.primaryColorLight), + 'primaryIconTheme': encodeIconThemeData(value.primaryIconTheme), + 'primaryTextTheme': encodeTextTheme(value.primaryTextTheme), + 'radioTheme': encodeRadioThemeData(value.radioTheme), + 'scaffoldBackgroundColor': encodeColor(value.scaffoldBackgroundColor), + 'searchBarTheme': encodeSearchBarThemeData(value.searchBarTheme), + 'searchViewTheme': encodeSearchViewThemeData(value.searchViewTheme), + 'secondaryHeaderColor': encodeColor(value.secondaryHeaderColor), + 'shadowColor': encodeColor(value.shadowColor), + 'sliderTheme': encodeSliderThemeData(value.sliderTheme), + 'snackBarTheme': encodeSnackBarThemeData(value.snackBarTheme), + 'splashColor': encodeColor(value.splashColor), + 'splashFactory': + encodeInteractiveInkFeatureFactory(value.splashFactory), + 'switchTheme': encodeSwitchThemeData(value.switchTheme), + 'tabBarTheme': encodeTabBarTheme(value.tabBarTheme), + 'textButtonTheme': encodeTextButtonThemeData(value.textButtonTheme), + 'textSelectionTheme': encodeTextSelectionThemeData( + value.textSelectionTheme, + ), + 'textTheme': encodeTextTheme(value.textTheme), + 'toggleButtonsTheme': encodeToggleButtonsThemeData( + value.toggleButtonsTheme, + ), + 'tooltipTheme': encodeTooltipThemeData(value.tooltipTheme), + 'typography': encodeTypography(value.typography), + 'unselectedWidgetColor': encodeColor(value.unselectedWidgetColor), + 'useMaterial3': value.useMaterial3, + 'visualDensity': encodeVisualDensity(value.visualDensity), + }; } return _stripDynamicNull(result); } - /// Encodes the [value] into a String representation. Supported values are: - /// * `clip` - /// * `ellipsis` - /// * `fade` - /// * `visible` - /// - /// All other values, including `null`, will result in `null`. - static String? encodeTextOverflow(TextOverflow? value) { + /// Encodes the [value] to a [TileMode]. Supported values are: + /// * `clamp` + /// * `decal` + /// * `mirror` + /// * `repeated` + static String? encodeTileMode(TileMode? value) { String? result; if (value != null) { switch (value) { - case TextOverflow.clip: - result = 'clip'; + case TileMode.clamp: + result = 'clamp'; break; - case TextOverflow.ellipsis: - result = 'ellipsis'; + case TileMode.decal: + result = 'decal'; break; - case TextOverflow.fade: - result = 'fade'; + case TileMode.mirror: + result = 'mirror'; break; - case TextOverflow.visible: - result = 'visible'; + case TileMode.repeated: + result = 'repeated'; break; } } @@ -7190,812 +7225,776 @@ class ThemeEncoder { return _stripDynamicNull(result); } - /// Encodes a given [value] into a JSON compatible Map structure. This will - /// return the following structure: + /// encodes the given [value] to a [TimePickerThemeData]. This expects the + /// [value] to have the following structure: /// /// ```json - /// "cursorColor": "", - /// "selectionColor": "", - /// "selectionHandleColor": "" + /// { + /// "backgroundColor": "", + /// "cancelButtonStyle": "", + /// "confirmButtonStyle": "", + /// "dayPeriodBorderSide": "", + /// "dayPeriodColor": "", + /// "dayPeriodShape": "", + /// "dayPeriodTextColor": "", + /// "dayPeriodTextStyle": "", + /// "dialBackgroundColor": "", + /// "dialHandColor": "", + /// "dialTextColor": "", + /// "dialTextStyle": "", + /// "elevation": "", + /// "entryModeIconColor": "", + /// "helpTextStyle": "", + /// "hourMinuteColor": "", + /// "hourMinuteShape": "", + /// "hourMinuteTextColor": "", + /// "hourMinuteTextStyle": "", + /// "inputDecorationTheme": "", + /// "padding": "", + /// "shape": "" + /// } /// ``` /// /// See also: + /// * [encodeBorderSide] + /// * [encodeButtonStyle] /// * [encodeColor] - static Map? encodeTextSelectionThemeData( - TextSelectionThemeData? value, + /// * [encodeInputDecorationTheme] + /// * [encodeShapeBorder] + /// * [encodeTextStyle] + static Map? encodeTimePickerThemeData( + TimePickerThemeData? value, ) { Map? result; if (value != null) { result = { - 'cursorColor': encodeColor( - value.cursorColor, - ), - 'selectionColor': encodeColor( - value.selectionColor, - ), - 'selectionHandleColor': encodeColor( - value.selectionHandleColor, - ), - }; - } - - return _stripDynamicNull(result); - } - - /// Encodes a [TextStyle] object into a JSON map: - /// - /// ```json - /// { - /// "children": ">", - /// "locale": "", - /// "mouseCursor": "", - /// "onEnter": "", - /// "onExit": "", - /// "recognizer": "", - /// "semanticsLabel": "", - /// "spellOut": "", - /// "style": "", - /// "text": "" - /// } - /// ``` - /// - /// See Also: - /// * [encodeLocale] - /// * [encodeMouseCursor] - /// * [encodeTextStyle] - static Map? encodeTextSpan(TextSpan? value) { - Map? result; - - if (value != null) { - result = { - 'children': value.children - ?.whereType() - .map((e) => encodeTextSpan(e)!) - .toList(), - 'locale': encodeLocale(value.locale), - 'mouseCursor': encodeMouseCursor(value.mouseCursor), - // 'onEnter': @unencodable, - // 'onExit': @unencodable, - // 'recognizer': @unencodable, - 'semanticsLabel': value.semanticsLabel, - 'spellOut': value.spellOut, - 'style': encodeTextStyle(value.style), - 'text': value.text, + 'backgroundColor': encodeColor(value.backgroundColor), + 'cancelButtonStyle': encodeButtonStyle(value.cancelButtonStyle), + 'confirmButtonStyle': encodeButtonStyle(value.confirmButtonStyle), + 'dayPeriodBorderSide': encodeBorderSide(value.dayPeriodBorderSide), + 'dayPeriodColor': encodeColor(value.dayPeriodColor), + 'dayPeriodShape': encodeShapeBorder(value.dayPeriodShape), + 'dayPeriodTextColor': encodeColor(value.dayPeriodTextColor), + 'dayPeriodTextStyle': encodeTextStyle(value.dayPeriodTextStyle), + 'dialBackgroundColor': encodeColor(value.dialBackgroundColor), + 'dialHandColor': encodeColor(value.dialHandColor), + 'dialTextColor': encodeColor(value.dialTextColor), + 'dialTextStyle': encodeTextStyle(value.dialTextStyle), + 'elevation': value.elevation, + 'entryModeIconColor': encodeColor(value.entryModeIconColor), + 'helpTextStyle': encodeTextStyle(value.helpTextStyle), + 'hourMinuteColor': encodeColor(value.hourMinuteColor), + 'hourMinuteShape': encodeShapeBorder(value.hourMinuteShape), + 'hourMinuteTextColor': encodeColor(value.hourMinuteTextColor), + 'hourMinuteTextStyle': encodeTextStyle(value.hourMinuteTextStyle), + 'inputDecorationTheme': encodeInputDecorationTheme( + value.inputDecorationTheme, + ), + 'padding': encodeEdgeInsetsGeometry(value.padding as EdgeInsets?), + 'shape': encodeShapeBorder(value.shape), }; } return _stripDynamicNull(result); } - /// Encodes a given [value] into a JSON compatible Map structure. This will - /// return the following structure: + /// Encodes the given [value] to a JSON compatible Map. The returned returned + /// value will have the following structure. /// /// ```json /// { - /// "backgroundColor": "", + /// "borderColor": "", + /// "borderRadius": "", + /// "borderWidth": "", /// "color": "", - /// "decoration": "", - /// "decorationColor": "", - /// "decorationStyle": "", - /// "decorationThickness": "", - /// "fontFamily": value['fontFamily'], - /// "fontFamilyFallback": "", - /// "fontFeatures": "", - /// "fontSize": "", - /// "fontStyle": "", - /// "fontVariation": "", - /// "fontWeight": "", - /// "height": "", - /// "inherit": "", - /// "leadingDistribution": "", - /// "letterSpacing": "", - /// "locale": "", - /// "overflow": "", - /// "package": "", - /// "shadows": "", - /// "textBaseline": "", - /// "wordSpacing": "" + /// "constraints": "", + /// "disabledBorderColor": "", + /// "disabledColor": "", + /// "fillColor": "", + /// "focusColor": "", + /// "highlightColor": "", + /// "hoverColor": "", + /// "selectedBorderColor": "", + /// "selectedColor": "", + /// "splashColor": "", + /// "textStyle": "" /// } /// ``` /// /// See also: + /// * [encodeBorderRadius] + /// * [encodeBoxConstraints] /// * [encodeColor] - /// * [encodeFontFeature] - /// * [encodeFontStyle] - /// * [encodeFontVariation] - /// * [encodeFontWeight] - /// * [encodeLocale] - /// * [encodeShadow] - /// * [encodeTextBaseline] - /// * [encodeTextDecoration] - /// * [encodeTextDecorationStyle] - /// * [encodeTextLeadingDistribution] - /// * [encodeTextOverflow] - static Map? encodeTextStyle(TextStyle? value) { + /// * [encodeTextStyle] + static Map? encodeToggleButtonsThemeData( + ToggleButtonsThemeData? value, + ) { Map? result; if (value != null) { result = { - 'backgroundColor': encodeColor(value.backgroundColor), + 'borderColor': encodeColor(value.borderColor), + 'borderRadius': encodeBorderRadius(value.borderRadius), + 'borderWidth': value.borderWidth, 'color': encodeColor(value.color), - 'decoration': encodeTextDecoration(value.decoration), - 'decorationColor': encodeColor(value.decorationColor), - 'decorationStyle': encodeTextDecorationStyle(value.decorationStyle), - 'decorationThickness': value.decorationThickness, - 'fontFamily': value.fontFamily, - 'fontFamilyFallback': value.fontFamilyFallback, - 'fontFeatures': value.fontFeatures - ?.map( - (value) => encodeFontFeature(value), - ) - .toList(), - 'fontSize': value.fontSize, - 'fontStyle': encodeFontStyle(value.fontStyle), - 'fontVariations': value.fontVariations - ?.map( - (e) => encodeFontVariation(e), - ) - .toList(), - 'fontWeight': encodeFontWeight(value.fontWeight), - 'height': value.height, - 'inherit': value.inherit, - 'leadingDistribution': encodeTextLeadingDistribution( - value.leadingDistribution, - ), - 'letterSpacing': value.letterSpacing, - 'locale': encodeLocale(value.locale), - 'overflow': encodeTextOverflow(value.overflow), - 'shadows': value.shadows - ?.map( - (value) => encodeShadow(value), - ) - .toList(), - 'textBaseline': encodeTextBaseline(value.textBaseline), - 'wordSpacing': value.wordSpacing, + 'constraints': encodeBoxConstraints(value.constraints), + 'disabledBorderColor': encodeColor(value.disabledBorderColor), + 'disabledColor': encodeColor(value.disabledColor), + 'fillColor': encodeColor(value.fillColor), + 'focusColor': encodeColor(value.focusColor), + 'highlightColor': encodeColor(value.highlightColor), + 'hoverColor': encodeColor(value.hoverColor), + 'selectedBorderColor': encodeColor(value.selectedBorderColor), + 'selectedColor': encodeColor(value.selectedColor), + 'splashColor': encodeColor(value.splashColor), + 'textStyle': encodeTextStyle(value.textStyle), }; } return _stripDynamicNull(result); } - /// Encodes the given [value] to a JSON compatible Map. The returned Map will - /// have the following structure: + /// Encodes the given [value] to a JSON compatible Map. The returned returned + /// value will have the following structure. /// /// ```json /// { - /// "bodyLarge": "", - /// "bodyMedium": "", - /// "bodySmall": "", - /// "displayLarge": "", - /// "displayMedium": "", - /// "displaySmall": "", - /// "headlineLarge": "", - /// "headlineMedium": "", - /// "headlineSmall": "", - /// "labelLarge": "", - /// "labelMedium": "", - /// "labelSmall": "", - /// "titleLarge": "", - /// "titleMedium": "", - /// "titleSmall": "" + /// "enableFeedback": "", + /// "excludeFromSemantics": "", + /// "height": "", + /// "margin": "", + /// "padding": "", + /// "preferBelow": "" + /// "showDuration": "", + /// "textAlign": "", + /// "textStyle": "", + /// "triggerMode": "", + /// "verticalOffset": "", + /// "waitDuration": "" /// } /// ``` /// /// See also: + /// * [encodeEdgeInsetsGeometry] /// * [encodeTextStyle] - static Map? encodeTextTheme(TextTheme? value) { + /// * [encodeTooltipTriggerMode] + static Map? encodeTooltipThemeData(TooltipThemeData? value) { Map? result; if (value != null) { result = { - 'bodyLarge': encodeTextStyle(value.bodyLarge), - 'bodyMedium': encodeTextStyle(value.bodyMedium), - 'bodySmall': encodeTextStyle(value.bodySmall), - 'displayLarge': encodeTextStyle(value.displayLarge), - 'displayMedium': encodeTextStyle(value.displayMedium), - 'displaySmall': encodeTextStyle(value.displaySmall), - 'headlineLarge': encodeTextStyle(value.headlineLarge), - 'headlineMedium': encodeTextStyle(value.headlineMedium), - 'headlineSmall': encodeTextStyle(value.headlineSmall), - 'labelLarge': encodeTextStyle(value.labelLarge), - 'labelMedium': encodeTextStyle(value.labelMedium), - 'labelSmall': encodeTextStyle(value.labelSmall), - 'titleLarge': encodeTextStyle(value.titleLarge), - 'titleMedium': encodeTextStyle(value.titleMedium), - 'titleSmall': encodeTextStyle(value.titleSmall), + 'enableFeedback': value.enableFeedback, + 'excludeFromSemantics': value.excludeFromSemantics, + 'height': value.height, + 'margin': encodeEdgeInsetsGeometry(value.margin as EdgeInsets?), + 'padding': encodeEdgeInsetsGeometry(value.padding as EdgeInsets?), + 'preferBelow': value.preferBelow, + 'showDuration': value.showDuration?.inMilliseconds, + 'textAlign': encodeTextAlign(value.textAlign), + 'textStyle': encodeTextStyle(value.textStyle), + 'triggerMode': encodeTooltipTriggerMode(value.triggerMode), + 'verticalOffset': value.verticalOffset, + 'waitDuration': value.waitDuration?.inMilliseconds, }; } return _stripDynamicNull(result); } - /// Encodes the [value] into a String representation. Supported values are: - /// * `longestLine` - /// * `parent` + /// Encodes the given [value] to the String representation. Supported values + /// are: + /// * `longPress` + /// * `manual` + /// * `tap` /// /// All other values, including `null`, will result in `null`. - static String? encodeTextWidthBasis(TextWidthBasis? value) { + static String? encodeTooltipTriggerMode(TooltipTriggerMode? value) { String? result; if (value != null) { - switch (value) { - case TextWidthBasis.longestLine: - result = 'longestLine'; - break; - case TextWidthBasis.parent: - result = 'parent'; - break; - } - } - - return _stripDynamicNull(result); - } - - /// Encodes the given [value] to a JSON compatible Map. The returned Map will - /// have the following structure: - /// - /// ```json - /// { - /// "actionIconThemeData": "", - /// "appBarTheme": "", - /// "applyElevationOverlayColor": "", - /// "badgeTheme": "", - /// "bannerTheme": "", - /// "bottomAppBarTheme": "", - /// "bottomSheetTheme": "", - /// "brightness": "", - /// "buttonBarTheme": "", - /// "buttonTheme": "", - /// "canvasColor": "", - /// "cardColor": "", - /// "cardTheme": "", - /// "checkboxTheme": "", - /// "chipTheme": "", - /// "colorScheme": "", - /// "colorSchemeSeed": "", - /// "cupertinoOverrideTheme": "", - /// "datePickerTheme": "", - /// "dataTableTheme": "", - /// "dialogBackgroundColor": "", - /// "dialogTheme": "", - /// "disabledColor": "", - /// "dividerColor": "", - /// "dividerTheme": "", - /// "drawerTheme": "", - /// "dropdownMenuTheme": "", - /// "elevatedButtonTheme": "", - /// "expansionTileTheme": "", - /// "filledButtonTheme": """, - /// "floatingActionButtonTheme": "", - /// "focusColor": "", - /// "fontFamily": "", - /// "fontFamilyFallback": ">", - /// "highlightColor": "", - /// "hintColor": "", - /// "hoverColor": "", - /// "iconButtonTheme": "", - /// "iconTheme": "", - /// "indicatorColor": "", - /// "inputDecorationTheme": "", - /// "listTileTheme": "", - /// "materialTapTargetSize": "", - /// "menuBarTheme": "", - /// "menuButtonTheme": "", - /// "menuTheme": "", - /// "navigationBarTheme": "", - /// "navigationDrawerTheme": "", - /// "navigationRailTheme": "", - /// "outlinedButtonTheme": "", - /// "package": "", - /// "pageTransitionsTheme": "", + if (value == TooltipTriggerMode.longPress) { + result = 'longPress'; + } else if (value == TooltipTriggerMode.manual) { + result = 'manual'; + } else if (value == TooltipTriggerMode.tap) { + result = 'tap'; + } + } + + return _stripDynamicNull(result); + } + + /// Encodes the given [value] to a JSON compatible Map. The returned returned + /// value will have the following structure. + /// + /// ```json + /// { + /// "black": "", + /// "dense": "", + /// "englishLike": "", /// "platform": "", - /// "popupMenuTheme": "", - /// "primaryColor": "", - /// "primaryColorDark": "", - /// "primaryColorLight": "", - /// "primaryIconTheme": "", - /// "primarySwatch": "", - /// "primaryTextTheme": "", - /// "progressIndicatorTheme": "", - /// "radioTheme": "", - /// "scaffoldBackgroundColor": "", - /// "scrollbarTheme": "", - /// "searchBarTheme": "", - /// "searchViewTheme": "", - /// "secondaryHeaderColor": "", - /// "segmentedButtonTheme": "", - /// "shadowColor": "", - /// "sliderTheme": "", - /// "snackBarTheme": "", - /// "splashColor": "", - /// "splashFactory": "", - /// "switchTheme": "", - /// "tabBarTheme": "", - /// "textButtonTheme": "", - /// "textSelectionTheme": "", - /// "textTheme": "", - /// "timePickerTheme": "", - /// "toggleButtonsTheme": "", - /// "tooltipTheme": "", - /// "typography": "", - /// "unselectedWidgetColor": "", - /// "useMaterial3": "", - /// "visualDensity": "" + /// "tall": "", + /// "white": "", /// } /// ``` /// /// See also: - /// * [encodeActionIconThemeData] - /// * [encodeAppBarTheme] - /// * [encodeBadgeThemeData] - /// * [encodeBrightness] - /// * [encodeBottomAppBarTheme] - /// * [encodeBottomSheetThemeData] - /// * [encodeButtonBarThemeData] - /// * [encodeButtonThemeData] - /// * [encodeCardTheme] - /// * [encodeCheckboxThemeData] - /// * [encodeChipThemeData] - /// * [encodeColor] - /// * [encodeColorScheme] - /// * [encodeDatePickerThemeData] - /// * [encodeDataTableThemeData] - /// * [encodeDialogTheme] - /// * [encodeDividerThemeData] - /// * [encodeDrawerThemeData] - /// * [encodeElevatedButtonThemeData] - /// * [encodeExpansionTileThemeData] - /// * [encodeFilledButtonThemeData] - /// * [encodeFloatingActionButtonThemeData] - /// * [encodeIconButtonThemeData] - /// * [encodeIconThemeData] - /// * [encodeInputDecorationTheme] - /// * [encodeInteractiveInkFeatureFactory] - /// * [encodeListTileThemeData] - /// * [encodeMaterialBannerThemeData] - /// * [encodeMaterialTapTargetSize] - /// * [encodeMenuBarThemeData] - /// * [encodeMenuButtonThemeData] - /// * [encodeMenuThemeData] - /// * [encodeNavigationBarThemeData] - /// * [encodeNavigationRailThemeData] - /// * [encodeOutlinedButtonThemeData] - /// * [encodePopupMenuThemeData] - /// * [encodeRadioThemeData] - /// * [encodeSearchBarThemeData] - /// * [encodeSearchViewThemeData] - /// * [encodeSegmentedButtonThemeData] - /// * [encodeSliderThemeData] - /// * [encodeSnackBarThemeData] - /// * [encodeSwitchThemeData] - /// * [encodeTabBarTheme] /// * [encodeTargetPlatform] - /// * [encodeTextButtonThemeData] - /// * [encodeTextSelectionThemeData] - /// * [encodeTextStyle] - /// * [encodeToggleButtonsThemeData] - /// * [encodeTypography] - /// * [encodeVisualDensity] - static Map? encodeThemeData(ThemeData? value) { + /// * [encodeTextTheme] + static Map? encodeTypography(Typography? value) { Map? result; if (value != null) { result = { - 'actionIconTheme': encodeActionIconThemeData(value.actionIconTheme), - 'appBarTheme': encodeAppBarTheme(value.appBarTheme), - 'applyElevationOverlayColor': value.applyElevationOverlayColor, - 'badgeTheme': encodeBadgeThemeData(value.badgeTheme), - 'bannerTheme': encodeMaterialBannerThemeData(value.bannerTheme), - 'bottomAppBarTheme': encodeBottomAppBarTheme(value.bottomAppBarTheme), - 'bottomNavigationBarTheme': encodeBottomNavigationBarThemeData( - value.bottomNavigationBarTheme, - ), - 'bottomSheetTheme': encodeBottomSheetThemeData(value.bottomSheetTheme), - 'brightness': encodeBrightness(value.brightness), - 'buttonBarTheme': encodeButtonBarThemeData(value.buttonBarTheme), - 'buttonTheme': encodeButtonThemeData(value.buttonTheme), - 'canvasColor': encodeColor(value.canvasColor), - 'cardColor': encodeColor(value.cardColor), - 'cardTheme': encodeCardTheme(value.cardTheme), - 'checkboxTheme': encodeCheckboxThemeData(value.checkboxTheme), - 'chipTheme': encodeChipThemeData(value.chipTheme), - 'colorScheme': encodeColorScheme(value.colorScheme), - // 'colorSchemeSeed': @nonexistant, - 'cupertinoOverrideTheme': encodeCupertinoThemeData( - value.cupertinoOverrideTheme, - ), - 'datePickerThemeData': encodeDatePickerThemeData(value.datePickerTheme), - 'dataTableTheme': encodeDataTableThemeData(value.dataTableTheme), - 'dialogBackgroundColor': encodeColor(value.dialogBackgroundColor), - 'dialogTheme': encodeDialogTheme(value.dialogTheme), - 'disabledColor': encodeColor(value.disabledColor), - 'dividerColor': encodeColor(value.dividerColor), - 'dividerTheme': encodeDividerThemeData(value.dividerTheme), - 'drawerTheme': encodeDrawerThemeData(value.drawerTheme), - 'elevatedButtonTheme': encodeElevatedButtonThemeData( - value.elevatedButtonTheme, - ), - 'expansionTileThemeData': encodeExpansionTileThemeData( - value.expansionTileTheme, - ), - 'filledButtonTheme': encodeFilledButtonThemeData( - value.filledButtonTheme, - ), - 'floatingActionButtonTheme': encodeFloatingActionButtonThemeData( - value.floatingActionButtonTheme, - ), - 'focusColor': encodeColor(value.focusColor), - 'highlightColor': encodeColor(value.highlightColor), - 'hintColor': encodeColor(value.hintColor), - 'hoverColor': encodeColor(value.hoverColor), - 'iconButtonTheme': encodeIconButtonThemeData(value.iconButtonTheme), - 'iconTheme': encodeIconThemeData(value.iconTheme), - 'indicatorColor': encodeColor(value.indicatorColor), - 'inputDecorationTheme': encodeInputDecorationTheme( - value.inputDecorationTheme, - ), - 'listTileTheme': encodeListTileThemeData(value.listTileTheme), - 'materialTapTargetSize': encodeMaterialTapTargetSize( - value.materialTapTargetSize, - ), - 'menuBarTheme': encodeMenuBarThemeData(value.menuBarTheme), - 'menuButtonTheme': encodeMenuButtonThemeData(value.menuButtonTheme), - 'menuTheme': encodeMenuThemeData(value.menuTheme), - 'navigationBarTheme': encodeNavigationBarThemeData( - value.navigationBarTheme, - ), - 'navigationRailTheme': encodeNavigationRailThemeData( - value.navigationRailTheme, - ), - 'outlinedButtonTheme': encodeOutlinedButtonThemeData( - value.outlinedButtonTheme, - ), - 'platform': encodeTargetPlatform(value.platform), - 'popupMenuTheme': encodePopupMenuThemeData(value.popupMenuTheme), - 'primaryColor': encodeColor(value.primaryColor), - 'primaryColorDark': encodeColor(value.primaryColorDark), - 'primaryColorLight': encodeColor(value.primaryColorLight), - 'primaryIconTheme': encodeIconThemeData(value.primaryIconTheme), - 'primaryTextTheme': encodeTextTheme(value.primaryTextTheme), - 'radioTheme': encodeRadioThemeData(value.radioTheme), - 'scaffoldBackgroundColor': encodeColor(value.scaffoldBackgroundColor), - 'searchBarTheme': encodeSearchBarThemeData(value.searchBarTheme), - 'searchViewTheme': encodeSearchViewThemeData(value.searchViewTheme), - 'secondaryHeaderColor': encodeColor(value.secondaryHeaderColor), - 'shadowColor': encodeColor(value.shadowColor), - 'sliderTheme': encodeSliderThemeData(value.sliderTheme), - 'snackBarTheme': encodeSnackBarThemeData(value.snackBarTheme), - 'splashColor': encodeColor(value.splashColor), - 'splashFactory': - encodeInteractiveInkFeatureFactory(value.splashFactory), - 'switchTheme': encodeSwitchThemeData(value.switchTheme), - 'tabBarTheme': encodeTabBarTheme(value.tabBarTheme), - 'textButtonTheme': encodeTextButtonThemeData(value.textButtonTheme), - 'textSelectionTheme': encodeTextSelectionThemeData( - value.textSelectionTheme, - ), - 'textTheme': encodeTextTheme(value.textTheme), - 'toggleButtonsTheme': encodeToggleButtonsThemeData( - value.toggleButtonsTheme, - ), - 'tooltipTheme': encodeTooltipThemeData(value.tooltipTheme), - 'typography': encodeTypography(value.typography), - 'unselectedWidgetColor': encodeColor(value.unselectedWidgetColor), - 'useMaterial3': value.useMaterial3, - 'visualDensity': encodeVisualDensity(value.visualDensity), + 'black': encodeTextTheme(value.black), + 'dense': encodeTextTheme(value.dense), + 'englishLike': encodeTextTheme(value.englishLike), + 'tall': encodeTextTheme(value.tall), + 'white': encodeTextTheme(value.white), }; } return _stripDynamicNull(result); } - /// Encodes the [value] to a [TileMode]. Supported values are: - /// * `clamp` - /// * `decal` - /// * `mirror` - /// * `repeated` - static String? encodeTileMode(TileMode? value) { - String? result; + /// Encodes the given [value] to the String representation. Supported values + /// are: + /// * `down` + /// * `up` + /// + /// All other values, including `null`, will result in `null`. + static String? encodeVerticalDirection(VerticalDirection? value) { + String? result; + + if (value != null) { + switch (value) { + case VerticalDirection.down: + result = 'down'; + break; + case VerticalDirection.up: + result = 'up'; + break; + } + } + + return _stripDynamicNull(result); + } + + /// Encodes the given [value] to the String representation. Supported values + /// are: + /// * `comfortable` + /// * `compact` + /// * `standard` + /// + /// All other values, including `null`, will result in `null`. + static String? encodeVisualDensity(VisualDensity? value) { + String? result; + + if (value != null) { + if (value == VisualDensity.comfortable) { + result = 'comfortable'; + } else if (value == VisualDensity.compact) { + result = 'compact'; + } else if (value == VisualDensity.standard) { + result = 'standard'; + } + } + + return _stripDynamicNull(result); + } + + /// Encodes the [value] into a JSON representation. + /// + /// + /// ```json + /// { + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "" + /// } + /// ``` + /// + /// See also: + /// * [encodeColor] + static Map? encodeWidgetStateColor( + WidgetStateColor? value, { + bool validate = true, + }) { + Map? result; if (value != null) { - switch (value) { - case TileMode.clamp: - result = 'clamp'; - break; + result = { + 'disabled': encodeColor(value.resolve({WidgetState.disabled})), + 'dragged': encodeColor(value.resolve({WidgetState.dragged})), + 'empty': encodeColor(value.resolve({})), + 'error': encodeColor(value.resolve({WidgetState.error})), + 'focused': encodeColor(value.resolve({WidgetState.focused})), + 'hovered': encodeColor(value.resolve({WidgetState.hovered})), + 'pressed': encodeColor(value.resolve({WidgetState.pressed})), + 'scrolledUnder': encodeColor(value.resolve( + {WidgetState.scrolledUnder}, + )), + 'selected': encodeColor(value.resolve({WidgetState.selected})), + }; + } - case TileMode.decal: - result = 'decal'; - break; + return _stripDynamicNull(result); + } - case TileMode.mirror: - result = 'mirror'; - break; + /// Encodes the [value] into a JSON representation. + /// + /// + /// ```json + /// { + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "" + /// } + /// ``` + static Map? encodeWidgetStatePropertyBool( + WidgetStateProperty? value, { + bool validate = true, + }) { + Map? result; - case TileMode.repeated: - result = 'repeated'; - break; - } + if (value != null) { + result = { + 'disabled': value.resolve({WidgetState.disabled}), + 'dragged': value.resolve({WidgetState.dragged}), + 'empty': value.resolve({}), + 'error': value.resolve({WidgetState.error}), + 'focused': value.resolve({WidgetState.focused}), + 'hovered': value.resolve({WidgetState.hovered}), + 'pressed': value.resolve({WidgetState.pressed}), + 'scrolledUnder': value.resolve({WidgetState.scrolledUnder}), + 'selected': value.resolve({WidgetState.selected}), + }; } return _stripDynamicNull(result); } - /// encodes the given [value] to a [TimePickerThemeData]. This expects the - /// [value] to have the following structure: + /// Encodes the [value] into a JSON representation. + /// /// /// ```json /// { - /// "backgroundColor": "", - /// "cancelButtonStyle": "", - /// "confirmButtonStyle": "", - /// "dayPeriodBorderSide": "", - /// "dayPeriodColor": "", - /// "dayPeriodShape": "", - /// "dayPeriodTextColor": "", - /// "dayPeriodTextStyle": "", - /// "dialBackgroundColor": "", - /// "dialHandColor": "", - /// "dialTextColor": "", - /// "dialTextStyle": "", - /// "elevation": "", - /// "entryModeIconColor": "", - /// "helpTextStyle": "", - /// "hourMinuteColor": "", - /// "hourMinuteShape": "", - /// "hourMinuteTextColor": "", - /// "hourMinuteTextStyle": "", - /// "inputDecorationTheme": "", - /// "padding": "", - /// "shape": "" + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "" /// } /// ``` /// /// See also: /// * [encodeBorderSide] - /// * [encodeButtonStyle] + static Map? encodeWidgetStatePropertyBorderSide( + WidgetStateProperty? value, { + bool validate = true, + }) { + Map? result; + + if (value != null) { + result = { + 'disabled': encodeBorderSide(value.resolve({WidgetState.disabled})), + 'dragged': encodeBorderSide(value.resolve({WidgetState.dragged})), + 'empty': encodeBorderSide(value.resolve({})), + 'error': encodeBorderSide(value.resolve({WidgetState.error})), + 'focused': encodeBorderSide(value.resolve({WidgetState.focused})), + 'hovered': encodeBorderSide(value.resolve({WidgetState.hovered})), + 'pressed': encodeBorderSide(value.resolve({WidgetState.pressed})), + 'scrolledUnder': encodeBorderSide(value.resolve( + {WidgetState.scrolledUnder}, + )), + 'selected': encodeBorderSide(value.resolve({WidgetState.selected})), + }; + } + + return _stripDynamicNull(result); + } + + /// Encodes the [value] into a JSON representation. + /// + /// + /// ```json + /// { + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "" + /// } + /// ``` + /// + /// See also: /// * [encodeColor] - /// * [encodeInputDecorationTheme] - /// * [encodeShapeBorder] - /// * [encodeTextStyle] - static Map? encodeTimePickerThemeData( - TimePickerThemeData? value, - ) { + static Map? encodeWidgetStatePropertyColor( + WidgetStateProperty? value, { + bool validate = true, + }) { Map? result; if (value != null) { - result = { - 'backgroundColor': encodeColor(value.backgroundColor), - 'cancelButtonStyle': encodeButtonStyle(value.cancelButtonStyle), - 'confirmButtonStyle': encodeButtonStyle(value.confirmButtonStyle), - 'dayPeriodBorderSide': encodeBorderSide(value.dayPeriodBorderSide), - 'dayPeriodColor': encodeColor(value.dayPeriodColor), - 'dayPeriodShape': encodeShapeBorder(value.dayPeriodShape), - 'dayPeriodTextColor': encodeColor(value.dayPeriodTextColor), - 'dayPeriodTextStyle': encodeTextStyle(value.dayPeriodTextStyle), - 'dialBackgroundColor': encodeColor(value.dialBackgroundColor), - 'dialHandColor': encodeColor(value.dialHandColor), - 'dialTextColor': encodeColor(value.dialTextColor), - 'dialTextStyle': encodeTextStyle(value.dialTextStyle), - 'elevation': value.elevation, - 'entryModeIconColor': encodeColor(value.entryModeIconColor), - 'helpTextStyle': encodeTextStyle(value.helpTextStyle), - 'hourMinuteColor': encodeColor(value.hourMinuteColor), - 'hourMinuteShape': encodeShapeBorder(value.hourMinuteShape), - 'hourMinuteTextColor': encodeColor(value.hourMinuteTextColor), - 'hourMinuteTextStyle': encodeTextStyle(value.hourMinuteTextStyle), - 'inputDecorationTheme': encodeInputDecorationTheme( - value.inputDecorationTheme, + result = { + 'disabled': encodeColor(value.resolve({WidgetState.disabled})), + 'dragged': encodeColor(value.resolve({WidgetState.dragged})), + 'empty': encodeColor(value.resolve({})), + 'error': encodeColor(value.resolve({WidgetState.error})), + 'focused': encodeColor(value.resolve({WidgetState.focused})), + 'hovered': encodeColor(value.resolve({WidgetState.hovered})), + 'pressed': encodeColor(value.resolve({WidgetState.pressed})), + 'scrolledUnder': encodeColor(value.resolve( + {WidgetState.scrolledUnder}, + )), + 'selected': encodeColor(value.resolve({WidgetState.selected})), + }; + } + + return _stripDynamicNull(result); + } + + /// Encodes the [value] into a JSON representation. + /// + /// + /// ```json + /// { + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "" + /// } + /// ``` + static Map? encodeWidgetStatePropertyDouble( + WidgetStateProperty? value, { + bool validate = true, + }) { + Map? result; + + if (value != null) { + result = { + 'disabled': value.resolve({WidgetState.disabled}), + 'dragged': value.resolve({WidgetState.dragged}), + 'empty': value.resolve({}), + 'error': value.resolve({WidgetState.error}), + 'focused': value.resolve({WidgetState.focused}), + 'hovered': value.resolve({WidgetState.hovered}), + 'pressed': value.resolve({WidgetState.pressed}), + 'scrolledUnder': value.resolve({WidgetState.scrolledUnder}), + 'selected': value.resolve({WidgetState.selected}), + }; + } + + return _stripDynamicNull(result); + } + + /// Encodes the [value] into a JSON representation. + /// + /// + /// ```json + /// { + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "" + /// } + /// ``` + /// + /// See also: + /// * [encodeEdgeInsetsGeometry] + static Map? encodeWidgetStatePropertyEdgeInsetsGeometry( + WidgetStateProperty? value, { + bool validate = true, + }) { + Map? result; + + if (value != null) { + result = { + 'disabled': encodeEdgeInsetsGeometry( + value.resolve({WidgetState.disabled}) as EdgeInsets?, + ), + 'dragged': encodeEdgeInsetsGeometry( + value.resolve({WidgetState.dragged}) as EdgeInsets?, + ), + 'empty': encodeEdgeInsetsGeometry( + value.resolve({}) as EdgeInsets?, + ), + 'error': encodeEdgeInsetsGeometry( + value.resolve({WidgetState.error}) as EdgeInsets?, + ), + 'focused': encodeEdgeInsetsGeometry( + value.resolve({WidgetState.focused}) as EdgeInsets?, + ), + 'hovered': encodeEdgeInsetsGeometry( + value.resolve({WidgetState.hovered}) as EdgeInsets?, + ), + 'pressed': encodeEdgeInsetsGeometry( + value.resolve({WidgetState.pressed}) as EdgeInsets?, + ), + 'scrolledUnder': encodeEdgeInsetsGeometry( + value.resolve({WidgetState.scrolledUnder}) as EdgeInsets?, + ), + 'selected': encodeEdgeInsetsGeometry( + value.resolve({WidgetState.selected}) as EdgeInsets?, ), - 'padding': encodeEdgeInsetsGeometry(value.padding as EdgeInsets?), - 'shape': encodeShapeBorder(value.shape), }; } return _stripDynamicNull(result); } - /// Encodes the given [value] to a JSON compatible Map. The returned returned - /// value will have the following structure. + /// Encodes the [value] into a JSON representation. + /// /// /// ```json /// { - /// "borderColor": "", - /// "borderRadius": "", - /// "borderWidth": "", - /// "color": "", - /// "constraints": "", - /// "disabledBorderColor": "", - /// "disabledColor": "", - /// "fillColor": "", - /// "focusColor": "", - /// "highlightColor": "", - /// "hoverColor": "", - /// "selectedBorderColor": "", - /// "selectedColor": "", - /// "splashColor": "", - /// "textStyle": "" + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "" /// } /// ``` /// /// See also: - /// * [encodeBorderRadius] - /// * [encodeBoxConstraints] - /// * [encodeColor] - /// * [encodeTextStyle] - static Map? encodeToggleButtonsThemeData( - ToggleButtonsThemeData? value, - ) { + /// * [encodeIconThemeData] + static Map? encodeWidgetStatePropertyIconThemeData( + WidgetStateProperty? value, { + bool validate = true, + }) { Map? result; if (value != null) { - result = { - 'borderColor': encodeColor(value.borderColor), - 'borderRadius': encodeBorderRadius(value.borderRadius), - 'borderWidth': value.borderWidth, - 'color': encodeColor(value.color), - 'constraints': encodeBoxConstraints(value.constraints), - 'disabledBorderColor': encodeColor(value.disabledBorderColor), - 'disabledColor': encodeColor(value.disabledColor), - 'fillColor': encodeColor(value.fillColor), - 'focusColor': encodeColor(value.focusColor), - 'highlightColor': encodeColor(value.highlightColor), - 'hoverColor': encodeColor(value.hoverColor), - 'selectedBorderColor': encodeColor(value.selectedBorderColor), - 'selectedColor': encodeColor(value.selectedColor), - 'splashColor': encodeColor(value.splashColor), - 'textStyle': encodeTextStyle(value.textStyle), + result = { + 'disabled': encodeIconThemeData( + value.resolve({WidgetState.disabled}), + ), + 'dragged': encodeIconThemeData(value.resolve({WidgetState.dragged})), + 'empty': encodeIconThemeData(value.resolve({})), + 'error': encodeIconThemeData(value.resolve({WidgetState.error})), + 'focused': encodeIconThemeData(value.resolve({WidgetState.focused})), + 'hovered': encodeIconThemeData(value.resolve({WidgetState.hovered})), + 'pressed': encodeIconThemeData(value.resolve({WidgetState.pressed})), + 'scrolledUnder': encodeIconThemeData( + value.resolve({WidgetState.selected}), + ), + 'selected': encodeIconThemeData( + value.resolve({WidgetState.selected}), + ), }; } return _stripDynamicNull(result); } - /// Encodes the given [value] to a JSON compatible Map. The returned returned - /// value will have the following structure. + /// Encodes the [value] into a JSON representation. + /// /// /// ```json /// { - /// "enableFeedback": "", - /// "excludeFromSemantics": "", - /// "height": "", - /// "margin": "", - /// "padding": "", - /// "preferBelow": "" - /// "showDuration": "", - /// "textAlign": "", - /// "textStyle": "", - /// "triggerMode": "", - /// "verticalOffset": "", - /// "waitDuration": "" + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "" /// } /// ``` /// /// See also: - /// * [encodeEdgeInsetsGeometry] - /// * [encodeTextStyle] - /// * [encodeTooltipTriggerMode] - static Map? encodeTooltipThemeData(TooltipThemeData? value) { + /// * [encodeMouseCursor] + static Map? encodeWidgetStatePropertyMouseCursor( + WidgetStateProperty? value, { + bool validate = true, + }) { Map? result; if (value != null) { - result = { - 'enableFeedback': value.enableFeedback, - 'excludeFromSemantics': value.excludeFromSemantics, - 'height': value.height, - 'margin': encodeEdgeInsetsGeometry(value.margin as EdgeInsets?), - 'padding': encodeEdgeInsetsGeometry(value.padding as EdgeInsets?), - 'preferBelow': value.preferBelow, - 'showDuration': value.showDuration?.inMilliseconds, - 'textAlign': encodeTextAlign(value.textAlign), - 'textStyle': encodeTextStyle(value.textStyle), - 'triggerMode': encodeTooltipTriggerMode(value.triggerMode), - 'verticalOffset': value.verticalOffset, - 'waitDuration': value.waitDuration?.inMilliseconds, + result = { + 'disabled': encodeMouseCursor(value.resolve({WidgetState.disabled})), + 'dragged': encodeMouseCursor(value.resolve({WidgetState.dragged})), + 'empty': encodeMouseCursor(value.resolve({})), + 'error': encodeMouseCursor(value.resolve({WidgetState.error})), + 'focused': encodeMouseCursor(value.resolve({WidgetState.focused})), + 'hovered': encodeMouseCursor(value.resolve({WidgetState.hovered})), + 'pressed': encodeMouseCursor(value.resolve({WidgetState.pressed})), + 'scrolledUnder': encodeMouseCursor(value.resolve( + {WidgetState.scrolledUnder}, + )), + 'selected': encodeMouseCursor(value.resolve({WidgetState.selected})), }; } return _stripDynamicNull(result); } - /// Encodes the given [value] to the String representation. Supported values - /// are: - /// * `longPress` - /// * `manual` - /// * `tap` + /// Encodes the [value] into a JSON representation. /// - /// All other values, including `null`, will result in `null`. - static String? encodeTooltipTriggerMode(TooltipTriggerMode? value) { - String? result; - - if (value != null) { - if (value == TooltipTriggerMode.longPress) { - result = 'longPress'; - } else if (value == TooltipTriggerMode.manual) { - result = 'manual'; - } else if (value == TooltipTriggerMode.tap) { - result = 'tap'; - } - } - - return _stripDynamicNull(result); - } - - /// Encodes the given [value] to a JSON compatible Map. The returned returned - /// value will have the following structure. /// /// ```json /// { - /// "black": "", - /// "dense": "", - /// "englishLike": "", - /// "platform": "", - /// "tall": "", - /// "white": "", + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "" /// } /// ``` /// /// See also: - /// * [encodeTargetPlatform] - /// * [encodeTextTheme] - static Map? encodeTypography(Typography? value) { + /// * [encodeOutlinedBorder] + static Map? encodeWidgetStatePropertyOutlinedBorder( + WidgetStateProperty? value, { + bool validate = true, + }) { Map? result; if (value != null) { - result = { - 'black': encodeTextTheme(value.black), - 'dense': encodeTextTheme(value.dense), - 'englishLike': encodeTextTheme(value.englishLike), - 'tall': encodeTextTheme(value.tall), - 'white': encodeTextTheme(value.white), + result = { + 'disabled': encodeOutlinedBorder( + value.resolve({WidgetState.disabled}), + ), + 'dragged': encodeOutlinedBorder(value.resolve({WidgetState.dragged})), + 'empty': encodeOutlinedBorder(value.resolve({})), + 'error': encodeOutlinedBorder(value.resolve({WidgetState.error})), + 'focused': encodeOutlinedBorder(value.resolve({WidgetState.focused})), + 'hovered': encodeOutlinedBorder(value.resolve({WidgetState.hovered})), + 'pressed': encodeOutlinedBorder(value.resolve({WidgetState.pressed})), + 'scrolledUnder': encodeOutlinedBorder( + value.resolve({WidgetState.scrolledUnder}), + ), + 'selected': encodeOutlinedBorder( + value.resolve({WidgetState.selected}), + ), }; } return _stripDynamicNull(result); } - /// Encodes the given [value] to the String representation. Supported values - /// are: - /// * `down` - /// * `up` + /// Encodes the [value] into a JSON representation. /// - /// All other values, including `null`, will result in `null`. - static String? encodeVerticalDirection(VerticalDirection? value) { - String? result; + /// + /// ```json + /// { + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "" + /// } + /// ``` + /// + /// See also: + /// * [encodeSize] + static Map? encodeWidgetStatePropertySize( + WidgetStateProperty? value, { + bool validate = true, + }) { + Map? result; if (value != null) { - switch (value) { - case VerticalDirection.down: - result = 'down'; - break; - case VerticalDirection.up: - result = 'up'; - break; - } + result = { + 'disabled': encodeSize(value.resolve({WidgetState.disabled})), + 'dragged': encodeSize(value.resolve({WidgetState.dragged})), + 'empty': encodeSize(value.resolve({})), + 'error': encodeSize(value.resolve({WidgetState.error})), + 'focused': encodeSize(value.resolve({WidgetState.focused})), + 'hovered': encodeSize(value.resolve({WidgetState.hovered})), + 'pressed': encodeSize(value.resolve({WidgetState.pressed})), + 'scrolledUnder': encodeSize(value.resolve({WidgetState.scrolledUnder})), + 'selected': encodeSize(value.resolve({WidgetState.selected})), + }; } return _stripDynamicNull(result); } - /// Encodes the given [value] to the String representation. Supported values - /// are: - /// * `comfortable` - /// * `compact` - /// * `standard` + /// Encodes the [value] into a JSON representation. /// - /// All other values, including `null`, will result in `null`. - static String? encodeVisualDensity(VisualDensity? value) { - String? result; + /// + /// ```json + /// { + /// "disabled": "", + /// "dragged": "", + /// "empty": "", + /// "error": "", + /// "focused": "", + /// "hovered": "", + /// "pressed": "", + /// "scrolledUnder": "", + /// "selected": "", + /// } + /// ``` + /// + /// See also: + /// * [encodeTextStyle] + static Map? encodeWidgetStatePropertyTextStyle( + WidgetStateProperty? value, { + bool validate = true, + }) { + Map? result; if (value != null) { - if (value == VisualDensity.comfortable) { - result = 'comfortable'; - } else if (value == VisualDensity.compact) { - result = 'compact'; - } else if (value == VisualDensity.standard) { - result = 'standard'; - } + result = { + 'disabled': encodeTextStyle(value.resolve({WidgetState.disabled})), + 'dragged': encodeTextStyle(value.resolve({WidgetState.dragged})), + 'empty': encodeTextStyle(value.resolve({})), + 'error': encodeTextStyle(value.resolve({WidgetState.error})), + 'focused': encodeTextStyle(value.resolve({WidgetState.focused})), + 'hovered': encodeTextStyle(value.resolve({WidgetState.hovered})), + 'pressed': encodeTextStyle(value.resolve({WidgetState.pressed})), + 'scrolledUnder': encodeTextStyle(value.resolve( + {WidgetState.scrolledUnder}, + )), + 'selected': encodeTextStyle(value.resolve({WidgetState.selected})), + }; } return _stripDynamicNull(result); diff --git a/json_theme/lib/src/model/json_material_state_property.dart b/json_theme/lib/src/model/json_material_state_property.dart deleted file mode 100644 index 6b4e95c..0000000 --- a/json_theme/lib/src/model/json_material_state_property.dart +++ /dev/null @@ -1,36 +0,0 @@ -// ignore_for_file: curly_braces_in_flow_control_structures - -import 'package:flutter/material.dart'; -import 'package:meta/meta.dart' show experimental; - -/// Helper class that allows to expose values of [MaterialPropertyResolver] in -/// form of type-safe [Map] instead of `Instance of -/// '_MaterialStatePropertyWith'` via toString() call. -@immutable -class JsonMaterialStateProperty - implements MaterialStateProperty { - const JsonMaterialStateProperty(this.map); - - /// Map containing [MaterialState?] and it's corresponding [T] values. - final Map map; - - bool get _hasValues => map.values.whereType().isNotEmpty; - - /// Copies the behavior of the ThemeDecoder's `decodeMaterialStateProperty*` - /// through [MaterialState.values]. - @experimental - @override - T? resolve(Set states) { - if (!_hasValues) return null; - for (final s in MaterialState.values) if (states.contains(s)) return map[s]; - return map[null]; - } - - @override - String toString() { - if (!_hasValues) return null.toString(); - final sb = StringBuffer('JsonMaterialStateProperty({'); - for (final entry in map.entries) sb.write('${entry.key}: ${entry.value}, '); - return '${sb.toString().trimRight()}})'; - } -} diff --git a/json_theme/lib/src/model/json_widget_state_property.dart b/json_theme/lib/src/model/json_widget_state_property.dart new file mode 100644 index 0000000..6cfb15b --- /dev/null +++ b/json_theme/lib/src/model/json_widget_state_property.dart @@ -0,0 +1,36 @@ +// ignore_for_file: curly_braces_in_flow_control_structures + +import 'package:flutter/material.dart'; +import 'package:meta/meta.dart' show experimental; + +/// Helper class that allows to expose values of [WidgetPropertyResolver] in +/// form of type-safe [Map] instead of `Instance of +/// '_WidgetStatePropertyWith'` via toString() call. +@immutable +class JsonWidgetStateProperty + implements WidgetStateProperty { + const JsonWidgetStateProperty(this.map); + + /// Map containing [WidgetState?] and it's corresponding [T] values. + final Map map; + + bool get _hasValues => map.values.whereType().isNotEmpty; + + /// Copies the behavior of the ThemeDecoder's `decodeWidgetStateProperty*` + /// through [WidgetState.values]. + @experimental + @override + T? resolve(Set states) { + if (!_hasValues) return null; + for (final s in WidgetState.values) if (states.contains(s)) return map[s]; + return map[null]; + } + + @override + String toString() { + if (!_hasValues) return null.toString(); + final sb = StringBuffer('JsonWidgetStateProperty({'); + for (final entry in map.entries) sb.write('${entry.key}: ${entry.value}, '); + return '${sb.toString().trimRight()}})'; + } +} diff --git a/json_theme/lib/src/model/map_material_state_property.dart b/json_theme/lib/src/model/map_material_state_property.dart deleted file mode 100644 index 28b14d0..0000000 --- a/json_theme/lib/src/model/map_material_state_property.dart +++ /dev/null @@ -1,45 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:meta/meta.dart' show internal; - -import 'json_material_state_property.dart'; - -/// Helper class that does not break [MaterialStateProperty] resolveWith -/// contract and on the other hand exposes values as [JsonMaterialStateProperty] -/// instead of `Instance of '_MaterialStatePropertyWith'` via toString() call. -@internal -@immutable -class MapMaterialStateProperty - implements MaterialStateProperty { - /// Class is internal, means that it not a part of the public API. - const MapMaterialStateProperty(this._resolve); - - final MaterialPropertyResolver _resolve; - - /// Convenience method for creating a [MaterialStateProperty] from a - /// [MaterialPropertyResolver] function alone. - /// - /// Copied from [MaterialStateProperty]. - static MaterialStateProperty resolveWith( - MaterialPropertyResolver callback, - ) => - MapMaterialStateProperty(callback); - - @override - T resolve(Set states) => _resolve(states); - - @override - String toString() { - final map = {}; - // ignore: curly_braces_in_flow_control_structures - for (final state in MaterialState.values) map[state] = _resolve({state}); - map[null] = _resolve({}); // Covers "empty" case. - - return JsonMaterialStateProperty(_nonNullValueMap(map)).toString(); - } - - Map _nonNullValueMap(Map map) { - map.removeWhere((_, value) => value == null); - - return Map.unmodifiable(map); - } -} diff --git a/json_theme/lib/src/model/map_widget_state_property.dart b/json_theme/lib/src/model/map_widget_state_property.dart new file mode 100644 index 0000000..ca0f7e3 --- /dev/null +++ b/json_theme/lib/src/model/map_widget_state_property.dart @@ -0,0 +1,45 @@ +import 'package:flutter/material.dart'; +import 'package:meta/meta.dart' show internal; + +import 'json_widget_state_property.dart'; + +/// Helper class that does not break [WidgetStateProperty] resolveWith +/// contract and on the other hand exposes values as [JsonWidgetStateProperty] +/// instead of `Instance of '_WidgetStatePropertyWith'` via toString() call. +@internal +@immutable +class MapWidgetStateProperty + implements WidgetStateProperty { + /// Class is internal, means that it not a part of the public API. + const MapWidgetStateProperty(this._resolve); + + final WidgetPropertyResolver _resolve; + + /// Convenience method for creating a [WidgetStateProperty] from a + /// [WidgetPropertyResolver] function alone. + /// + /// Copied from [WidgetStateProperty]. + static WidgetStateProperty resolveWith( + WidgetPropertyResolver callback, + ) => + MapWidgetStateProperty(callback); + + @override + T resolve(Set states) => _resolve(states); + + @override + String toString() { + final map = {}; + // ignore: curly_braces_in_flow_control_structures + for (final state in WidgetState.values) map[state] = _resolve({state}); + map[null] = _resolve({}); // Covers "empty" case. + + return JsonWidgetStateProperty(_nonNullValueMap(map)).toString(); + } + + Map _nonNullValueMap(Map map) { + map.removeWhere((_, value) => value == null); + + return Map.unmodifiable(map); + } +} diff --git a/json_theme/lib/src/schema/all.dart b/json_theme/lib/src/schema/all.dart index d7b83c6..82e384a 100644 --- a/json_theme/lib/src/schema/all.dart +++ b/json_theme/lib/src/schema/all.dart @@ -134,18 +134,6 @@ export 'schemas/objects/list_tile_theme_data_schema.dart'; export 'schemas/objects/locale_schema.dart'; export 'schemas/objects/material_banner_theme_data_schema.dart'; export 'schemas/objects/material_color_schema.dart'; -export 'schemas/objects/material_state_color_schema.dart'; -export 'schemas/objects/material_state_property_bool_schema.dart'; -export 'schemas/objects/material_state_property_border_side_schema.dart'; -export 'schemas/objects/material_state_property_color_schema.dart'; -export 'schemas/objects/material_state_property_double_schema.dart'; -export 'schemas/objects/material_state_property_edge_insets_geometry_schema.dart'; -export 'schemas/objects/material_state_property_icon_schema.dart'; -export 'schemas/objects/material_state_property_icon_theme_data_schema.dart'; -export 'schemas/objects/material_state_property_mouse_cursor_schema.dart'; -export 'schemas/objects/material_state_property_outlined_border_schema.dart'; -export 'schemas/objects/material_state_property_size_schema.dart'; -export 'schemas/objects/material_state_property_text_style_schema.dart'; export 'schemas/objects/matrix4_schema.dart'; export 'schemas/objects/menu_bar_theme_data_schema.dart'; export 'schemas/objects/menu_button_theme_data_schema.dart'; @@ -197,3 +185,15 @@ export 'schemas/objects/time_picker_theme_data_schema.dart'; export 'schemas/objects/toggle_buttons_theme_data_schema.dart'; export 'schemas/objects/tooltip_theme_data_schema.dart'; export 'schemas/objects/typography_schema.dart'; +export 'schemas/objects/widget_state_color_schema.dart'; +export 'schemas/objects/widget_state_property_bool_schema.dart'; +export 'schemas/objects/widget_state_property_border_side_schema.dart'; +export 'schemas/objects/widget_state_property_color_schema.dart'; +export 'schemas/objects/widget_state_property_double_schema.dart'; +export 'schemas/objects/widget_state_property_edge_insets_geometry_schema.dart'; +export 'schemas/objects/widget_state_property_icon_schema.dart'; +export 'schemas/objects/widget_state_property_icon_theme_data_schema.dart'; +export 'schemas/objects/widget_state_property_mouse_cursor_schema.dart'; +export 'schemas/objects/widget_state_property_outlined_border_schema.dart'; +export 'schemas/objects/widget_state_property_size_schema.dart'; +export 'schemas/objects/widget_state_property_text_style_schema.dart'; diff --git a/json_theme/lib/src/schema/schemas.dart b/json_theme/lib/src/schema/schemas.dart index 666c91e..3cb087a 100644 --- a/json_theme/lib/src/schema/schemas.dart +++ b/json_theme/lib/src/schema/schemas.dart @@ -100,26 +100,6 @@ class Schemas { MainAxisSizeSchema.id: MainAxisSizeSchema.schema, MaterialBannerThemeDataSchema.id: MaterialBannerThemeDataSchema.schema, MaterialColorSchema.id: MaterialColorSchema.schema, - MaterialStateColorSchema.id: MaterialStateColorSchema.schema, - MaterialStatePropertyBoolSchema.id: MaterialStatePropertyBoolSchema.schema, - MaterialStatePropertyBorderSideSchema.id: - MaterialStatePropertyBorderSideSchema.schema, - MaterialStatePropertyColorSchema.id: - MaterialStatePropertyColorSchema.schema, - MaterialStatePropertyDoubleSchema.id: - MaterialStatePropertyDoubleSchema.schema, - MaterialStatePropertyEdgeInsetsGeometrySchema.id: - MaterialStatePropertyEdgeInsetsGeometrySchema.schema, - MaterialStatePropertyIconSchema.id: MaterialStatePropertyIconSchema.schema, - MaterialStatePropertyIconThemeDataSchema.id: - MaterialStatePropertyIconThemeDataSchema.schema, - MaterialStatePropertyMouseCursorSchema.id: - MaterialStatePropertyMouseCursorSchema.schema, - MaterialStatePropertyOutlinedBorderSchema.id: - MaterialStatePropertyOutlinedBorderSchema.schema, - MaterialStatePropertySizeSchema.id: MaterialStatePropertySizeSchema.schema, - MaterialStatePropertyTextStyleSchema.id: - MaterialStatePropertyTextStyleSchema.schema, MaterialTapTargetSizeSchema.id: MaterialTapTargetSizeSchema.schema, MaterialTypeSchema.id: MaterialTypeSchema.schema, Matrix4Schema.id: Matrix4Schema.schema, @@ -217,6 +197,24 @@ class Schemas { TypographySchema.id: TypographySchema.schema, VerticalDirectionSchema.id: VerticalDirectionSchema.schema, VisualDensitySchema.id: VisualDensitySchema.schema, + WidgetStateColorSchema.id: WidgetStateColorSchema.schema, + WidgetStatePropertyBoolSchema.id: WidgetStatePropertyBoolSchema.schema, + WidgetStatePropertyBorderSideSchema.id: + WidgetStatePropertyBorderSideSchema.schema, + WidgetStatePropertyColorSchema.id: WidgetStatePropertyColorSchema.schema, + WidgetStatePropertyDoubleSchema.id: WidgetStatePropertyDoubleSchema.schema, + WidgetStatePropertyEdgeInsetsGeometrySchema.id: + WidgetStatePropertyEdgeInsetsGeometrySchema.schema, + WidgetStatePropertyIconSchema.id: WidgetStatePropertyIconSchema.schema, + WidgetStatePropertyIconThemeDataSchema.id: + WidgetStatePropertyIconThemeDataSchema.schema, + WidgetStatePropertyMouseCursorSchema.id: + WidgetStatePropertyMouseCursorSchema.schema, + WidgetStatePropertyOutlinedBorderSchema.id: + WidgetStatePropertyOutlinedBorderSchema.schema, + WidgetStatePropertySizeSchema.id: WidgetStatePropertySizeSchema.schema, + WidgetStatePropertyTextStyleSchema.id: + WidgetStatePropertyTextStyleSchema.schema, WrapAlignmentSchema.id: WrapAlignmentSchema.schema, WrapCrossAlignmentSchema.id: WrapCrossAlignmentSchema.schema, }; diff --git a/json_theme/lib/src/schema/schemas/objects/bottom_navigation_bar_theme_data_schema.dart b/json_theme/lib/src/schema/schemas/objects/bottom_navigation_bar_theme_data_schema.dart index 761f775..fa030f8 100644 --- a/json_theme/lib/src/schema/schemas/objects/bottom_navigation_bar_theme_data_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/bottom_navigation_bar_theme_data_schema.dart @@ -16,7 +16,7 @@ class BottomNavigationBarThemeDataSchema { 'backgroundColor': SchemaHelper.objectSchema(ColorSchema.id), 'elevation': SchemaHelper.numberSchema, 'mouseCursor': SchemaHelper.objectSchema( - MaterialStatePropertyMouseCursorSchema.id, + WidgetStatePropertyMouseCursorSchema.id, ), 'selectedIconTheme': SchemaHelper.objectSchema(IconThemeDataSchema.id), 'selectedItemColor': SchemaHelper.objectSchema(ColorSchema.id), diff --git a/json_theme/lib/src/schema/schemas/objects/button_style_schema.dart b/json_theme/lib/src/schema/schemas/objects/button_style_schema.dart index b99dc37..0b622d5 100644 --- a/json_theme/lib/src/schema/schemas/objects/button_style_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/button_style_schema.dart @@ -15,7 +15,7 @@ class ButtonStyleSchema { 'alignment': SchemaHelper.objectSchema(AlignmentSchema.id), 'animationDuration': SchemaHelper.numberSchema, 'backgroundColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'elevation': { 'anyOf': [ @@ -26,19 +26,19 @@ class ButtonStyleSchema { 'type': 'string', }, { - r'$ref': MaterialStatePropertyDoubleSchema.id, + r'$ref': WidgetStatePropertyDoubleSchema.id, }, ], }, 'enableFeedback': SchemaHelper.boolSchema, 'fixedSize': SchemaHelper.objectSchema( - MaterialStatePropertySizeSchema.id, + WidgetStatePropertySizeSchema.id, ), 'foregroundColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'iconColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'iconSize': { 'anyOf': [ @@ -49,39 +49,39 @@ class ButtonStyleSchema { 'type': 'string', }, { - r'$ref': MaterialStatePropertyDoubleSchema.id, + r'$ref': WidgetStatePropertyDoubleSchema.id, }, ], }, 'maximumSize': SchemaHelper.objectSchema( - MaterialStatePropertySizeSchema.id, + WidgetStatePropertySizeSchema.id, ), 'minimumSize': SchemaHelper.objectSchema( - MaterialStatePropertySizeSchema.id, + WidgetStatePropertySizeSchema.id, ), 'mouseCursor': SchemaHelper.objectSchema( - MaterialStatePropertyMouseCursorSchema.id, + WidgetStatePropertyMouseCursorSchema.id, ), 'overlayColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'padding': SchemaHelper.objectSchema( - MaterialStatePropertyEdgeInsetsGeometrySchema.id, + WidgetStatePropertyEdgeInsetsGeometrySchema.id, ), 'shadowColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'shape': SchemaHelper.objectSchema( - MaterialStatePropertyOutlinedBorderSchema.id, + WidgetStatePropertyOutlinedBorderSchema.id, ), 'side': SchemaHelper.objectSchema( - MaterialStatePropertyBorderSideSchema.id, + WidgetStatePropertyBorderSideSchema.id, ), 'tapTargetSize': SchemaHelper.objectSchema( MaterialTapTargetSizeSchema.id, ), 'textStyle': SchemaHelper.objectSchema( - MaterialStatePropertyTextStyleSchema.id, + WidgetStatePropertyTextStyleSchema.id, ), 'visualDensity': SchemaHelper.objectSchema(VisualDensitySchema.id), }, diff --git a/json_theme/lib/src/schema/schemas/objects/button_theme_data_schema.dart b/json_theme/lib/src/schema/schemas/objects/button_theme_data_schema.dart index d3f7e93..1083f28 100644 --- a/json_theme/lib/src/schema/schemas/objects/button_theme_data_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/button_theme_data_schema.dart @@ -31,7 +31,7 @@ class ButtonThemeDataSchema { InteractiveInkFeatureFactorySchema.id, ), 'surfaceTintColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'textTheme': SchemaHelper.objectSchema(ButtonTextThemeSchema.id), }, diff --git a/json_theme/lib/src/schema/schemas/objects/checkbox_theme_data_schema.dart b/json_theme/lib/src/schema/schemas/objects/checkbox_theme_data_schema.dart index 84b7899..1bc4571 100644 --- a/json_theme/lib/src/schema/schemas/objects/checkbox_theme_data_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/checkbox_theme_data_schema.dart @@ -13,19 +13,19 @@ class CheckboxThemeDataSchema { 'type': 'object', 'properties': { 'checkColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'fillColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'materialTapTargetSize': SchemaHelper.objectSchema( MaterialTapTargetSizeSchema.id, ), 'mouseCursor': SchemaHelper.objectSchema( - MaterialStatePropertyMouseCursorSchema.id, + WidgetStatePropertyMouseCursorSchema.id, ), 'overlayColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'shape': SchemaHelper.objectSchema(OutlinedBorderSchema.id), 'side': SchemaHelper.objectSchema(BorderSideSchema.id), diff --git a/json_theme/lib/src/schema/schemas/objects/chip_theme_data_schema.dart b/json_theme/lib/src/schema/schemas/objects/chip_theme_data_schema.dart index 33f0bbe..3729391 100644 --- a/json_theme/lib/src/schema/schemas/objects/chip_theme_data_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/chip_theme_data_schema.dart @@ -15,7 +15,7 @@ class ChipThemeDataSchema { 'backgroundColor': SchemaHelper.objectSchema(ColorSchema.id), 'brightness': SchemaHelper.objectSchema(BrightnessSchema.id), 'checkmarkColor': SchemaHelper.objectSchema(ColorSchema.id), - 'color': SchemaHelper.objectSchema(MaterialStatePropertyColorSchema.id), + 'color': SchemaHelper.objectSchema(WidgetStatePropertyColorSchema.id), 'deleteIconColor': SchemaHelper.objectSchema(ColorSchema.id), 'disabledColor': SchemaHelper.objectSchema(ColorSchema.id), 'elevation': SchemaHelper.numberSchema, diff --git a/json_theme/lib/src/schema/schemas/objects/color_scheme_schema.dart b/json_theme/lib/src/schema/schemas/objects/color_scheme_schema.dart index a35688f..f2fd9cd 100644 --- a/json_theme/lib/src/schema/schemas/objects/color_scheme_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/color_scheme_schema.dart @@ -40,7 +40,7 @@ class ColorSchemeSchema { 'shadow': SchemaHelper.objectSchema(ColorSchema.id), 'surface': SchemaHelper.objectSchema(ColorSchema.id), 'surfaceTint': SchemaHelper.objectSchema(ColorSchema.id), - 'surfaceVariant': SchemaHelper.objectSchema(ColorSchema.id), + 'JsonWidgetStateProperty': SchemaHelper.numberSchema, 'tertiary': SchemaHelper.objectSchema(ColorSchema.id), 'tertiaryContainer': SchemaHelper.objectSchema(ColorSchema.id) }, diff --git a/json_theme/lib/src/schema/schemas/objects/data_table_theme_data_schema.dart b/json_theme/lib/src/schema/schemas/objects/data_table_theme_data_schema.dart index acbf5e4..98fdfcd 100644 --- a/json_theme/lib/src/schema/schemas/objects/data_table_theme_data_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/data_table_theme_data_schema.dart @@ -15,18 +15,18 @@ class DataTableThemeDataSchema { 'checkboxHorizontalMargin': SchemaHelper.numberSchema, 'columnSpacing': SchemaHelper.numberSchema, 'dataRowCursor': - SchemaHelper.objectSchema(MaterialStatePropertyMouseCursorSchema.id), + SchemaHelper.objectSchema(WidgetStatePropertyMouseCursorSchema.id), 'dataRowColor': - SchemaHelper.objectSchema(MaterialStatePropertyColorSchema.id), + SchemaHelper.objectSchema(WidgetStatePropertyColorSchema.id), 'dataRowMaxHeight': SchemaHelper.numberSchema, 'dataRowMinHeight': SchemaHelper.numberSchema, 'dataTextStyle': SchemaHelper.objectSchema(TextStyleSchema.id), 'decoration': SchemaHelper.objectSchema(BoxDecorationSchema.id), 'dividerThickness': SchemaHelper.numberSchema, 'headingCellCursor': - SchemaHelper.objectSchema(MaterialStatePropertyMouseCursorSchema.id), + SchemaHelper.objectSchema(WidgetStatePropertyMouseCursorSchema.id), 'headingRowColor': - SchemaHelper.objectSchema(MaterialStatePropertyColorSchema.id), + SchemaHelper.objectSchema(WidgetStatePropertyColorSchema.id), 'headingRowHeight': SchemaHelper.numberSchema, 'headingTextStyle': SchemaHelper.objectSchema(TextStyleSchema.id), 'horizontalMargin': SchemaHelper.numberSchema, diff --git a/json_theme/lib/src/schema/schemas/objects/date_picker_theme_data_schema.dart b/json_theme/lib/src/schema/schemas/objects/date_picker_theme_data_schema.dart index 7dd1e3b..836b80e 100644 --- a/json_theme/lib/src/schema/schemas/objects/date_picker_theme_data_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/date_picker_theme_data_schema.dart @@ -16,13 +16,13 @@ class DatePickerThemeDataSchema { 'cancelButtonStyle': SchemaHelper.objectSchema(ButtonStyleSchema.id), 'confirmButtonStyle': SchemaHelper.objectSchema(ButtonStyleSchema.id), 'dayBackgroundColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'dayForegroundColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'dayOverlayColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'dayStyle': SchemaHelper.objectSchema(TextStyleSchema.id), 'dividerColor': SchemaHelper.objectSchema(ColorSchema.id), @@ -52,27 +52,27 @@ class DatePickerThemeDataSchema { ColorSchema.id, ), 'rangeSelectionOverlayColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'shadowColor': SchemaHelper.objectSchema(ColorSchema.id), 'shape': SchemaHelper.objectSchema(ShapeBorderSchema.id), 'surfaceTintColor': SchemaHelper.objectSchema(ColorSchema.id), 'todayBackgroundColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'todayBorder': SchemaHelper.objectSchema(ShapeBorderSchema.id), 'todayForegroundColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'weekdayStyle': SchemaHelper.objectSchema(TextStyleSchema.id), 'yearBackgroundColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'yearForegroundColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'yearOverlayColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'yearStyle': SchemaHelper.objectSchema(TextStyleSchema.id), }, diff --git a/json_theme/lib/src/schema/schemas/objects/floating_action_button_theme_data_schema.dart b/json_theme/lib/src/schema/schemas/objects/floating_action_button_theme_data_schema.dart index 92b8ca3..5c22cc8 100644 --- a/json_theme/lib/src/schema/schemas/objects/floating_action_button_theme_data_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/floating_action_button_theme_data_schema.dart @@ -33,7 +33,7 @@ class FloatingActionButtonThemeDataSchema { BoxConstraintsSchema.id, ), 'mouseCursor': SchemaHelper.objectSchema( - MaterialStatePropertyMouseCursorSchema.id, + WidgetStatePropertyMouseCursorSchema.id, ), 'shape': SchemaHelper.objectSchema(ShapeBorderSchema.id), 'sizeConstraints': SchemaHelper.objectSchema(BoxConstraintsSchema.id), diff --git a/json_theme/lib/src/schema/schemas/objects/list_tile_theme_data_schema.dart b/json_theme/lib/src/schema/schemas/objects/list_tile_theme_data_schema.dart index a04356d..20b133d 100644 --- a/json_theme/lib/src/schema/schemas/objects/list_tile_theme_data_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/list_tile_theme_data_schema.dart @@ -23,7 +23,7 @@ class ListTileThemeDataSchema { 'minLeadingWidth': SchemaHelper.numberSchema, 'minVerticalPadding': SchemaHelper.numberSchema, 'mouseCursor': SchemaHelper.objectSchema( - MaterialStatePropertyMouseCursorSchema.id, + WidgetStatePropertyMouseCursorSchema.id, ), 'selectedColor': SchemaHelper.objectSchema(ColorSchema.id), 'selectedTileColor': SchemaHelper.objectSchema(ColorSchema.id), diff --git a/json_theme/lib/src/schema/schemas/objects/menu_style_schema.dart b/json_theme/lib/src/schema/schemas/objects/menu_style_schema.dart index 5743f81..9ea7f6f 100644 --- a/json_theme/lib/src/schema/schemas/objects/menu_style_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/menu_style_schema.dart @@ -14,34 +14,34 @@ class MenuStyleSchema { 'properties': { 'alignment': SchemaHelper.objectSchema(AlignmentSchema.id), 'backgroundColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'elevation': SchemaHelper.objectSchema( - MaterialStatePropertyDoubleSchema.id, + WidgetStatePropertyDoubleSchema.id, ), 'fixedSize': SchemaHelper.objectSchema( - MaterialStatePropertySizeSchema.id, + WidgetStatePropertySizeSchema.id, ), 'maximumSize': SchemaHelper.objectSchema( - MaterialStatePropertySizeSchema.id, + WidgetStatePropertySizeSchema.id, ), 'minimumSize': SchemaHelper.objectSchema( - MaterialStatePropertySizeSchema.id, + WidgetStatePropertySizeSchema.id, ), 'padding': SchemaHelper.objectSchema( - MaterialStatePropertyEdgeInsetsGeometrySchema.id, + WidgetStatePropertyEdgeInsetsGeometrySchema.id, ), 'shadowColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'shape': SchemaHelper.objectSchema( - MaterialStatePropertyOutlinedBorderSchema.id, + WidgetStatePropertyOutlinedBorderSchema.id, ), 'side': SchemaHelper.objectSchema( - MaterialStatePropertyBorderSideSchema.id, + WidgetStatePropertyBorderSideSchema.id, ), 'surfaceTintColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'visualDensity': SchemaHelper.objectSchema(VisualDensitySchema.id), }, diff --git a/json_theme/lib/src/schema/schemas/objects/navigation_bar_theme_data_schema.dart b/json_theme/lib/src/schema/schemas/objects/navigation_bar_theme_data_schema.dart index 498aded..f923508 100644 --- a/json_theme/lib/src/schema/schemas/objects/navigation_bar_theme_data_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/navigation_bar_theme_data_schema.dart @@ -17,7 +17,7 @@ class NavigationBarThemeDataSchema { 'elevation': SchemaHelper.numberSchema, 'height': SchemaHelper.numberSchema, 'iconTheme': SchemaHelper.objectSchema( - MaterialStatePropertyIconThemeDataSchema.id, + WidgetStatePropertyIconThemeDataSchema.id, ), 'indicatorColor': SchemaHelper.objectSchema(ColorSchema.id), 'indicatorShape': SchemaHelper.objectSchema(ShapeBorderSchema.id), @@ -25,7 +25,7 @@ class NavigationBarThemeDataSchema { NavigationDestinationLabelBehaviorSchema.id, ), 'labelTextStyle': SchemaHelper.objectSchema( - MaterialStatePropertyTextStyleSchema.id, + WidgetStatePropertyTextStyleSchema.id, ), 'shadowColor': SchemaHelper.objectSchema(ColorSchema.id), 'surfaceTintColor': SchemaHelper.objectSchema(ColorSchema.id), diff --git a/json_theme/lib/src/schema/schemas/objects/navigation_drawer_theme_data.dart b/json_theme/lib/src/schema/schemas/objects/navigation_drawer_theme_data.dart index c6eb03f..0c959a9 100644 --- a/json_theme/lib/src/schema/schemas/objects/navigation_drawer_theme_data.dart +++ b/json_theme/lib/src/schema/schemas/objects/navigation_drawer_theme_data.dart @@ -15,13 +15,13 @@ class NavigationDrawerThemeDataSchema { 'backgroundColor': SchemaHelper.objectSchema(ColorSchema.id), 'elevation': SchemaHelper.numberSchema, 'iconTheme': SchemaHelper.objectSchema( - MaterialStatePropertyIconThemeDataSchema.id, + WidgetStatePropertyIconThemeDataSchema.id, ), 'indicatorColor': SchemaHelper.objectSchema(ColorSchema.id), 'indicatorShape': SchemaHelper.objectSchema(ShapeBorderSchema.id), 'indicatorSize': SchemaHelper.objectSchema(SizeSchema.id), 'labelTextStyle': SchemaHelper.objectSchema( - MaterialStatePropertyTextStyleSchema.id, + WidgetStatePropertyTextStyleSchema.id, ), 'shadowColor': SchemaHelper.objectSchema(ColorSchema.id), 'surfaceTintColor': SchemaHelper.objectSchema(ColorSchema.id), diff --git a/json_theme/lib/src/schema/schemas/objects/popup_menu_theme_data_schema.dart b/json_theme/lib/src/schema/schemas/objects/popup_menu_theme_data_schema.dart index 11e35d2..fd2da14 100644 --- a/json_theme/lib/src/schema/schemas/objects/popup_menu_theme_data_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/popup_menu_theme_data_schema.dart @@ -19,10 +19,10 @@ class PopupMenuThemeDataSchema { 'iconColor': SchemaHelper.objectSchema(ColorSchema.id), 'iconSize': SchemaHelper.numberSchema, 'labelTextStyle': SchemaHelper.objectSchema( - MaterialStatePropertyTextStyleSchema.id, + WidgetStatePropertyTextStyleSchema.id, ), 'mouseCursor': SchemaHelper.objectSchema( - MaterialStatePropertyMouseCursorSchema.id, + WidgetStatePropertyMouseCursorSchema.id, ), 'position': SchemaHelper.objectSchema(PopupMenuPositionSchema.id), 'shadowColor': SchemaHelper.objectSchema(ColorSchema.id), diff --git a/json_theme/lib/src/schema/schemas/objects/radio_theme_data_schema.dart b/json_theme/lib/src/schema/schemas/objects/radio_theme_data_schema.dart index a4a3aca..4a00e11 100644 --- a/json_theme/lib/src/schema/schemas/objects/radio_theme_data_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/radio_theme_data_schema.dart @@ -12,16 +12,15 @@ class RadioThemeDataSchema { 'title': 'RadioThemeDataSchema', 'type': 'object', 'properties': { - 'fillColor': - SchemaHelper.objectSchema(MaterialStatePropertyColorSchema.id), + 'fillColor': SchemaHelper.objectSchema(WidgetStatePropertyColorSchema.id), 'materialTapTargetSize': SchemaHelper.objectSchema( MaterialTapTargetSizeSchema.id, ), 'mouseCursor': SchemaHelper.objectSchema( - MaterialStatePropertyMouseCursorSchema.id, + WidgetStatePropertyMouseCursorSchema.id, ), 'overlayColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'splashRadius': SchemaHelper.numberSchema, 'visualDensity': SchemaHelper.objectSchema(VisualDensitySchema.id), diff --git a/json_theme/lib/src/schema/schemas/objects/scrollbar_theme_data_schema.dart b/json_theme/lib/src/schema/schemas/objects/scrollbar_theme_data_schema.dart index 7c4efe2..b769d47 100644 --- a/json_theme/lib/src/schema/schemas/objects/scrollbar_theme_data_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/scrollbar_theme_data_schema.dart @@ -26,24 +26,24 @@ class ScrollbarThemeDataSchema { 'type': 'string', }, { - r'$ref': MaterialStatePropertyDoubleSchema.id, + r'$ref': WidgetStatePropertyDoubleSchema.id, }, ], }, 'thumbColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'thumbVisibility': SchemaHelper.objectSchema( - MaterialStatePropertyBoolSchema.id, + WidgetStatePropertyBoolSchema.id, ), 'trackBorderColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'trackColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'trackVisibility': SchemaHelper.objectSchema( - MaterialStatePropertyBoolSchema.id, + WidgetStatePropertyBoolSchema.id, ), }, }; diff --git a/json_theme/lib/src/schema/schemas/objects/search_bar_theme_data_schema.dart b/json_theme/lib/src/schema/schemas/objects/search_bar_theme_data_schema.dart index 93a9e07..3b26899 100644 --- a/json_theme/lib/src/schema/schemas/objects/search_bar_theme_data_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/search_bar_theme_data_schema.dart @@ -13,37 +13,37 @@ class SearchBarThemeDataSchema { 'additionalProperties': false, 'properties': { 'backgroundColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'constraints': SchemaHelper.objectSchema(BoxConstraintsSchema.id), 'elevation': SchemaHelper.objectSchema( - MaterialStatePropertyDoubleSchema.id, + WidgetStatePropertyDoubleSchema.id, ), 'hintStyle': SchemaHelper.objectSchema( - MaterialStatePropertyTextStyleSchema.id, + WidgetStatePropertyTextStyleSchema.id, ), 'overlayColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'padding': SchemaHelper.objectSchema( - MaterialStatePropertyEdgeInsetsGeometrySchema.id), + WidgetStatePropertyEdgeInsetsGeometrySchema.id), 'shadowColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'shape': SchemaHelper.objectSchema( - MaterialStatePropertyOutlinedBorderSchema.id, + WidgetStatePropertyOutlinedBorderSchema.id, ), 'side': SchemaHelper.objectSchema( - MaterialStatePropertyBorderSideSchema.id, + WidgetStatePropertyBorderSideSchema.id, ), 'surfaceTintColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'textCapitalization': SchemaHelper.objectSchema( TextCapitalizationSchema.id, ), 'textStyle': SchemaHelper.objectSchema( - MaterialStatePropertyTextStyleSchema.id, + WidgetStatePropertyTextStyleSchema.id, ), } }; diff --git a/json_theme/lib/src/schema/schemas/objects/slider_theme_data_schema.dart b/json_theme/lib/src/schema/schemas/objects/slider_theme_data_schema.dart index 2ab6e92..aba88d3 100644 --- a/json_theme/lib/src/schema/schemas/objects/slider_theme_data_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/slider_theme_data_schema.dart @@ -32,7 +32,7 @@ class SliderThemeDataSchema { 'inactiveTrackColor': SchemaHelper.objectSchema(ColorSchema.id), 'minThumbSeparation': SchemaHelper.numberSchema, 'mouseCursor': SchemaHelper.objectSchema( - MaterialStatePropertyMouseCursorSchema.id, + WidgetStatePropertyMouseCursorSchema.id, ), 'overlappingShapeStrokeColor': SchemaHelper.objectSchema(ColorSchema.id), 'overlayColor': SchemaHelper.objectSchema(ColorSchema.id), diff --git a/json_theme/lib/src/schema/schemas/objects/switch_theme_data_schema.dart b/json_theme/lib/src/schema/schemas/objects/switch_theme_data_schema.dart index 03ddb5e..12d52ad 100644 --- a/json_theme/lib/src/schema/schemas/objects/switch_theme_data_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/switch_theme_data_schema.dart @@ -17,17 +17,17 @@ class SwitchThemeDataSchema { ), 'mouseCursor': SchemaHelper.objectSchema(MouseCursorSchema.id), 'overlayColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'splashRadius': SchemaHelper.numberSchema, 'thumbColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'trackColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'trackOutlineColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'trackOutlineWidth': SchemaHelper.numberSchema, }, diff --git a/json_theme/lib/src/schema/schemas/objects/tab_bar_theme_schema.dart b/json_theme/lib/src/schema/schemas/objects/tab_bar_theme_schema.dart index 30a82c7..15c2426 100644 --- a/json_theme/lib/src/schema/schemas/objects/tab_bar_theme_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/tab_bar_theme_schema.dart @@ -20,10 +20,10 @@ class TabBarThemeSchema { 'labelColor': SchemaHelper.objectSchema(ColorSchema.id), 'labelStyle': SchemaHelper.objectSchema(TextStyleSchema.id), 'mouseCursor': SchemaHelper.objectSchema( - MaterialStatePropertyMouseCursorSchema.id, + WidgetStatePropertyMouseCursorSchema.id, ), 'overlayColor': SchemaHelper.objectSchema( - MaterialStatePropertyColorSchema.id, + WidgetStatePropertyColorSchema.id, ), 'splashFactory': SchemaHelper.objectSchema( InteractiveInkFeatureFactorySchema.id, diff --git a/json_theme/lib/src/schema/schemas/objects/material_state_color_schema.dart b/json_theme/lib/src/schema/schemas/objects/widget_state_color_schema.dart similarity index 81% rename from json_theme/lib/src/schema/schemas/objects/material_state_color_schema.dart rename to json_theme/lib/src/schema/schemas/objects/widget_state_color_schema.dart index 7968a7e..273b7b1 100644 --- a/json_theme/lib/src/schema/schemas/objects/material_state_color_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/widget_state_color_schema.dart @@ -1,15 +1,13 @@ import 'package:json_theme/json_theme_schemas.dart'; -class MaterialStateColorSchema { +class WidgetStateColorSchema { static const id = - 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/material_state_color.json'; + 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/widget_state_color.json'; static final schema = { r'$schema': 'http://json-schema.org/draft-07/schema#', r'$id': id, - r'$comment': - 'https://api.flutter.dev/flutter/material/MaterialStateColor-class.html', - 'title': 'MaterialStateColor', + 'title': 'WidgetStateColor', 'anyOf': [ { 'type': 'string', diff --git a/json_theme/lib/src/schema/schemas/objects/material_state_property_bool_schema.dart b/json_theme/lib/src/schema/schemas/objects/widget_state_property_bool_schema.dart similarity index 73% rename from json_theme/lib/src/schema/schemas/objects/material_state_property_bool_schema.dart rename to json_theme/lib/src/schema/schemas/objects/widget_state_property_bool_schema.dart index 749e0bf..688932c 100644 --- a/json_theme/lib/src/schema/schemas/objects/material_state_property_bool_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/widget_state_property_bool_schema.dart @@ -1,15 +1,12 @@ import 'package:json_theme/json_theme_schemas.dart'; -class MaterialStatePropertyBoolSchema { +class WidgetStatePropertyBoolSchema { static const id = - 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/material_state_property_bool.json'; + 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/widget_state_property_bool.json'; static final schema = { r'$schema': 'http://json-schema.org/draft-07/schema#', r'$id': id, - r'$comment': - 'https://api.flutter.dev/flutter/material/MaterialStateProperty-class.html', - 'title': 'MaterialStatePropertyBool', 'type': 'object', 'properties': { 'disabled': SchemaHelper.boolSchema, diff --git a/json_theme/lib/src/schema/schemas/objects/material_state_property_border_side_schema.dart b/json_theme/lib/src/schema/schemas/objects/widget_state_property_border_side_schema.dart similarity index 77% rename from json_theme/lib/src/schema/schemas/objects/material_state_property_border_side_schema.dart rename to json_theme/lib/src/schema/schemas/objects/widget_state_property_border_side_schema.dart index a12de3b..259ebaa 100644 --- a/json_theme/lib/src/schema/schemas/objects/material_state_property_border_side_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/widget_state_property_border_side_schema.dart @@ -1,15 +1,13 @@ import 'package:json_theme/json_theme_schemas.dart'; -class MaterialStatePropertyBorderSideSchema { +class WidgetStatePropertyBorderSideSchema { static const id = - 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/material_state_property_border_side.json'; + 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/widget_state_property_border_side.json'; static final schema = { r'$schema': 'http://json-schema.org/draft-07/schema#', r'$id': id, - r'$comment': - 'https://api.flutter.dev/flutter/material/MaterialStateProperty-class.html', - 'title': 'MaterialStatePropertyBorderSide', + 'title': 'WidgetStatePropertyBorderSide', 'type': 'object', 'properties': { 'disabled': SchemaHelper.objectSchema(BorderSideSchema.id), diff --git a/json_theme/lib/src/schema/schemas/objects/material_state_property_color_schema.dart b/json_theme/lib/src/schema/schemas/objects/widget_state_property_color_schema.dart similarity index 77% rename from json_theme/lib/src/schema/schemas/objects/material_state_property_color_schema.dart rename to json_theme/lib/src/schema/schemas/objects/widget_state_property_color_schema.dart index 7c24d11..030262d 100644 --- a/json_theme/lib/src/schema/schemas/objects/material_state_property_color_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/widget_state_property_color_schema.dart @@ -1,15 +1,13 @@ import 'package:json_theme/json_theme_schemas.dart'; -class MaterialStatePropertyColorSchema { +class WidgetStatePropertyColorSchema { static const id = - 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/material_state_property_color.json'; + 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/widget_state_property_color.json'; static final schema = { r'$schema': 'http://json-schema.org/draft-07/schema#', r'$id': id, - r'$comment': - 'https://api.flutter.dev/flutter/material/MaterialStateProperty-class.html', - 'title': 'MaterialStatePropertyColor', + 'title': 'WidgetStatePropertyColor', 'type': 'object', 'properties': { 'disabled': SchemaHelper.objectSchema(ColorSchema.id), diff --git a/json_theme/lib/src/schema/schemas/objects/material_state_property_double_schema.dart b/json_theme/lib/src/schema/schemas/objects/widget_state_property_double_schema.dart similarity index 73% rename from json_theme/lib/src/schema/schemas/objects/material_state_property_double_schema.dart rename to json_theme/lib/src/schema/schemas/objects/widget_state_property_double_schema.dart index 1398472..e6ab7d8 100644 --- a/json_theme/lib/src/schema/schemas/objects/material_state_property_double_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/widget_state_property_double_schema.dart @@ -1,15 +1,13 @@ import 'package:json_theme/json_theme_schemas.dart'; -class MaterialStatePropertyDoubleSchema { +class WidgetStatePropertyDoubleSchema { static const id = - 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/material_state_property_double.json'; + 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/widget_state_property_double.json'; static final schema = { r'$schema': 'http://json-schema.org/draft-07/schema#', r'$id': id, - r'$comment': - 'https://api.flutter.dev/flutter/material/MaterialStateProperty-class.html', - 'title': 'MaterialStatePropertyDouble', + 'title': 'WidgetStatePropertyDouble', 'type': 'object', 'properties': { 'disabled': SchemaHelper.numberSchema, diff --git a/json_theme/lib/src/schema/schemas/objects/material_state_property_edge_insets_geometry_schema.dart b/json_theme/lib/src/schema/schemas/objects/widget_state_property_edge_insets_geometry_schema.dart similarity index 81% rename from json_theme/lib/src/schema/schemas/objects/material_state_property_edge_insets_geometry_schema.dart rename to json_theme/lib/src/schema/schemas/objects/widget_state_property_edge_insets_geometry_schema.dart index 8da7fb3..f88653d 100644 --- a/json_theme/lib/src/schema/schemas/objects/material_state_property_edge_insets_geometry_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/widget_state_property_edge_insets_geometry_schema.dart @@ -1,15 +1,13 @@ import 'package:json_theme/json_theme_schemas.dart'; -class MaterialStatePropertyEdgeInsetsGeometrySchema { +class WidgetStatePropertyEdgeInsetsGeometrySchema { static const id = - 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/material_state_property_edge_insets_geometry.json'; + 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/widget_state_property_edge_insets_geometry.json'; static final schema = { r'$schema': 'http://json-schema.org/draft-07/schema#', r'$id': id, - r'$comment': - 'https://api.flutter.dev/flutter/material/MaterialStateProperty-class.html', - 'title': 'MaterialStatePropertyEdgeInsetsGeometry', + 'title': 'WidgetStatePropertyEdgeInsetsGeometry', 'oneOf': [ { 'type': 'string', diff --git a/json_theme/lib/src/schema/schemas/objects/material_state_property_icon_schema.dart b/json_theme/lib/src/schema/schemas/objects/widget_state_property_icon_schema.dart similarity index 86% rename from json_theme/lib/src/schema/schemas/objects/material_state_property_icon_schema.dart rename to json_theme/lib/src/schema/schemas/objects/widget_state_property_icon_schema.dart index f8b0b43..4e4f20f 100644 --- a/json_theme/lib/src/schema/schemas/objects/material_state_property_icon_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/widget_state_property_icon_schema.dart @@ -1,14 +1,14 @@ import 'package:json_theme/json_theme_schemas.dart'; -class MaterialStatePropertyIconSchema { +class WidgetStatePropertyIconSchema { static const id = - 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/material_state_property_icon.json'; + 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/widget_state_property_icon.json'; static final schema = { r'$schema': 'http://json-schema.org/draft-07/schema#', r'$id': id, r'$comment': 'https://api.flutter.dev/flutter/widgets/Icon-class.html', - 'title': 'MaterialStatePropertyIcon', + 'title': 'WidgetStatePropertyIcon', 'type': 'object', 'properties': { 'disabled': SchemaHelper.objectSchema(IconSchema.id), diff --git a/json_theme/lib/src/schema/schemas/objects/material_state_property_icon_theme_data_schema.dart b/json_theme/lib/src/schema/schemas/objects/widget_state_property_icon_theme_data_schema.dart similarity index 77% rename from json_theme/lib/src/schema/schemas/objects/material_state_property_icon_theme_data_schema.dart rename to json_theme/lib/src/schema/schemas/objects/widget_state_property_icon_theme_data_schema.dart index 5e1a33f..6b13c14 100644 --- a/json_theme/lib/src/schema/schemas/objects/material_state_property_icon_theme_data_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/widget_state_property_icon_theme_data_schema.dart @@ -1,15 +1,13 @@ import 'package:json_theme/json_theme_schemas.dart'; -class MaterialStatePropertyIconThemeDataSchema { +class WidgetStatePropertyIconThemeDataSchema { static const id = - 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/material_state_property_icon_theme_data.json'; + 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/widget_state_property_icon_theme_data.json'; static final schema = { r'$schema': 'http://json-schema.org/draft-07/schema#', r'$id': id, - r'$comment': - 'https://api.flutter.dev/flutter/material/IconThemeData-class.html', - 'title': 'MaterialStatePropertyIconThemeData', + 'title': 'WidgetStatePropertyIconThemeData', 'type': 'object', 'properties': { 'disabled': SchemaHelper.objectSchema(IconThemeDataSchema.id), diff --git a/json_theme/lib/src/schema/schemas/objects/material_state_property_mouse_cursor_schema.dart b/json_theme/lib/src/schema/schemas/objects/widget_state_property_mouse_cursor_schema.dart similarity index 76% rename from json_theme/lib/src/schema/schemas/objects/material_state_property_mouse_cursor_schema.dart rename to json_theme/lib/src/schema/schemas/objects/widget_state_property_mouse_cursor_schema.dart index d83a197..fb45c84 100644 --- a/json_theme/lib/src/schema/schemas/objects/material_state_property_mouse_cursor_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/widget_state_property_mouse_cursor_schema.dart @@ -1,15 +1,13 @@ import 'package:json_theme/json_theme_schemas.dart'; -class MaterialStatePropertyMouseCursorSchema { +class WidgetStatePropertyMouseCursorSchema { static const id = - 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/material_state_property_mouse_cursor.json'; + 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/widget_state_property_mouse_cursor.json'; static final schema = { r'$schema': 'http://json-schema.org/draft-07/schema#', r'$id': id, - r'$comment': - 'https://api.flutter.dev/flutter/material/MaterialStateProperty-class.html', - 'title': 'MaterialStatePropertyMouseCursorSchema', + 'title': 'WidgetStatePropertyMouseCursorSchema', 'type': 'object', 'properties': { 'disabled': SchemaHelper.objectSchema(MouseCursorSchema.id), diff --git a/json_theme/lib/src/schema/schemas/objects/material_state_property_outlined_border_schema.dart b/json_theme/lib/src/schema/schemas/objects/widget_state_property_outlined_border_schema.dart similarity index 77% rename from json_theme/lib/src/schema/schemas/objects/material_state_property_outlined_border_schema.dart rename to json_theme/lib/src/schema/schemas/objects/widget_state_property_outlined_border_schema.dart index 63d0bc4..ea6c6a4 100644 --- a/json_theme/lib/src/schema/schemas/objects/material_state_property_outlined_border_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/widget_state_property_outlined_border_schema.dart @@ -1,15 +1,13 @@ import 'package:json_theme/json_theme_schemas.dart'; -class MaterialStatePropertyOutlinedBorderSchema { +class WidgetStatePropertyOutlinedBorderSchema { static const id = - 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/material_state_property_outlined_border.json'; + 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/widget_state_property_outlined_border.json'; static final schema = { r'$schema': 'http://json-schema.org/draft-07/schema#', r'$id': id, - r'$comment': - 'https://api.flutter.dev/flutter/material/MaterialStateProperty-class.html', - 'title': 'MaterialStatePropertyOutlinedBorder', + 'title': 'WidgetStatePropertyOutlinedBorder', 'type': 'object', 'properties': { 'disabled': SchemaHelper.objectSchema(OutlinedBorderSchema.id), diff --git a/json_theme/lib/src/schema/schemas/objects/material_state_property_size_schema.dart b/json_theme/lib/src/schema/schemas/objects/widget_state_property_size_schema.dart similarity index 77% rename from json_theme/lib/src/schema/schemas/objects/material_state_property_size_schema.dart rename to json_theme/lib/src/schema/schemas/objects/widget_state_property_size_schema.dart index b959cd7..a378b3b 100644 --- a/json_theme/lib/src/schema/schemas/objects/material_state_property_size_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/widget_state_property_size_schema.dart @@ -1,15 +1,13 @@ import 'package:json_theme/json_theme_schemas.dart'; -class MaterialStatePropertySizeSchema { +class WidgetStatePropertySizeSchema { static const id = - 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/material_state_property_size.json'; + 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/widget_state_property_size.json'; static final schema = { r'$schema': 'http://json-schema.org/draft-07/schema#', r'$id': id, - r'$comment': - 'https://api.flutter.dev/flutter/material/MaterialStateProperty-class.html', - 'title': 'MaterialStatePropertySize', + 'title': 'WidgetStatePropertySize', 'type': 'object', 'properties': { 'disabled': SchemaHelper.objectSchema(SizeSchema.id), diff --git a/json_theme/lib/src/schema/schemas/objects/material_state_property_text_style_schema.dart b/json_theme/lib/src/schema/schemas/objects/widget_state_property_text_style_schema.dart similarity index 77% rename from json_theme/lib/src/schema/schemas/objects/material_state_property_text_style_schema.dart rename to json_theme/lib/src/schema/schemas/objects/widget_state_property_text_style_schema.dart index 4956838..117cdcc 100644 --- a/json_theme/lib/src/schema/schemas/objects/material_state_property_text_style_schema.dart +++ b/json_theme/lib/src/schema/schemas/objects/widget_state_property_text_style_schema.dart @@ -1,15 +1,13 @@ import 'package:json_theme/json_theme_schemas.dart'; -class MaterialStatePropertyTextStyleSchema { +class WidgetStatePropertyTextStyleSchema { static const id = - 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/material_state_property_text_style.json'; + 'https://peiffer-innovations.github.io/flutter_json_schemas/schemas/json_theme/widget_state_property_text_style.json'; static final schema = { r'$schema': 'http://json-schema.org/draft-07/schema#', r'$id': id, - r'$comment': - 'https://api.flutter.dev/flutter/material/MaterialStateProperty-class.html', - 'title': 'MaterialStatePropertyTextStyle', + 'title': 'WidgetStatePropertyTextStyle', 'type': 'object', 'properties': { 'disabled': SchemaHelper.objectSchema(TextStyleSchema.id), diff --git a/json_theme/pubspec.yaml b/json_theme/pubspec.yaml index c20b9fa..ab58214 100644 --- a/json_theme/pubspec.yaml +++ b/json_theme/pubspec.yaml @@ -1,38 +1,38 @@ 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.1+5' +version: '6.5.0' -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+13' json_schema: '^5.1.7' json_theme_annotation: '^1.0.3+6' logging: '^1.2.0' - meta: '^1.10.0' + meta: '1.12.0' -dev_dependencies: +dev_dependencies: analyzer: '^6.4.1' build: '^2.4.1' build_runner: '^2.4.9' code_builder: '^4.10.0' - flutter_lints: '^3.0.2' - flutter_test: + flutter_lints: '^4.0.0' + flutter_test: sdk: 'flutter' json_theme_codegen: '^1.1.2+13' 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 241bd29..acb0845 100644 --- a/json_theme/test/json_theme_test.dart +++ b/json_theme/test/json_theme_test.dart @@ -1543,49 +1543,49 @@ void main() { final entry = ButtonStyle( alignment: Alignment.bottomCenter, animationDuration: const Duration(milliseconds: 1000), - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( const Color(0xff555555), ), - elevation: MaterialStateProperty.all(1.0), + elevation: WidgetStateProperty.all(1.0), enableFeedback: false, - fixedSize: MaterialStateProperty.all( + fixedSize: WidgetStateProperty.all( const Size(50.0, 50.0), ), - foregroundColor: MaterialStateProperty.all( + foregroundColor: WidgetStateProperty.all( const Color(0xff555555), ), - iconColor: MaterialStateProperty.all( + iconColor: WidgetStateProperty.all( const Color(0xff555555), ), - iconSize: MaterialStateProperty.all( + iconSize: WidgetStateProperty.all( 12.0, ), - maximumSize: MaterialStateProperty.all( + maximumSize: WidgetStateProperty.all( const Size(10.0, 10.0), ), - minimumSize: MaterialStateProperty.all( + minimumSize: WidgetStateProperty.all( const Size(100.0, 100.0), ), - mouseCursor: MaterialStateProperty.all( + mouseCursor: WidgetStateProperty.all( MouseCursor.defer, ), - overlayColor: MaterialStateProperty.all( + overlayColor: WidgetStateProperty.all( const Color(0xff555555), ), - padding: MaterialStateProperty.all( + padding: WidgetStateProperty.all( EdgeInsets.zero, ), - shadowColor: MaterialStateProperty.all( + shadowColor: WidgetStateProperty.all( const Color(0xff555555), ), - shape: MaterialStateProperty.all( + shape: WidgetStateProperty.all( const CircleBorder(), ), - side: MaterialStateProperty.all( + side: WidgetStateProperty.all( const BorderSide(), ), tapTargetSize: MaterialTapTargetSize.padded, - textStyle: MaterialStateProperty.all( + textStyle: WidgetStateProperty.all( const TextStyle(), ), visualDensity: VisualDensity.standard, @@ -1664,7 +1664,7 @@ void main() { 'padding': [1, 2], }), ButtonStyle( - padding: MaterialStateProperty.all( + padding: WidgetStateProperty.all( const EdgeInsets.symmetric(horizontal: 1, vertical: 2)), ), ), @@ -1678,7 +1678,7 @@ void main() { }), ButtonStyle( padding: - MaterialStateProperty.all(const EdgeInsets.fromLTRB(1, 2, 3, 4)), + WidgetStateProperty.all(const EdgeInsets.fromLTRB(1, 2, 3, 4)), ), ), true, @@ -1688,7 +1688,7 @@ void main() { _buttonStylesAreEqual( ThemeDecoder.decodeButtonStyle({'padding': 1}), ButtonStyle( - padding: MaterialStateProperty.all(const EdgeInsets.all(1)), + padding: WidgetStateProperty.all(const EdgeInsets.all(1)), ), ), true, @@ -1701,7 +1701,7 @@ void main() { }), ButtonStyle( padding: - MaterialStateProperty.all(const EdgeInsets.fromLTRB(1, 2, 3, 4)), + WidgetStateProperty.all(const EdgeInsets.fromLTRB(1, 2, 3, 4)), ), ), true, @@ -1810,7 +1810,7 @@ void main() { 'shadow': '#ffffffff', 'surface': '#ff121212', 'surfaceTint': '#ffbb86fc', - 'surfaceVariant': '#ff121212', + 'surfaceContainerHighest': '#ff121212', 'tertiary': '#ff03dac6', 'tertiaryContainer': '#ff03dac6', }, @@ -1878,7 +1878,7 @@ void main() { 'shadow': '#ff000000', 'surface': '#ff121212', 'surfaceTint': '#ffbb86fc', - 'surfaceVariant': '#ff121212', + 'surfaceContainerHighest': '#ff121212', 'tertiary': '#ff03dac6', 'tertiaryContainer': '#ff03dac6', }, @@ -1999,11 +1999,11 @@ void main() { expect(ThemeEncoder.encodeCheckboxThemeData(null), null); final entry = CheckboxThemeData( - checkColor: MaterialStateProperty.all(_kColor), - fillColor: MaterialStateProperty.all(_kColor), + checkColor: WidgetStateProperty.all(_kColor), + fillColor: WidgetStateProperty.all(_kColor), materialTapTargetSize: MaterialTapTargetSize.padded, - mouseCursor: MaterialStateProperty.all(MouseCursor.uncontrolled), - overlayColor: MaterialStateProperty.all(_kColor), + mouseCursor: WidgetStateProperty.all(MouseCursor.uncontrolled), + overlayColor: WidgetStateProperty.all(_kColor), splashRadius: 2.0, visualDensity: VisualDensity.comfortable, ); @@ -2014,24 +2014,24 @@ void main() { final decoded = ThemeDecoder.decodeCheckboxThemeData(encoded); expect( - decoded!.checkColor!.resolve({MaterialState.error}), - entry.checkColor!.resolve({MaterialState.error}), + decoded!.checkColor!.resolve({WidgetState.error}), + entry.checkColor!.resolve({WidgetState.error}), ); expect( - decoded.fillColor!.resolve({MaterialState.error}), - entry.fillColor!.resolve({MaterialState.error}), + decoded.fillColor!.resolve({WidgetState.error}), + entry.fillColor!.resolve({WidgetState.error}), ); expect( decoded.materialTapTargetSize, entry.materialTapTargetSize, ); expect( - decoded.mouseCursor!.resolve({MaterialState.error}), - entry.mouseCursor!.resolve({MaterialState.error}), + decoded.mouseCursor!.resolve({WidgetState.error}), + entry.mouseCursor!.resolve({WidgetState.error}), ); expect( - decoded.overlayColor!.resolve({MaterialState.error}), - entry.overlayColor!.resolve({MaterialState.error}), + decoded.overlayColor!.resolve({WidgetState.error}), + entry.overlayColor!.resolve({WidgetState.error}), ); expect( decoded.splashRadius, @@ -2051,7 +2051,7 @@ void main() { backgroundColor: const Color(0xff111111), brightness: Brightness.light, checkmarkColor: const Color(0xff222222), - color: MaterialStateProperty.all( + color: WidgetStateProperty.all( const Color(0xff555555), ), deleteIconColor: const Color(0xff333333), @@ -2272,14 +2272,14 @@ void main() { 'shadow': '#ff000000', 'surface': '#ff121212', 'surfaceTint': '#ffbb86fc', - 'surfaceVariant': '#ff121212', + 'surfaceContainerHighest': '#ff121212', 'tertiary': '#ff03dac6', 'tertiaryContainer': '#ff03dac6', }, ); expect( - decoded!.background, - entry.background, + decoded!.surface, + entry.surface, ); }); @@ -2605,18 +2605,17 @@ void main() { final entry = DataTableThemeData( checkboxHorizontalMargin: 24.0, columnSpacing: 1.0, - dataRowColor: MaterialStateProperty.all( + dataRowColor: WidgetStateProperty.all( const Color(0xff555555), ), - dataRowCursor: const MaterialStatePropertyAll(SystemMouseCursors.basic), + dataRowCursor: const WidgetStatePropertyAll(SystemMouseCursors.basic), dataRowMaxHeight: 1.0, dataRowMinHeight: 1.0, dataTextStyle: const TextStyle(), decoration: const BoxDecoration(color: _kColor), dividerThickness: 1.0, - headingCellCursor: - const MaterialStatePropertyAll(SystemMouseCursors.click), - headingRowColor: MaterialStateProperty.all( + headingCellCursor: const WidgetStatePropertyAll(SystemMouseCursors.click), + headingRowColor: WidgetStateProperty.all( const Color(0xff555555), ), headingRowHeight: 1.0, @@ -3172,7 +3171,7 @@ void main() { final entry = ElevatedButtonThemeData( style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( const Color(0xff222222), ), ), @@ -3269,49 +3268,49 @@ void main() { style: ButtonStyle( alignment: Alignment.bottomCenter, animationDuration: const Duration(milliseconds: 1000), - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( const Color(0xff555555), ), - elevation: MaterialStateProperty.all(1.0), + elevation: WidgetStateProperty.all(1.0), enableFeedback: false, - fixedSize: MaterialStateProperty.all( + fixedSize: WidgetStateProperty.all( const Size(50.0, 50.0), ), - foregroundColor: MaterialStateProperty.all( + foregroundColor: WidgetStateProperty.all( const Color(0xff555555), ), - iconColor: MaterialStateProperty.all( + iconColor: WidgetStateProperty.all( const Color(0xff555555), ), - iconSize: MaterialStateProperty.all( + iconSize: WidgetStateProperty.all( 12.0, ), - maximumSize: MaterialStateProperty.all( + maximumSize: WidgetStateProperty.all( const Size(10.0, 10.0), ), - minimumSize: MaterialStateProperty.all( + minimumSize: WidgetStateProperty.all( const Size(100.0, 100.0), ), - mouseCursor: MaterialStateProperty.all( + mouseCursor: WidgetStateProperty.all( MouseCursor.defer, ), - overlayColor: MaterialStateProperty.all( + overlayColor: WidgetStateProperty.all( const Color(0xff555555), ), - padding: MaterialStateProperty.all( + padding: WidgetStateProperty.all( EdgeInsets.zero, ), - shadowColor: MaterialStateProperty.all( + shadowColor: WidgetStateProperty.all( const Color(0xff555555), ), - shape: MaterialStateProperty.all( + shape: WidgetStateProperty.all( const CircleBorder(), ), - side: MaterialStateProperty.all( + side: WidgetStateProperty.all( const BorderSide(), ), tapTargetSize: MaterialTapTargetSize.padded, - textStyle: MaterialStateProperty.all( + textStyle: WidgetStateProperty.all( const TextStyle(), ), visualDensity: VisualDensity.standard, @@ -3491,7 +3490,7 @@ void main() { expect( ThemeEncoder.encodeFloatingActionButtonThemeData( FloatingActionButtonThemeData( - mouseCursor: MaterialStateProperty.all(SystemMouseCursors.basic), + mouseCursor: WidgetStateProperty.all(SystemMouseCursors.basic), ), ), { @@ -4032,49 +4031,49 @@ void main() { style: ButtonStyle( alignment: Alignment.bottomCenter, animationDuration: const Duration(milliseconds: 1000), - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( const Color(0xff555555), ), - elevation: MaterialStateProperty.all(1.0), + elevation: WidgetStateProperty.all(1.0), enableFeedback: false, - fixedSize: MaterialStateProperty.all( + fixedSize: WidgetStateProperty.all( const Size(50.0, 50.0), ), - foregroundColor: MaterialStateProperty.all( + foregroundColor: WidgetStateProperty.all( const Color(0xff555555), ), - iconColor: MaterialStateProperty.all( + iconColor: WidgetStateProperty.all( const Color(0xff555555), ), - iconSize: MaterialStateProperty.all( + iconSize: WidgetStateProperty.all( 12.0, ), - maximumSize: MaterialStateProperty.all( + maximumSize: WidgetStateProperty.all( const Size(10.0, 10.0), ), - minimumSize: MaterialStateProperty.all( + minimumSize: WidgetStateProperty.all( const Size(100.0, 100.0), ), - mouseCursor: MaterialStateProperty.all( + mouseCursor: WidgetStateProperty.all( MouseCursor.defer, ), - overlayColor: MaterialStateProperty.all( + overlayColor: WidgetStateProperty.all( const Color(0xff555555), ), - padding: MaterialStateProperty.all( + padding: WidgetStateProperty.all( EdgeInsets.zero, ), - shadowColor: MaterialStateProperty.all( + shadowColor: WidgetStateProperty.all( const Color(0xff555555), ), - shape: MaterialStateProperty.all( + shape: WidgetStateProperty.all( const CircleBorder(), ), - side: MaterialStateProperty.all( + side: WidgetStateProperty.all( const BorderSide(), ), tapTargetSize: MaterialTapTargetSize.padded, - textStyle: MaterialStateProperty.all( + textStyle: WidgetStateProperty.all( const TextStyle(), ), visualDensity: VisualDensity.standard, @@ -5114,1397 +5113,484 @@ void main() { expect(ThemeEncoder.encodeMaterialColor(decoded), encoded); }); - test('MaterialStateColor', () { - expect(ThemeDecoder.decodeMaterialStateColor(null), null); - expect(ThemeEncoder.encodeMaterialStateColor(null), null); - - final states = { - 'disabled': MaterialState.disabled, - 'dragged': MaterialState.dragged, - 'error': MaterialState.error, - 'focused': MaterialState.focused, - 'hovered': MaterialState.hovered, - 'pressed': MaterialState.pressed, - 'scrolledUnder': MaterialState.scrolledUnder, - 'selected': MaterialState.selected, - }; - - final colors = { - 'disabled': '#ff111111', - 'dragged': '#ff222222', - 'error': '#ff333333', - 'focused': '#ff444444', - 'hovered': '#ff555555', - 'pressed': '#ff666666', - 'scrolledUnder': '#ff888888', - 'selected': '#ff777777', - 'empty': '#00000000', - }; - - for (var entry in states.entries) { - final stateKey = entry.key; - final state = entry.value; - - final colorStr = colors[stateKey]; - final color = ThemeDecoder.decodeColor(colorStr); - - var decoded = ThemeDecoder.decodeMaterialStateColor(color); - expect(decoded!.resolve({state}), color); - - decoded = ThemeDecoder.decodeMaterialStateColor(colorStr); - expect(decoded!.resolve({state}), color); - - final encoded = ThemeEncoder.encodeMaterialStateColor(decoded); - expect(encoded![stateKey], colorStr); - } - - for (var entry in states.entries) { - final stateKey = entry.key; - final state = entry.value; - - final colorStr = colors[stateKey]; - final color = ThemeDecoder.decodeColor(colorStr); - final encodedColor = ThemeEncoder.encodeColor(color); - - final decoded = ThemeDecoder.decodeMaterialStateColor( - encodedColor, - ); - - expect(decoded!.resolve({state}), color); + test('MaterialTapTargetSize', () { + expect(ThemeDecoder.decodeMaterialTapTargetSize(null), null); + expect(ThemeEncoder.encodeMaterialTapTargetSize(null), null); - final encoded = ThemeEncoder.encodeMaterialStateColor(decoded); + expect( + ThemeDecoder.decodeMaterialTapTargetSize( + MaterialTapTargetSize.padded, + ), + MaterialTapTargetSize.padded, + ); - expect(encoded![stateKey], colorStr); - } + expect( + ThemeDecoder.decodeMaterialTapTargetSize('padded'), + MaterialTapTargetSize.padded, + ); + expect( + ThemeDecoder.decodeMaterialTapTargetSize('shrinkWrap'), + MaterialTapTargetSize.shrinkWrap, + ); - /// Test if pressed takes precedence over hovered - final materialColor = ThemeDecoder.decodeMaterialStateColor( - colors, + expect( + ThemeEncoder.encodeMaterialTapTargetSize(MaterialTapTargetSize.padded), + 'padded', + ); + expect( + ThemeEncoder.encodeMaterialTapTargetSize( + MaterialTapTargetSize.shrinkWrap, + ), + 'shrinkWrap', ); - final color = materialColor?.resolve({ - states['pressed']!, - }); - expect(ThemeEncoder.encodeColor(color), colors['pressed']); }); - test('MaterialStatePropertyBool', () { - expect(ThemeDecoder.decodeMaterialStatePropertyBool(null), null); - expect(ThemeEncoder.encodeMaterialStatePropertyBool(null), null); + test('MaterialType', () { + expect(ThemeDecoder.decodeMaterialType(null), null); + expect(ThemeEncoder.encodeMaterialType(null), null); - final stateMap = { - MaterialState.disabled: 'disabled', - MaterialState.dragged: 'dragged', - MaterialState.error: 'error', - MaterialState.focused: 'focused', - MaterialState.hovered: 'hovered', - MaterialState.pressed: 'pressed', - MaterialState.scrolledUnder: 'scrolledUnder', - MaterialState.selected: 'selected', - }; + expect( + ThemeDecoder.decodeMaterialType( + MaterialType.button, + ), + MaterialType.button, + ); - final states = { - 'disabled': MaterialState.disabled, - 'dragged': MaterialState.dragged, - 'error': MaterialState.error, - 'focused': MaterialState.focused, - 'hovered': MaterialState.hovered, - 'pressed': MaterialState.pressed, - 'scrolledUnder': MaterialState.scrolledUnder, - 'selected': MaterialState.selected, - }; + expect(ThemeDecoder.decodeMaterialType('button'), MaterialType.button); + expect(ThemeDecoder.decodeMaterialType('canvas'), MaterialType.canvas); + expect(ThemeDecoder.decodeMaterialType('card'), MaterialType.card); + expect(ThemeDecoder.decodeMaterialType('circle'), MaterialType.circle); + expect( + ThemeDecoder.decodeMaterialType('transparency'), + MaterialType.transparency, + ); - final values = { - 'disabled': true, - 'dragged': true, - 'error': true, - 'focused': true, - 'hovered': false, - 'pressed': true, - 'scrolledUnder': false, - 'selected': false, - }; + expect(ThemeEncoder.encodeMaterialType(MaterialType.button), 'button'); + expect(ThemeEncoder.encodeMaterialType(MaterialType.canvas), 'canvas'); + expect(ThemeEncoder.encodeMaterialType(MaterialType.card), 'card'); + expect(ThemeEncoder.encodeMaterialType(MaterialType.circle), 'circle'); + expect( + ThemeEncoder.encodeMaterialType(MaterialType.transparency), + 'transparency', + ); + }); - for (var entry in states.entries) { - final stateKey = entry.key; - final state = entry.value; + test('Matrix4', () { + expect(ThemeDecoder.decodeMatrix4(null), null); + expect(ThemeEncoder.encodeMatrix4(null), null); - final value = values[stateKey]; + final entry = Matrix4( + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0, + ); - var decoded = ThemeDecoder.decodeMaterialStatePropertyBool(value); - expect(decoded?.resolve({state}), value); + expect(ThemeDecoder.decodeMatrix4(entry), entry); - decoded = ThemeDecoder.decodeMaterialStatePropertyBool(value.toString()); - expect(decoded?.resolve({state}), value); + final encoded = ThemeEncoder.encodeMatrix4(entry); + final decoded = ThemeDecoder.decodeMatrix4(encoded); - final encoded = ThemeEncoder.encodeMaterialStatePropertyBool(decoded); - expect(encoded![stateKey], value); - } + expect( + encoded, + [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + ], + ); - bool? func(Set states) => - states.isEmpty ? null : values[stateMap[states.first]!]; + expect( + decoded, + entry, + ); + }); - final prop = MaterialStateProperty.resolveWith(func); - final decoded = ThemeDecoder.decodeMaterialStatePropertyBool(prop); - for (var entry in states.entries) { - final value = values[stateMap[entry.value]!]; + test('MaxLengthEnforcement', () { + expect(ThemeDecoder.decodeMaxLengthEnforcement(null), null); + expect(ThemeEncoder.encodeMaxLengthEnforcement(null), null); - expect(decoded!.resolve({entry.value}), value); + expect( + ThemeDecoder.decodeMaxLengthEnforcement('enforced'), + MaxLengthEnforcement.enforced, + ); + expect( + ThemeDecoder.decodeMaxLengthEnforcement('none'), + MaxLengthEnforcement.none, + ); + expect( + ThemeDecoder.decodeMaxLengthEnforcement('truncateAfterCompositionEnds'), + MaxLengthEnforcement.truncateAfterCompositionEnds, + ); - final encoded = ThemeEncoder.encodeMaterialStatePropertyBool(decoded); + expect( + ThemeEncoder.encodeMaxLengthEnforcement(MaxLengthEnforcement.enforced), + 'enforced'); + expect( + ThemeEncoder.encodeMaxLengthEnforcement(MaxLengthEnforcement.none), + 'none', + ); + expect( + ThemeEncoder.encodeMaxLengthEnforcement( + MaxLengthEnforcement.truncateAfterCompositionEnds), + 'truncateAfterCompositionEnds', + ); + }); - expect(encoded?[entry.key], value); - } + test('MenuButtonThemeData', () { + expect(ThemeDecoder.decodeMenuButtonThemeData(null), null); + expect(ThemeEncoder.encodeMenuButtonThemeData(null), null); - for (var entry in states.entries) { - final stateKey = entry.key; - final state = entry.value; + final entry = MenuButtonThemeData( + style: ButtonStyle( + alignment: Alignment.bottomCenter, + animationDuration: const Duration(milliseconds: 1000), + backgroundColor: WidgetStateProperty.all( + const Color(0xff555555), + ), + elevation: WidgetStateProperty.all(1.0), + enableFeedback: false, + fixedSize: WidgetStateProperty.all( + const Size(50.0, 50.0), + ), + foregroundColor: WidgetStateProperty.all( + const Color(0xff555555), + ), + iconColor: WidgetStateProperty.all( + const Color(0xff555555), + ), + iconSize: WidgetStateProperty.all( + 12.0, + ), + maximumSize: WidgetStateProperty.all( + const Size(10.0, 10.0), + ), + minimumSize: WidgetStateProperty.all( + const Size(100.0, 100.0), + ), + mouseCursor: WidgetStateProperty.all( + MouseCursor.defer, + ), + overlayColor: WidgetStateProperty.all( + const Color(0xff555555), + ), + padding: WidgetStateProperty.all( + EdgeInsets.zero, + ), + shadowColor: WidgetStateProperty.all( + const Color(0xff555555), + ), + shape: WidgetStateProperty.all( + const CircleBorder(), + ), + side: WidgetStateProperty.all( + const BorderSide(), + ), + tapTargetSize: MaterialTapTargetSize.padded, + textStyle: WidgetStateProperty.all( + const TextStyle(), + ), + visualDensity: VisualDensity.standard, + ), + ); - final value = values[stateKey]; + expect(ThemeDecoder.decodeMenuButtonThemeData(entry), entry); - final decoded = ThemeDecoder.decodeMaterialStatePropertyBool(value); + final encoded = ThemeEncoder.encodeMenuButtonThemeData(entry); + final decoded = ThemeDecoder.decodeMenuButtonThemeData(encoded); - expect(decoded!.resolve({state}), value); - - final encoded = ThemeEncoder.encodeMaterialStatePropertyBool(decoded); + expect( + encoded, + { + 'style': { + 'alignment': 'bottomCenter', + 'animationDuration': 1000, + 'backgroundColor': _materializeState('#ff555555'), + 'elevation': _materializeState(1.0), + 'enableFeedback': false, + 'fixedSize': _materializeState({ + 'height': 50.0, + 'width': 50.0, + }), + 'foregroundColor': _materializeState('#ff555555'), + 'iconColor': _materializeState('#ff555555'), + 'iconSize': _materializeState(12.0), + 'maximumSize': _materializeState({ + 'height': 10.0, + 'width': 10.0, + }), + 'minimumSize': _materializeState({ + 'height': 100.0, + 'width': 100.0, + }), + 'mouseCursor': _materializeState({ + 'type': 'defer', + }), + 'overlayColor': _materializeState('#ff555555'), + 'padding': _materializeState({ + 'bottom': 0.0, + 'left': 0.0, + 'right': 0.0, + 'top': 0.0, + }), + 'shadowColor': _materializeState('#ff555555'), + 'shape': _materializeState({ + 'side': { + 'color': '#ff000000', + 'strokeAlign': -1.0, + 'style': 'none', + 'width': 0.0, + }, + 'type': 'circle' + }), + 'side': _materializeState({ + 'color': '#ff000000', + 'strokeAlign': -1.0, + 'style': 'solid', + 'width': 1.0, + }), + 'tapTargetSize': 'padded', + 'textStyle': _materializeState({ + 'inherit': true, + }), + 'visualDensity': 'standard', + }, + }, + ); - expect(encoded![stateKey], value); - } + expect( + _buttonStylesAreEqual(decoded!.style, entry.style), + true, + ); }); - test('MaterialStatePropertyBorderSide', () { - expect(ThemeDecoder.decodeMaterialStatePropertyBorderSide(null), null); - expect(ThemeEncoder.encodeMaterialStatePropertyBorderSide(null), null); - - final states = { - 'disabled': MaterialState.disabled, - 'dragged': MaterialState.dragged, - 'error': MaterialState.error, - 'focused': MaterialState.focused, - 'hovered': MaterialState.hovered, - 'pressed': MaterialState.pressed, - 'scrolledUnder': MaterialState.scrolledUnder, - 'selected': MaterialState.selected, - }; - - var count = 1.0; - final sides = {}; - - for (var entry in states.entries) { - final stateKey = entry.key; - final state = entry.value; - - final side = BorderSide( - color: _kColor, - style: BorderStyle.solid, - width: ++count, - ); - sides[state] = side; - - final decoded = ThemeDecoder.decodeMaterialStatePropertyBorderSide(side); - - expect(decoded!.resolve({state}), side); - - final encoded = - ThemeEncoder.encodeMaterialStatePropertyBorderSide(decoded); - - expect(encoded![stateKey]['width'], side.width); - } - - BorderSide? func(Set states) => - states.isEmpty ? null : sides[states.first]; - - final prop = MaterialStateProperty.resolveWith(func); - final decoded = ThemeDecoder.decodeMaterialStatePropertyBorderSide(prop); - for (var entry in states.entries) { - final side = sides[entry.value]; - - expect(decoded!.resolve({entry.value}), side); - - final encoded = - ThemeEncoder.encodeMaterialStatePropertyBorderSide(decoded); - - expect(encoded![entry.key]['width'], side!.width); - } - - for (var entry in states.entries) { - final stateKey = entry.key; - final state = entry.value; + test('MenuStyle', () { + expect(ThemeDecoder.decodeMenuStyle(null), null); + expect(ThemeEncoder.encodeMenuStyle(null), null); - final side = BorderSide( - color: _kColor, - style: BorderStyle.solid, - width: ++count, - ); - final encodedSide = ThemeEncoder.encodeBorderSide(side); + const entry = MenuStyle( + alignment: Alignment.center, + ); - final decoded = ThemeDecoder.decodeMaterialStatePropertyBorderSide( - encodedSide, - ); + expect( + ThemeDecoder.decodeMenuStyle(entry), + entry, + ); - expect(decoded!.resolve({state}), side); + final encoded = ThemeEncoder.encodeMenuStyle(entry); + final decoded = ThemeDecoder.decodeMenuStyle(encoded); - final encoded = - ThemeEncoder.encodeMaterialStatePropertyBorderSide(decoded); + expect( + encoded, + { + 'alignment': 'center', + }, + ); - expect(encoded![stateKey]['width'], side.width); - } + expect(entry, decoded); }); - test('MaterialStatePropertyColor', () { - expect(ThemeDecoder.decodeMaterialStatePropertyColor(null), null); - expect(ThemeEncoder.encodeMaterialStatePropertyColor(null), null); - - final stateMap = { - MaterialState.disabled: 'disabled', - MaterialState.dragged: 'dragged', - MaterialState.error: 'error', - MaterialState.focused: 'focused', - MaterialState.hovered: 'hovered', - MaterialState.pressed: 'pressed', - MaterialState.scrolledUnder: 'scrolledUnder', - MaterialState.selected: 'selected', - }; - final states = { - 'disabled': MaterialState.disabled, - 'dragged': MaterialState.dragged, - 'error': MaterialState.error, - 'focused': MaterialState.focused, - 'hovered': MaterialState.hovered, - 'pressed': MaterialState.pressed, - 'scrolledUnder': MaterialState.scrolledUnder, - 'selected': MaterialState.selected, - }; - - final colors = { - 'disabled': '#ff111111', - 'dragged': '#ff222222', - 'error': '#ff333333', - 'focused': '#ff444444', - 'hovered': '#ff555555', - 'pressed': '#ff666666', - 'scrolledUnder': '#ff888888', - 'selected': '#ff777777', - }; - - for (var entry in states.entries) { - final stateKey = entry.key; - final state = entry.value; - - final colorStr = colors[stateKey]; - final color = ThemeDecoder.decodeColor(colorStr); - - var decoded = ThemeDecoder.decodeMaterialStatePropertyColor(color); - expect(decoded!.resolve({state}), color); - - decoded = ThemeDecoder.decodeMaterialStatePropertyColor(colorStr); - expect(decoded!.resolve({state}), color); - - final encoded = ThemeEncoder.encodeMaterialStatePropertyColor(decoded); - expect(encoded![stateKey], colorStr); - } - - Color? func(Set states) => states.isEmpty - ? null - : ThemeDecoder.decodeColor(colors[stateMap[states.first]]); - - final prop = MaterialStateProperty.resolveWith(func); - final decoded = ThemeDecoder.decodeMaterialStatePropertyColor(prop); - for (var entry in states.entries) { - final colorStr = colors[stateMap[entry.value]]; - final color = ThemeDecoder.decodeColor(colorStr); - - expect(decoded!.resolve({entry.value}), color); - - final encoded = ThemeEncoder.encodeMaterialStatePropertyColor(decoded); - - expect(encoded?[entry.key], colorStr); - } - - for (var entry in states.entries) { - final stateKey = entry.key; - final state = entry.value; - - final colorStr = colors[stateKey]; - final color = ThemeDecoder.decodeColor(colorStr); - final encodedColor = ThemeEncoder.encodeColor(color); - - final decoded = ThemeDecoder.decodeMaterialStatePropertyColor( - encodedColor, - ); - - expect(decoded!.resolve({state}), color); - - final encoded = ThemeEncoder.encodeMaterialStatePropertyColor(decoded); - - expect(encoded![stateKey], colorStr); - } + test('MouseCursor', () { + expect(ThemeDecoder.decodeMouseCursor(null), null); + expect(ThemeEncoder.encodeMouseCursor(null), null); - /// Test if pressed takes precedence over hovered - final materialColor = ThemeDecoder.decodeMaterialStatePropertyColor( - colors, + expect( + ThemeDecoder.decodeMouseCursor( + MouseCursor.defer, + ), + MouseCursor.defer, ); - final color = materialColor?.resolve({ - states['hovered']!, - states['pressed']!, - }); - expect(ThemeEncoder.encodeColor(color), colors['pressed']); - }); - - test('MaterialStatePropertyDouble', () { - expect(ThemeDecoder.decodeMaterialStatePropertyDouble(null), null); - expect(ThemeEncoder.encodeMaterialStatePropertyDouble(null), null); - final stateMap = { - MaterialState.disabled: 'disabled', - MaterialState.dragged: 'dragged', - MaterialState.error: 'error', - MaterialState.focused: 'focused', - MaterialState.hovered: 'hovered', - MaterialState.pressed: 'pressed', - MaterialState.scrolledUnder: 'scrolledUnder', - MaterialState.selected: 'selected', - }; - - final states = { - 'disabled': MaterialState.disabled, - 'dragged': MaterialState.dragged, - 'error': MaterialState.error, - 'focused': MaterialState.focused, - 'hovered': MaterialState.hovered, - 'pressed': MaterialState.pressed, - 'scrolledUnder': MaterialState.scrolledUnder, - 'selected': MaterialState.selected, - }; - - final values = { - 'disabled': 1.0, - 'dragged': 2.0, - 'error': 3.0, - 'focused': 4.0, - 'hovered': 5.0, - 'pressed': 6.0, - 'scrolledUnder': 8.0, - 'selected': 7.0, - }; - - for (var entry in states.entries) { - final stateKey = entry.key; - final state = entry.value; - - final value = values[stateKey]; - - var decoded = ThemeDecoder.decodeMaterialStatePropertyDouble(value); - expect(decoded!.resolve({state}), value); - decoded = - ThemeDecoder.decodeMaterialStatePropertyDouble(value.toString()); - expect(decoded!.resolve({state}), value); + expect( + ThemeDecoder.decodeMouseCursor({'type': 'defer'}), + MouseCursor.defer, + ); + expect( + ThemeDecoder.decodeMouseCursor({ + 'cursor': 'clickable', + 'type': 'material', + }), + WidgetStateMouseCursor.clickable, + ); + expect( + ThemeDecoder.decodeMouseCursor({ + 'cursor': 'textable', + 'type': 'material', + }), + WidgetStateMouseCursor.textable, + ); - final encoded = ThemeEncoder.encodeMaterialStatePropertyDouble(decoded); - expect(encoded![stateKey], value); - } - - double? func(Set states) => - states.isEmpty ? null : values[stateMap[states.first]]; - - final prop = MaterialStateProperty.resolveWith(func); - final decoded = ThemeDecoder.decodeMaterialStatePropertyDouble(prop); - for (var entry in states.entries) { - final value = values[stateMap[entry.value]]; - - expect(decoded!.resolve({entry.value}), value); - - final encoded = ThemeEncoder.encodeMaterialStatePropertyDouble(decoded); - - expect(encoded?[entry.key], value); - } - - for (var entry in states.entries) { - final stateKey = entry.key; - final state = entry.value; - - final value = values[stateKey]; - - final decoded = ThemeDecoder.decodeMaterialStatePropertyDouble(value); - - expect(decoded!.resolve({state}), value); - - final encoded = ThemeEncoder.encodeMaterialStatePropertyDouble(decoded); - - expect(encoded![stateKey], value); - } - }); - - test('MaterialStatePropertyEdgeInsetsGeometry', () { expect( - ThemeDecoder.decodeMaterialStatePropertyEdgeInsetsGeometry(null), null); + ThemeDecoder.decodeMouseCursor({ + 'cursor': 'alias', + 'type': 'system', + }), + SystemMouseCursors.alias, + ); expect( - ThemeEncoder.encodeMaterialStatePropertyEdgeInsetsGeometry(null), null); - - final states = { - 'disabled': MaterialState.disabled, - 'dragged': MaterialState.dragged, - 'error': MaterialState.error, - 'focused': MaterialState.focused, - 'hovered': MaterialState.hovered, - 'pressed': MaterialState.pressed, - 'scrolledUnder': MaterialState.scrolledUnder, - 'selected': MaterialState.selected, - }; - - var count = 1.0; - final sides = {}; - - for (var entry in states.entries) { - final stateKey = entry.key; - final state = entry.value; - - final side = EdgeInsets.all(++count); - sides[state] = side; - - final decoded = - ThemeDecoder.decodeMaterialStatePropertyEdgeInsetsGeometry(side); - - expect(decoded!.resolve({state}), side); - - final encoded = - ThemeEncoder.encodeMaterialStatePropertyEdgeInsetsGeometry(decoded); - - expect(encoded![stateKey]['bottom'], side.bottom); - } - - EdgeInsetsGeometry? func(Set states) => - states.isEmpty ? null : sides[states.first]; - - final prop = MaterialStateProperty.resolveWith(func); - final decoded = - ThemeDecoder.decodeMaterialStatePropertyEdgeInsetsGeometry(prop); - for (var entry in states.entries) { - final side = sides[entry.value]; - - expect(decoded!.resolve({entry.value}), side); - - final encoded = - ThemeEncoder.encodeMaterialStatePropertyEdgeInsetsGeometry(decoded); - - expect(encoded![entry.key]['bottom'], (side as EdgeInsets).bottom); - } - - for (var entry in states.entries) { - final stateKey = entry.key; - final state = entry.value; - - final side = EdgeInsets.all(++count); - final encodedSide = ThemeEncoder.encodeEdgeInsetsGeometry(side); - - final decoded = - ThemeDecoder.decodeMaterialStatePropertyEdgeInsetsGeometry( - encodedSide, - ); - - expect(decoded!.resolve({state}), side); - - final encoded = - ThemeEncoder.encodeMaterialStatePropertyEdgeInsetsGeometry(decoded); - - expect(encoded![stateKey]['bottom'], side.bottom); - } - - final symmetricDecoded = - ThemeDecoder.decodeMaterialStatePropertyEdgeInsetsGeometry([1, 2]); - for (var state in states.values) { - expect(symmetricDecoded!.resolve({state}), - const EdgeInsets.symmetric(horizontal: 1, vertical: 2)); - } - - final ltrbDecoded = - ThemeDecoder.decodeMaterialStatePropertyEdgeInsetsGeometry( - [1, 2, 3, 4]); - for (var state in states.values) { - expect( - ltrbDecoded!.resolve({state}), const EdgeInsets.fromLTRB(1, 2, 3, 4)); - } - - final allDecoded = - ThemeDecoder.decodeMaterialStatePropertyEdgeInsetsGeometry(1); - for (var state in states.values) { - expect(allDecoded!.resolve({state}), const EdgeInsets.all(1)); - } - }); - - test('MaterialStatePropertyIconThemeData', () { - expect(ThemeDecoder.decodeMaterialStatePropertyIconThemeData(null), null); - expect(ThemeEncoder.encodeMaterialStatePropertyIconThemeData(null), null); - - final states = { - 'disabled': MaterialState.disabled, - 'dragged': MaterialState.dragged, - 'error': MaterialState.error, - 'focused': MaterialState.focused, - 'hovered': MaterialState.hovered, - 'pressed': MaterialState.pressed, - 'scrolledUnder': MaterialState.scrolledUnder, - 'selected': MaterialState.selected, - }; - - final icons = {}; - - for (var entry in states.entries) { - final stateKey = entry.key; - final state = entry.value; - - const icon = IconThemeData( - color: _kColor, - opacity: 0.5, - size: 12.0, - ); - icons[state] = icon; - - final decoded = - ThemeDecoder.decodeMaterialStatePropertyIconThemeData(icon); - - expect(decoded!.resolve({state}), icon); - - final encoded = - ThemeEncoder.encodeMaterialStatePropertyIconThemeData(decoded); - - expect(encoded![stateKey]['color'], _kColorStr); - } - - IconThemeData? func(Set states) => - states.isEmpty ? null : icons[states.first]; - - final prop = MaterialStateProperty.resolveWith(func); - final decoded = ThemeDecoder.decodeMaterialStatePropertyIconThemeData(prop); - for (var entry in states.entries) { - final icon = icons[entry.value]; - - expect(decoded!.resolve({entry.value}), icon); - - final encoded = ThemeEncoder.encodeMaterialStatePropertyIconThemeData( - decoded, - ); - - expect(encoded![entry.key]['color'], _kColorStr); - } - - for (var entry in states.entries) { - final stateKey = entry.key; - final state = entry.value; - - final icon = icons[state]; - final encodedSide = ThemeEncoder.encodeIconThemeData(icon); - - final decoded = ThemeDecoder.decodeMaterialStatePropertyIconThemeData( - encodedSide, - ); - - expect(decoded!.resolve({state}), icon); - - final encoded = - ThemeEncoder.encodeMaterialStatePropertyIconThemeData(decoded); - - expect(encoded![stateKey]['color'], _kColorStr); - } - }); - - test('MaterialStatePropertyMouseCursor', () { - expect(ThemeDecoder.decodeMaterialStatePropertyColor(null), null); - expect(ThemeEncoder.encodeMaterialStatePropertyColor(null), null); - final stateMap = { - MaterialState.disabled: 'disabled', - MaterialState.dragged: 'dragged', - MaterialState.error: 'error', - MaterialState.focused: 'focused', - MaterialState.hovered: 'hovered', - MaterialState.pressed: 'pressed', - MaterialState.scrolledUnder: 'scrolledUnder', - MaterialState.selected: 'selected', - }; - - final states = { - 'disabled': MaterialState.disabled, - 'dragged': MaterialState.dragged, - 'error': MaterialState.error, - 'focused': MaterialState.focused, - 'hovered': MaterialState.hovered, - 'pressed': MaterialState.pressed, - 'scrolledUnder': MaterialState.scrolledUnder, - 'selected': MaterialState.selected, - }; - - final cursors = { - 'disabled': {'type': 'system', 'cursor': 'alias'}, - 'dragged': {'type': 'system', 'cursor': 'allScroll'}, - 'error': {'type': 'system', 'cursor': 'basic'}, - 'focused': {'type': 'system', 'cursor': 'cell'}, - 'hovered': {'type': 'system', 'cursor': 'click'}, - 'pressed': {'type': 'system', 'cursor': 'contextMenu'}, - 'scrolledUnder': {'type': 'system', 'cursor': 'grab'}, - 'selected': {'type': 'system', 'cursor': 'copy'}, - }; - - for (var entry in states.entries) { - final stateKey = entry.key; - final state = entry.value; - - final cursorStr = cursors[stateKey]; - final cursor = ThemeDecoder.decodeMouseCursor(cursorStr); - - var decoded = ThemeDecoder.decodeMaterialStatePropertyMouseCursor(cursor); - expect(decoded!.resolve({state}), cursor); - - decoded = ThemeDecoder.decodeMaterialStatePropertyMouseCursor(cursorStr); - expect(decoded!.resolve({state}), cursor); - - final encoded = - ThemeEncoder.encodeMaterialStatePropertyMouseCursor(decoded); - expect(encoded![stateKey], cursorStr); - } - - MouseCursor? func(Set states) => states.isEmpty - ? null - : ThemeDecoder.decodeMouseCursor(cursors[stateMap[states.first]]); - - final prop = MaterialStateProperty.resolveWith(func); - final decoded = ThemeDecoder.decodeMaterialStatePropertyMouseCursor(prop); - for (var entry in states.entries) { - final cursorStr = cursors[stateMap[entry.value]]; - final cursor = ThemeDecoder.decodeMouseCursor(cursorStr); - - expect(decoded!.resolve({entry.value}), cursor); - - final encoded = - ThemeEncoder.encodeMaterialStatePropertyMouseCursor(decoded); - - expect(encoded?[entry.key], cursorStr); - } - - for (var entry in states.entries) { - final stateKey = entry.key; - final state = entry.value; - - final cursorStr = cursors[stateKey]; - final cursor = ThemeDecoder.decodeMouseCursor(cursorStr); - final encodedCursor = ThemeEncoder.encodeMouseCursor(cursor); - - final decoded = ThemeDecoder.decodeMaterialStatePropertyMouseCursor( - encodedCursor, - ); - - expect(decoded!.resolve({state}), cursor); - - final encoded = - ThemeEncoder.encodeMaterialStatePropertyMouseCursor(decoded); - - expect(encoded![stateKey], cursorStr); - } - }); - - test('MaterialStatePropertyOutlinedBorder', () { - expect(ThemeDecoder.decodeMaterialStatePropertyOutlinedBorder(null), null); - expect(ThemeEncoder.encodeMaterialStatePropertyOutlinedBorder(null), null); - - final states = { - 'disabled': MaterialState.disabled, - 'dragged': MaterialState.dragged, - 'error': MaterialState.error, - 'focused': MaterialState.focused, - 'hovered': MaterialState.hovered, - 'pressed': MaterialState.pressed, - 'scrolledUnder': MaterialState.scrolledUnder, - 'selected': MaterialState.selected, - }; - - var count = 1.0; - final sides = {}; - - for (var entry in states.entries) { - final stateKey = entry.key; - final state = entry.value; - - final side = RoundedRectangleBorder( - side: BorderSide( - color: Colors.black, - style: BorderStyle.solid, - width: ++count, - ), - ); - sides[state] = side; - - final decoded = - ThemeDecoder.decodeMaterialStatePropertyOutlinedBorder(side); - - expect(decoded!.resolve({state}), side); - - final encoded = - ThemeEncoder.encodeMaterialStatePropertyOutlinedBorder(decoded); - - expect(encoded![stateKey]['side']['width'], side.side.width); - } - - OutlinedBorder? func(Set states) => - states.isEmpty ? null : sides[states.first]; - - final prop = MaterialStateProperty.resolveWith(func); - final decoded = - ThemeDecoder.decodeMaterialStatePropertyOutlinedBorder(prop); - for (var entry in states.entries) { - final side = sides[entry.value]; - - expect(decoded!.resolve({entry.value}), side); - - final encoded = - ThemeEncoder.encodeMaterialStatePropertyOutlinedBorder(decoded); - - expect(encoded![entry.key]['side']['width'], side!.side.width); - } - - for (var entry in states.entries) { - final stateKey = entry.key; - final state = entry.value; - - final side = sides[state]; - final encodedSide = ThemeEncoder.encodeOutlinedBorder(side); - - final decoded = ThemeDecoder.decodeMaterialStatePropertyOutlinedBorder( - encodedSide, - ); - - expect(decoded!.resolve({state}), side); - - final encoded = - ThemeEncoder.encodeMaterialStatePropertyOutlinedBorder(decoded); - - expect(encoded![stateKey]['side']['width'], side!.side.width); - } - }); - - test('MaterialStatePropertySize', () { - expect( - ThemeDecoder.decodeMaterialStatePropertySize(null), - null, + ThemeDecoder.decodeMouseCursor({ + 'cursor': 'allScroll', + 'type': 'system', + }), + SystemMouseCursors.allScroll, ); expect( - ThemeEncoder.encodeMaterialStatePropertySize(null), - null, + ThemeDecoder.decodeMouseCursor({ + 'cursor': 'basic', + 'type': 'system', + }), + SystemMouseCursors.basic, ); - - final states = { - 'disabled': MaterialState.disabled, - 'dragged': MaterialState.dragged, - 'error': MaterialState.error, - 'focused': MaterialState.focused, - 'hovered': MaterialState.hovered, - 'pressed': MaterialState.pressed, - 'scrolledUnder': MaterialState.scrolledUnder, - 'selected': MaterialState.selected, - }; - - var count = 1.0; - final sides = {}; - - for (var entry in states.entries) { - final stateKey = entry.key; - final state = entry.value; - - final side = Size( - ++count, - ++count, - ); - sides[state] = side; - - final decoded = ThemeDecoder.decodeMaterialStatePropertySize(side); - - expect(decoded!.resolve({state}), side); - - final encoded = ThemeEncoder.encodeMaterialStatePropertySize(decoded); - - expect(encoded![stateKey]['width'], side.width); - } - - Size? func(Set states) => - states.isEmpty ? null : sides[states.first]; - - final prop = MaterialStateProperty.resolveWith(func); - final decoded = ThemeDecoder.decodeMaterialStatePropertySize(prop); - for (var entry in states.entries) { - final side = sides[entry.value]; - - expect(decoded!.resolve({entry.value}), side); - - final encoded = ThemeEncoder.encodeMaterialStatePropertySize(decoded); - - expect(encoded![entry.key]['width'], side!.width); - } - - for (var entry in states.entries) { - final stateKey = entry.key; - final state = entry.value; - - final side = sides[state]; - final encodedSide = ThemeEncoder.encodeSize(side); - - final decoded = ThemeDecoder.decodeMaterialStatePropertySize( - encodedSide, - ); - - expect(decoded!.resolve({state}), side); - - final encoded = ThemeEncoder.encodeMaterialStatePropertySize(decoded); - - expect(encoded![stateKey]['width'], side!.width); - } - }); - - test('MaterialStatePropertyTextStyle', () { - expect(ThemeDecoder.decodeMaterialStatePropertyTextStyle(null), null); - expect(ThemeEncoder.encodeMaterialStatePropertyTextStyle(null), null); - - final states = { - 'disabled': MaterialState.disabled, - 'dragged': MaterialState.dragged, - 'error': MaterialState.error, - 'focused': MaterialState.focused, - 'hovered': MaterialState.hovered, - 'pressed': MaterialState.pressed, - 'scrolledUnder': MaterialState.scrolledUnder, - 'selected': MaterialState.selected, - }; - - var count = 1.0; - final sides = {}; - - for (var entry in states.entries) { - final stateKey = entry.key; - final state = entry.value; - - final side = TextStyle(fontSize: ++count); - sides[state] = side; - - final decoded = ThemeDecoder.decodeMaterialStatePropertyTextStyle(side); - - expect(decoded!.resolve({state}), side); - - final encoded = - ThemeEncoder.encodeMaterialStatePropertyTextStyle(decoded); - - expect(encoded![stateKey]['fontSize'], side.fontSize); - } - - TextStyle? func(Set states) => - states.isEmpty ? null : sides[states.first]; - - final prop = MaterialStateProperty.resolveWith(func); - final decoded = ThemeDecoder.decodeMaterialStatePropertyTextStyle(prop); - for (var entry in states.entries) { - final side = sides[entry.value]; - - expect(decoded!.resolve({entry.value}), side); - - final encoded = - ThemeEncoder.encodeMaterialStatePropertyTextStyle(decoded); - - expect(encoded![entry.key]['fontSize'], side!.fontSize); - } - - for (var entry in states.entries) { - final stateKey = entry.key; - final state = entry.value; - - final side = sides[state]; - final encodedSide = ThemeEncoder.encodeTextStyle(side); - - final decoded = ThemeDecoder.decodeMaterialStatePropertyTextStyle( - encodedSide, - ); - - expect(decoded!.resolve({state}), side); - - final encoded = - ThemeEncoder.encodeMaterialStatePropertyTextStyle(decoded); - - expect(encoded![stateKey]['fontSize'], side!.fontSize); - } - }); - - test('MaterialTapTargetSize', () { - expect(ThemeDecoder.decodeMaterialTapTargetSize(null), null); - expect(ThemeEncoder.encodeMaterialTapTargetSize(null), null); - expect( - ThemeDecoder.decodeMaterialTapTargetSize( - MaterialTapTargetSize.padded, - ), - MaterialTapTargetSize.padded, + ThemeDecoder.decodeMouseCursor({ + 'cursor': 'cell', + 'type': 'system', + }), + SystemMouseCursors.cell, ); - expect( - ThemeDecoder.decodeMaterialTapTargetSize('padded'), - MaterialTapTargetSize.padded, + ThemeDecoder.decodeMouseCursor({ + 'cursor': 'click', + 'type': 'system', + }), + SystemMouseCursors.click, ); expect( - ThemeDecoder.decodeMaterialTapTargetSize('shrinkWrap'), - MaterialTapTargetSize.shrinkWrap, + ThemeDecoder.decodeMouseCursor({ + 'cursor': 'contextMenu', + 'type': 'system', + }), + SystemMouseCursors.contextMenu, ); - expect( - ThemeEncoder.encodeMaterialTapTargetSize(MaterialTapTargetSize.padded), - 'padded', + ThemeDecoder.decodeMouseCursor({ + 'cursor': 'copy', + 'type': 'system', + }), + SystemMouseCursors.copy, ); expect( - ThemeEncoder.encodeMaterialTapTargetSize( - MaterialTapTargetSize.shrinkWrap, - ), - 'shrinkWrap', + ThemeDecoder.decodeMouseCursor({ + 'cursor': 'disappearing', + 'type': 'system', + }), + SystemMouseCursors.disappearing, ); - }); - - test('MaterialType', () { - expect(ThemeDecoder.decodeMaterialType(null), null); - expect(ThemeEncoder.encodeMaterialType(null), null); - expect( - ThemeDecoder.decodeMaterialType( - MaterialType.button, - ), - MaterialType.button, + ThemeDecoder.decodeMouseCursor({ + 'cursor': 'forbidden', + 'type': 'system', + }), + SystemMouseCursors.forbidden, ); - - expect(ThemeDecoder.decodeMaterialType('button'), MaterialType.button); - expect(ThemeDecoder.decodeMaterialType('canvas'), MaterialType.canvas); - expect(ThemeDecoder.decodeMaterialType('card'), MaterialType.card); - expect(ThemeDecoder.decodeMaterialType('circle'), MaterialType.circle); expect( - ThemeDecoder.decodeMaterialType('transparency'), - MaterialType.transparency, + ThemeDecoder.decodeMouseCursor({ + 'cursor': 'grab', + 'type': 'system', + }), + SystemMouseCursors.grab, ); - - expect(ThemeEncoder.encodeMaterialType(MaterialType.button), 'button'); - expect(ThemeEncoder.encodeMaterialType(MaterialType.canvas), 'canvas'); - expect(ThemeEncoder.encodeMaterialType(MaterialType.card), 'card'); - expect(ThemeEncoder.encodeMaterialType(MaterialType.circle), 'circle'); expect( - ThemeEncoder.encodeMaterialType(MaterialType.transparency), - 'transparency', - ); - }); - - test('Matrix4', () { - expect(ThemeDecoder.decodeMatrix4(null), null); - expect(ThemeEncoder.encodeMatrix4(null), null); - - final entry = Matrix4( - 1.0, - 2.0, - 3.0, - 4.0, - 5.0, - 6.0, - 7.0, - 8.0, - 9.0, - 10.0, - 11.0, - 12.0, - 13.0, - 14.0, - 15.0, - 16.0, - ); - - expect(ThemeDecoder.decodeMatrix4(entry), entry); - - final encoded = ThemeEncoder.encodeMatrix4(entry); - final decoded = ThemeDecoder.decodeMatrix4(encoded); - - expect( - encoded, - [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - ], - ); - - expect( - decoded, - entry, - ); - }); - - test('MaxLengthEnforcement', () { - expect(ThemeDecoder.decodeMaxLengthEnforcement(null), null); - expect(ThemeEncoder.encodeMaxLengthEnforcement(null), null); - - expect( - ThemeDecoder.decodeMaxLengthEnforcement('enforced'), - MaxLengthEnforcement.enforced, - ); - expect( - ThemeDecoder.decodeMaxLengthEnforcement('none'), - MaxLengthEnforcement.none, - ); - expect( - ThemeDecoder.decodeMaxLengthEnforcement('truncateAfterCompositionEnds'), - MaxLengthEnforcement.truncateAfterCompositionEnds, - ); - - expect( - ThemeEncoder.encodeMaxLengthEnforcement(MaxLengthEnforcement.enforced), - 'enforced'); - expect( - ThemeEncoder.encodeMaxLengthEnforcement(MaxLengthEnforcement.none), - 'none', - ); - expect( - ThemeEncoder.encodeMaxLengthEnforcement( - MaxLengthEnforcement.truncateAfterCompositionEnds), - 'truncateAfterCompositionEnds', - ); - }); - - test('MenuButtonThemeData', () { - expect(ThemeDecoder.decodeMenuButtonThemeData(null), null); - expect(ThemeEncoder.encodeMenuButtonThemeData(null), null); - - final entry = MenuButtonThemeData( - style: ButtonStyle( - alignment: Alignment.bottomCenter, - animationDuration: const Duration(milliseconds: 1000), - backgroundColor: MaterialStateProperty.all( - const Color(0xff555555), - ), - elevation: MaterialStateProperty.all(1.0), - enableFeedback: false, - fixedSize: MaterialStateProperty.all( - const Size(50.0, 50.0), - ), - foregroundColor: MaterialStateProperty.all( - const Color(0xff555555), - ), - iconColor: MaterialStateProperty.all( - const Color(0xff555555), - ), - iconSize: MaterialStateProperty.all( - 12.0, - ), - maximumSize: MaterialStateProperty.all( - const Size(10.0, 10.0), - ), - minimumSize: MaterialStateProperty.all( - const Size(100.0, 100.0), - ), - mouseCursor: MaterialStateProperty.all( - MouseCursor.defer, - ), - overlayColor: MaterialStateProperty.all( - const Color(0xff555555), - ), - padding: MaterialStateProperty.all( - EdgeInsets.zero, - ), - shadowColor: MaterialStateProperty.all( - const Color(0xff555555), - ), - shape: MaterialStateProperty.all( - const CircleBorder(), - ), - side: MaterialStateProperty.all( - const BorderSide(), - ), - tapTargetSize: MaterialTapTargetSize.padded, - textStyle: MaterialStateProperty.all( - const TextStyle(), - ), - visualDensity: VisualDensity.standard, - ), - ); - - expect(ThemeDecoder.decodeMenuButtonThemeData(entry), entry); - - final encoded = ThemeEncoder.encodeMenuButtonThemeData(entry); - final decoded = ThemeDecoder.decodeMenuButtonThemeData(encoded); - - expect( - encoded, - { - 'style': { - 'alignment': 'bottomCenter', - 'animationDuration': 1000, - 'backgroundColor': _materializeState('#ff555555'), - 'elevation': _materializeState(1.0), - 'enableFeedback': false, - 'fixedSize': _materializeState({ - 'height': 50.0, - 'width': 50.0, - }), - 'foregroundColor': _materializeState('#ff555555'), - 'iconColor': _materializeState('#ff555555'), - 'iconSize': _materializeState(12.0), - 'maximumSize': _materializeState({ - 'height': 10.0, - 'width': 10.0, - }), - 'minimumSize': _materializeState({ - 'height': 100.0, - 'width': 100.0, - }), - 'mouseCursor': _materializeState({ - 'type': 'defer', - }), - 'overlayColor': _materializeState('#ff555555'), - 'padding': _materializeState({ - 'bottom': 0.0, - 'left': 0.0, - 'right': 0.0, - 'top': 0.0, - }), - 'shadowColor': _materializeState('#ff555555'), - 'shape': _materializeState({ - 'side': { - 'color': '#ff000000', - 'strokeAlign': -1.0, - 'style': 'none', - 'width': 0.0, - }, - 'type': 'circle' - }), - 'side': _materializeState({ - 'color': '#ff000000', - 'strokeAlign': -1.0, - 'style': 'solid', - 'width': 1.0, - }), - 'tapTargetSize': 'padded', - 'textStyle': _materializeState({ - 'inherit': true, - }), - 'visualDensity': 'standard', - }, - }, - ); - - expect( - _buttonStylesAreEqual(decoded!.style, entry.style), - true, - ); - }); - - test('MenuStyle', () { - expect(ThemeDecoder.decodeMenuStyle(null), null); - expect(ThemeEncoder.encodeMenuStyle(null), null); - - const entry = MenuStyle( - alignment: Alignment.center, - ); - - expect( - ThemeDecoder.decodeMenuStyle(entry), - entry, - ); - - final encoded = ThemeEncoder.encodeMenuStyle(entry); - final decoded = ThemeDecoder.decodeMenuStyle(encoded); - - expect( - encoded, - { - 'alignment': 'center', - }, - ); - - expect(entry, decoded); - }); - - test('MouseCursor', () { - expect(ThemeDecoder.decodeMouseCursor(null), null); - expect(ThemeEncoder.encodeMouseCursor(null), null); - - expect( - ThemeDecoder.decodeMouseCursor( - MouseCursor.defer, - ), - MouseCursor.defer, - ); - - expect( - ThemeDecoder.decodeMouseCursor({'type': 'defer'}), - MouseCursor.defer, + ThemeDecoder.decodeMouseCursor({ + 'cursor': 'grabbing', + 'type': 'system', + }), + SystemMouseCursors.grabbing, ); expect( ThemeDecoder.decodeMouseCursor({ - 'cursor': 'clickable', - 'type': 'material', + 'cursor': 'help', + 'type': 'system', }), - MaterialStateMouseCursor.clickable, + SystemMouseCursors.help, ); expect( ThemeDecoder.decodeMouseCursor({ - 'cursor': 'textable', - 'type': 'material', + 'cursor': 'move', + 'type': 'system', }), - MaterialStateMouseCursor.textable, + SystemMouseCursors.move, ); - expect( ThemeDecoder.decodeMouseCursor({ - 'cursor': 'alias', + 'cursor': 'noDrop', 'type': 'system', }), - SystemMouseCursors.alias, + SystemMouseCursors.noDrop, ); expect( ThemeDecoder.decodeMouseCursor({ - 'cursor': 'allScroll', + 'cursor': 'none', 'type': 'system', }), - SystemMouseCursors.allScroll, + SystemMouseCursors.none, ); expect( ThemeDecoder.decodeMouseCursor({ - 'cursor': 'basic', + 'cursor': 'precise', 'type': 'system', }), - SystemMouseCursors.basic, + SystemMouseCursors.precise, ); expect( ThemeDecoder.decodeMouseCursor({ - 'cursor': 'cell', + 'cursor': 'progress', 'type': 'system', }), - SystemMouseCursors.cell, + SystemMouseCursors.progress, ); expect( ThemeDecoder.decodeMouseCursor({ - 'cursor': 'click', + 'cursor': 'resizeColumn', 'type': 'system', }), - SystemMouseCursors.click, + SystemMouseCursors.resizeColumn, ); expect( ThemeDecoder.decodeMouseCursor({ - 'cursor': 'contextMenu', + 'cursor': 'resizeDown', 'type': 'system', }), - SystemMouseCursors.contextMenu, + SystemMouseCursors.resizeDown, ); expect( ThemeDecoder.decodeMouseCursor({ - 'cursor': 'copy', + 'cursor': 'resizeDownLeft', 'type': 'system', }), - SystemMouseCursors.copy, + SystemMouseCursors.resizeDownLeft, ); expect( ThemeDecoder.decodeMouseCursor({ - 'cursor': 'disappearing', + 'cursor': 'resizeDownRight', 'type': 'system', }), - SystemMouseCursors.disappearing, - ); - expect( - ThemeDecoder.decodeMouseCursor({ - 'cursor': 'forbidden', - 'type': 'system', - }), - SystemMouseCursors.forbidden, - ); - expect( - ThemeDecoder.decodeMouseCursor({ - 'cursor': 'grab', - 'type': 'system', - }), - SystemMouseCursors.grab, - ); - expect( - ThemeDecoder.decodeMouseCursor({ - 'cursor': 'grabbing', - 'type': 'system', - }), - SystemMouseCursors.grabbing, - ); - expect( - ThemeDecoder.decodeMouseCursor({ - 'cursor': 'help', - 'type': 'system', - }), - SystemMouseCursors.help, - ); - expect( - ThemeDecoder.decodeMouseCursor({ - 'cursor': 'move', - 'type': 'system', - }), - SystemMouseCursors.move, - ); - expect( - ThemeDecoder.decodeMouseCursor({ - 'cursor': 'noDrop', - 'type': 'system', - }), - SystemMouseCursors.noDrop, - ); - expect( - ThemeDecoder.decodeMouseCursor({ - 'cursor': 'none', - 'type': 'system', - }), - SystemMouseCursors.none, - ); - expect( - ThemeDecoder.decodeMouseCursor({ - 'cursor': 'precise', - 'type': 'system', - }), - SystemMouseCursors.precise, - ); - expect( - ThemeDecoder.decodeMouseCursor({ - 'cursor': 'progress', - 'type': 'system', - }), - SystemMouseCursors.progress, - ); - expect( - ThemeDecoder.decodeMouseCursor({ - 'cursor': 'resizeColumn', - 'type': 'system', - }), - SystemMouseCursors.resizeColumn, - ); - expect( - ThemeDecoder.decodeMouseCursor({ - 'cursor': 'resizeDown', - 'type': 'system', - }), - SystemMouseCursors.resizeDown, - ); - expect( - ThemeDecoder.decodeMouseCursor({ - 'cursor': 'resizeDownLeft', - 'type': 'system', - }), - SystemMouseCursors.resizeDownLeft, - ); - expect( - ThemeDecoder.decodeMouseCursor({ - 'cursor': 'resizeDownRight', - 'type': 'system', - }), - SystemMouseCursors.resizeDownRight, + SystemMouseCursors.resizeDownRight, ); expect( ThemeDecoder.decodeMouseCursor({ @@ -6618,7 +5704,7 @@ void main() { ); expect( ThemeEncoder.encodeMouseCursor( - MaterialStateMouseCursor.clickable, + WidgetStateMouseCursor.clickable, ), { 'cursor': 'clickable', @@ -6627,7 +5713,7 @@ void main() { ); expect( ThemeEncoder.encodeMouseCursor( - MaterialStateMouseCursor.textable, + WidgetStateMouseCursor.textable, ), { 'cursor': 'textable', @@ -7420,7 +6506,7 @@ void main() { final entry = OutlinedButtonThemeData( style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( const Color(0xff222222), ), ), @@ -7817,10 +6903,10 @@ void main() { expect(ThemeEncoder.encodeRadioThemeData(null), null); final entry = RadioThemeData( - fillColor: MaterialStateProperty.all(_kColor), + fillColor: WidgetStateProperty.all(_kColor), materialTapTargetSize: MaterialTapTargetSize.padded, - mouseCursor: MaterialStateProperty.all(MouseCursor.uncontrolled), - overlayColor: MaterialStateProperty.all(_kColor), + mouseCursor: WidgetStateProperty.all(MouseCursor.uncontrolled), + overlayColor: WidgetStateProperty.all(_kColor), splashRadius: 2.0, visualDensity: VisualDensity.comfortable, ); @@ -7831,20 +6917,20 @@ void main() { final decoded = ThemeDecoder.decodeRadioThemeData(encoded); expect( - decoded!.fillColor!.resolve({MaterialState.error}), - entry.fillColor!.resolve({MaterialState.error}), + decoded!.fillColor!.resolve({WidgetState.error}), + entry.fillColor!.resolve({WidgetState.error}), ); expect( decoded.materialTapTargetSize, entry.materialTapTargetSize, ); expect( - decoded.mouseCursor!.resolve({MaterialState.error}), - entry.mouseCursor!.resolve({MaterialState.error}), + decoded.mouseCursor!.resolve({WidgetState.error}), + entry.mouseCursor!.resolve({WidgetState.error}), ); expect( - decoded.overlayColor!.resolve({MaterialState.error}), - entry.overlayColor!.resolve({MaterialState.error}), + decoded.overlayColor!.resolve({WidgetState.error}), + entry.overlayColor!.resolve({WidgetState.error}), ); expect( decoded.splashRadius, @@ -8521,8 +7607,8 @@ void main() { mainAxisMargin: 2.0, minThumbLength: 3.0, radius: const Radius.circular(4.0), - thickness: MaterialStateProperty.all(5.0), - thumbVisibility: MaterialStateProperty.all(true), + thickness: WidgetStateProperty.all(5.0), + thumbVisibility: WidgetStateProperty.all(true), ); expect(ThemeDecoder.decodeScrollbarThemeData(entry), entry); @@ -8555,12 +7641,12 @@ void main() { expect( encoded['thickness']['error'], - entry.thickness!.resolve({MaterialState.error}), + entry.thickness!.resolve({WidgetState.error}), ); expect( encoded['thumbVisibility']['error'], - entry.thumbVisibility!.resolve({MaterialState.error}), + entry.thumbVisibility!.resolve({WidgetState.error}), ); final decoded = ThemeDecoder.decodeScrollbarThemeData(encoded); @@ -8590,13 +7676,13 @@ void main() { ); expect( - decoded.thickness!.resolve({MaterialState.error}), - entry.thickness!.resolve({MaterialState.error}), + decoded.thickness!.resolve({WidgetState.error}), + entry.thickness!.resolve({WidgetState.error}), ); expect( - decoded.thumbVisibility!.resolve({MaterialState.error}), - entry.thumbVisibility!.resolve({MaterialState.error}), + decoded.thumbVisibility!.resolve({WidgetState.error}), + entry.thumbVisibility!.resolve({WidgetState.error}), ); }); @@ -8605,18 +7691,18 @@ void main() { expect(ThemeEncoder.encodeSearchBarThemeData(null), null); final entry = SearchBarThemeData( - backgroundColor: MaterialStateProperty.all(_kColor), + backgroundColor: WidgetStateProperty.all(_kColor), constraints: const BoxConstraints( maxWidth: 200.0, minWidth: 100.0, ), - elevation: MaterialStateProperty.all(4.0), - hintStyle: MaterialStateProperty.all(_kTextStyle), - overlayColor: MaterialStateProperty.all(_kColor), - padding: MaterialStateProperty.all(const EdgeInsets.all(16.0)), - shadowColor: MaterialStateProperty.all(_kColor), + elevation: WidgetStateProperty.all(4.0), + hintStyle: WidgetStateProperty.all(_kTextStyle), + overlayColor: WidgetStateProperty.all(_kColor), + padding: WidgetStateProperty.all(const EdgeInsets.all(16.0)), + shadowColor: WidgetStateProperty.all(_kColor), textCapitalization: TextCapitalization.sentences, - textStyle: MaterialStateProperty.all(_kTextStyle), + textStyle: WidgetStateProperty.all(_kTextStyle), ); expect( @@ -9524,12 +8610,12 @@ void main() { final entry = SwitchThemeData( materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - mouseCursor: MaterialStateProperty.all(MouseCursor.defer), - overlayColor: MaterialStateProperty.all(_kColor), + mouseCursor: WidgetStateProperty.all(MouseCursor.defer), + overlayColor: WidgetStateProperty.all(_kColor), splashRadius: 20.0, - thumbColor: MaterialStateProperty.all(_kColor), - trackColor: MaterialStateProperty.all(_kColor), - trackOutlineWidth: MaterialStateProperty.all(2.0), + thumbColor: WidgetStateProperty.all(_kColor), + trackColor: WidgetStateProperty.all(_kColor), + trackOutlineWidth: WidgetStateProperty.all(2.0), ); final encoded = { @@ -9620,7 +8706,7 @@ void main() { }); expect( - theme!.thumbColor!.resolve({MaterialState.selected}), + theme!.thumbColor!.resolve({WidgetState.selected}), const Color(0xff2196f3), ); }); @@ -10261,7 +9347,7 @@ void main() { final entry = TextButtonThemeData( style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( const Color(0xff222222), ), ), @@ -11124,7 +10210,7 @@ void main() { cardColor: const Color(0xffdddddd), cardTheme: const CardTheme(color: Color(0xffeeeeee)), checkboxTheme: CheckboxThemeData( - fillColor: MaterialStateProperty.all(const Color(0xff123456)), + fillColor: WidgetStateProperty.all(const Color(0xff123456)), ), chipTheme: ChipThemeData( backgroundColor: const Color(0xff111111), @@ -11155,14 +10241,14 @@ void main() { ), dataTableTheme: DataTableThemeData( columnSpacing: 1.0, - dataRowColor: MaterialStateProperty.all( + dataRowColor: WidgetStateProperty.all( const Color(0xff555555), ), dataRowMaxHeight: 1.0, dataRowMinHeight: 1.0, dataTextStyle: const TextStyle(), dividerThickness: 1.0, - headingRowColor: MaterialStateProperty.all( + headingRowColor: WidgetStateProperty.all( const Color(0xff555555), ), headingRowHeight: 1.0, @@ -11184,14 +10270,14 @@ void main() { ), elevatedButtonTheme: ElevatedButtonThemeData( style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( const Color(0xff222222), ), ), ), filledButtonTheme: FilledButtonThemeData( style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( const Color(0xff222222), ), ), @@ -11241,7 +10327,7 @@ void main() { ), outlinedButtonTheme: OutlinedButtonThemeData( style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( const Color(0xff222222), ), ), @@ -11271,7 +10357,7 @@ void main() { bodyMedium: TextStyle(color: Color(0xccaaaaaa)), ), radioTheme: RadioThemeData( - fillColor: MaterialStateProperty.all(const Color(0xff123456)), + fillColor: WidgetStateProperty.all(const Color(0xff123456)), ), scaffoldBackgroundColor: const Color(0xee666666), secondaryHeaderColor: const Color(0xccbbbbbb), @@ -11283,12 +10369,12 @@ void main() { splashColor: const Color(0xee444444), splashFactory: InkSplash.splashFactory, switchTheme: SwitchThemeData( - thumbColor: MaterialStateProperty.all(const Color(0xff123456)), + thumbColor: WidgetStateProperty.all(const Color(0xff123456)), ), tabBarTheme: const TabBarTheme(labelColor: Color(0xccffffff)), textButtonTheme: TextButtonThemeData( style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( const Color(0xff222222), ), ), @@ -11435,7 +10521,7 @@ void main() { 'shadow': '#ff000000', 'surface': '#ff121212', 'surfaceTint': '#ffbb86fc', - 'surfaceVariant': '#ff121212', + 'surfaceContainerHighest': '#ff121212', 'tertiary': '#ff03dac6', 'tertiaryContainer': '#ff03dac6' }, @@ -12323,443 +11409,1345 @@ void main() { 'visualDensity': 'comfortable' }; - expect(encoded, jsonMap); + expect(encoded, jsonMap); + + final reencoded = ThemeEncoder.encodeThemeData(decoded); + expect(reencoded, jsonMap); + }); + + test('TileMode', () { + expect(ThemeDecoder.decodeTileMode(null), null); + expect(ThemeEncoder.encodeTileMode(null), null); + + expect( + ThemeDecoder.decodeTileMode( + TileMode.clamp, + ), + TileMode.clamp, + ); + + expect(ThemeDecoder.decodeTileMode('clamp'), TileMode.clamp); + expect(ThemeDecoder.decodeTileMode('mirror'), TileMode.mirror); + expect(ThemeDecoder.decodeTileMode('repeated'), TileMode.repeated); + + expect(ThemeEncoder.encodeTileMode(TileMode.clamp), 'clamp'); + expect(ThemeEncoder.encodeTileMode(TileMode.mirror), 'mirror'); + expect(ThemeEncoder.encodeTileMode(TileMode.repeated), 'repeated'); + }); + + test('TimePickerThemeData', () { + expect(ThemeDecoder.decodeTimePickerThemeData(null), null); + expect(ThemeEncoder.encodeTimePickerThemeData(null), null); + + final entry = TimePickerThemeData( + backgroundColor: const Color(0xff000001), + dayPeriodBorderSide: const BorderSide( + color: Color(0xff000002), + style: BorderStyle.solid, + width: 1.0, + ), + dayPeriodColor: WidgetStateColor.resolveWith( + (_) => const Color(0xff000003), + ), + dayPeriodShape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(4.0), + ), + dayPeriodTextColor: const Color(0xff000004), + dayPeriodTextStyle: const TextStyle(fontSize: 1.0), + dialBackgroundColor: const Color(0xff000005), + dialHandColor: const Color(0xff000006), + dialTextColor: const Color(0xff000007), + entryModeIconColor: const Color(0xff000008), + helpTextStyle: const TextStyle(fontSize: 2.0), + hourMinuteColor: const Color(0xff000009), + hourMinuteShape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5.0), + ), + hourMinuteTextColor: const Color(0xff000010), + hourMinuteTextStyle: const TextStyle(fontSize: 3.0), + inputDecorationTheme: + const InputDecorationTheme(fillColor: Color(0xff000011)), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(6.0)), + ); + + expect(ThemeDecoder.decodeTimePickerThemeData(entry), entry); + + final encoded = ThemeEncoder.encodeTimePickerThemeData(entry); + final decoded = ThemeDecoder.decodeTimePickerThemeData(encoded); + + expect(encoded, { + 'backgroundColor': '#ff000001', + 'dayPeriodBorderSide': { + 'color': '#ff000002', + 'strokeAlign': -1.0, + 'style': 'solid', + 'width': 1.0, + }, + 'dayPeriodColor': '#ff000003', + 'dayPeriodShape': { + 'borderRadius': { + 'bottomLeft': {'type': 'elliptical', 'x': 4.0, 'y': 4.0}, + 'bottomRight': {'type': 'elliptical', 'x': 4.0, 'y': 4.0}, + 'topLeft': {'type': 'elliptical', 'x': 4.0, 'y': 4.0}, + 'topRight': {'type': 'elliptical', 'x': 4.0, 'y': 4.0}, + 'type': 'only' + }, + 'side': { + 'color': '#ff000000', + 'strokeAlign': -1.0, + 'style': 'none', + 'width': 0.0, + }, + 'type': 'rounded', + }, + 'dayPeriodTextColor': '#ff000004', + 'dayPeriodTextStyle': { + 'fontSize': 1.0, + 'inherit': true, + }, + 'dialBackgroundColor': '#ff000005', + 'dialHandColor': '#ff000006', + 'dialTextColor': '#ff000007', + 'entryModeIconColor': '#ff000008', + 'helpTextStyle': { + 'fontSize': 2.0, + 'inherit': true, + }, + 'hourMinuteColor': '#ff000009', + 'hourMinuteShape': { + 'borderRadius': { + 'bottomLeft': {'type': 'elliptical', 'x': 5.0, 'y': 5.0}, + 'bottomRight': {'type': 'elliptical', 'x': 5.0, 'y': 5.0}, + 'topLeft': {'type': 'elliptical', 'x': 5.0, 'y': 5.0}, + 'topRight': {'type': 'elliptical', 'x': 5.0, 'y': 5.0}, + 'type': 'only' + }, + 'side': { + 'color': '#ff000000', + 'strokeAlign': -1.0, + 'style': 'none', + 'width': 0.0, + }, + 'type': 'rounded', + }, + 'hourMinuteTextColor': '#ff000010', + 'hourMinuteTextStyle': { + 'fontSize': 3.0, + 'inherit': true, + }, + 'inputDecorationTheme': { + 'alignLabelWithHint': false, + 'fillColor': '#ff000011', + 'filled': false, + 'floatingLabelAlignment': 'start', + 'floatingLabelBehavior': 'auto', + 'isCollapsed': false, + 'isDense': false, + }, + 'shape': { + 'borderRadius': { + 'bottomLeft': {'type': 'elliptical', 'x': 6.0, 'y': 6.0}, + 'bottomRight': {'type': 'elliptical', 'x': 6.0, 'y': 6.0}, + 'topLeft': {'type': 'elliptical', 'x': 6.0, 'y': 6.0}, + 'topRight': {'type': 'elliptical', 'x': 6.0, 'y': 6.0}, + 'type': 'only' + }, + 'side': { + 'color': '#ff000000', + 'strokeAlign': -1.0, + 'style': 'none', + 'width': 0.0, + }, + 'type': 'rounded', + }, + }); + + expect( + decoded, + entry, + ); + }); + + test('ToggleButtonsThemeData', () { + expect(ThemeDecoder.decodeToggleButtonsThemeData(null), null); + expect(ThemeEncoder.encodeToggleButtonsThemeData(null), null); + + final entry = ToggleButtonsThemeData( + borderColor: const Color(0xff111111), + borderRadius: BorderRadius.circular(1.0), + borderWidth: 2.0, + color: const Color(0xff222222), + constraints: const BoxConstraints( + maxHeight: 30.0, + maxWidth: 40.0, + minHeight: 5.0, + minWidth: 6.0, + ), + disabledBorderColor: const Color(0xff333333), + disabledColor: const Color(0xff444444), + fillColor: const Color(0xff555555), + focusColor: const Color(0xff666666), + highlightColor: const Color(0xff777777), + hoverColor: const Color(0xff888888), + selectedBorderColor: const Color(0xff999999), + selectedColor: const Color(0xff000000), + splashColor: const Color(0xffaaaaaa), + textStyle: const TextStyle(color: Color(0xffbbbbbb)), + ); + + expect(ThemeDecoder.decodeToggleButtonsThemeData(entry), entry); + + final encoded = ThemeEncoder.encodeToggleButtonsThemeData(entry); + final decoded = ThemeDecoder.decodeToggleButtonsThemeData(encoded); + + expect( + encoded, + { + 'borderColor': '#ff111111', + 'borderRadius': { + 'bottomLeft': {'type': 'elliptical', 'x': 1.0, 'y': 1.0}, + 'bottomRight': {'type': 'elliptical', 'x': 1.0, 'y': 1.0}, + 'topLeft': {'type': 'elliptical', 'x': 1.0, 'y': 1.0}, + 'topRight': {'type': 'elliptical', 'x': 1.0, 'y': 1.0}, + 'type': 'only' + }, + 'borderWidth': 2.0, + 'color': '#ff222222', + 'constraints': { + 'maxHeight': 30.0, + 'maxWidth': 40.0, + 'minHeight': 5.0, + 'minWidth': 6.0 + }, + 'disabledBorderColor': '#ff333333', + 'disabledColor': '#ff444444', + 'fillColor': '#ff555555', + 'focusColor': '#ff666666', + 'highlightColor': '#ff777777', + 'hoverColor': '#ff888888', + 'selectedBorderColor': '#ff999999', + 'selectedColor': '#ff000000', + 'splashColor': '#ffaaaaaa', + 'textStyle': {'color': '#ffbbbbbb', 'inherit': true} + }, + ); + + expect( + decoded, + entry, + ); + }); + + test('TooltipThemeData', () { + expect(ThemeDecoder.decodeTooltipThemeData(null), null); + expect(ThemeEncoder.encodeTooltipThemeData(null), null); + + const entry = TooltipThemeData( + enableFeedback: true, + excludeFromSemantics: true, + height: 1.0, + margin: EdgeInsets.all(2.0), + padding: EdgeInsets.all(3.0), + preferBelow: true, + showDuration: Duration(milliseconds: 4), + textAlign: TextAlign.center, + textStyle: _kTextStyle, + triggerMode: TooltipTriggerMode.longPress, + verticalOffset: 5.0, + waitDuration: Duration(milliseconds: 6), + ); + + expect(ThemeDecoder.decodeTooltipThemeData(entry), entry); + + final encoded = ThemeEncoder.encodeTooltipThemeData(entry); + final decoded = ThemeDecoder.decodeTooltipThemeData(encoded); + + expect( + encoded, + { + 'enableFeedback': true, + 'excludeFromSemantics': true, + 'height': 1.0, + 'margin': { + 'bottom': 2.0, + 'left': 2.0, + 'right': 2.0, + 'top': 2.0, + }, + 'padding': { + 'bottom': 3.0, + 'left': 3.0, + 'right': 3.0, + 'top': 3.0, + }, + 'preferBelow': true, + 'showDuration': 4, + 'textAlign': 'center', + 'textStyle': {'color': '#00123456', 'inherit': true}, + 'triggerMode': 'longPress', + 'verticalOffset': 5.0, + 'waitDuration': 6 + }, + ); + + expect( + decoded, + entry, + ); + }); + + test('TooltipTriggerMode', () { + expect(ThemeDecoder.decodeTooltipTriggerMode(null), null); + expect(ThemeEncoder.encodeTooltipTriggerMode(null), null); + + expect( + ThemeDecoder.decodeTooltipTriggerMode(TooltipTriggerMode.longPress), + TooltipTriggerMode.longPress, + ); + + expect( + ThemeDecoder.decodeTooltipTriggerMode('longPress'), + TooltipTriggerMode.longPress, + ); + expect( + ThemeDecoder.decodeTooltipTriggerMode('manual'), + TooltipTriggerMode.manual, + ); + expect( + ThemeDecoder.decodeTooltipTriggerMode('tap'), + TooltipTriggerMode.tap, + ); + + expect( + ThemeEncoder.encodeTooltipTriggerMode(TooltipTriggerMode.longPress), + 'longPress', + ); + expect( + ThemeEncoder.encodeTooltipTriggerMode(TooltipTriggerMode.manual), + 'manual', + ); + expect( + ThemeEncoder.encodeTooltipTriggerMode(TooltipTriggerMode.tap), + 'tap', + ); + }); + + test('Typography', () { + expect(ThemeDecoder.decodeTypography(null), null); + expect(ThemeEncoder.encodeTypography(null), null); + + final entry = Typography.material2018( + black: const TextTheme(bodyLarge: TextStyle(color: Color(0xff111111))), + dense: const TextTheme(bodyLarge: TextStyle(color: Color(0xff222222))), + englishLike: + const TextTheme(bodyLarge: TextStyle(color: Color(0xff333333))), + tall: const TextTheme(bodyLarge: TextStyle(color: Color(0xff444444))), + white: const TextTheme(bodyLarge: TextStyle(color: Color(0xff555555))), + ); + + expect(ThemeDecoder.decodeTypography(entry), entry); + + final encoded = ThemeEncoder.encodeTypography(entry); + final decoded = ThemeDecoder.decodeTypography(encoded); + + expect( + encoded, + { + 'black': { + 'bodyLarge': {'color': '#ff111111', 'inherit': true} + }, + 'dense': { + 'bodyLarge': {'color': '#ff222222', 'inherit': true} + }, + 'englishLike': { + 'bodyLarge': {'color': '#ff333333', 'inherit': true} + }, + 'tall': { + 'bodyLarge': {'color': '#ff444444', 'inherit': true} + }, + 'white': { + 'bodyLarge': {'color': '#ff555555', 'inherit': true} + } + }, + ); + + expect( + decoded, + entry, + ); + }); + test('VerticalDirection', () { + expect(ThemeDecoder.decodeVerticalDirection(null), null); + expect(ThemeEncoder.encodeVerticalDirection(null), null); + + expect( + ThemeDecoder.decodeVerticalDirection( + VerticalDirection.down, + ), + VerticalDirection.down, + ); + + expect( + ThemeDecoder.decodeVerticalDirection('down'), + VerticalDirection.down, + ); + expect( + ThemeDecoder.decodeVerticalDirection('up'), + VerticalDirection.up, + ); + + expect( + ThemeEncoder.encodeVerticalDirection(VerticalDirection.down), + 'down', + ); + expect( + ThemeEncoder.encodeVerticalDirection(VerticalDirection.up), + 'up', + ); + }); + + test('VisualDensity', () { + expect(ThemeDecoder.decodeVisualDensity(null), null); + expect(ThemeEncoder.encodeVisualDensity(null), null); + + expect( + ThemeDecoder.decodeVisualDensity( + VisualDensity.adaptivePlatformDensity, + ), + VisualDensity.adaptivePlatformDensity, + ); + + expect( + ThemeDecoder.decodeVisualDensity('adaptivePlatformDensity'), + VisualDensity.adaptivePlatformDensity, + ); + expect( + ThemeDecoder.decodeVisualDensity('comfortable'), + VisualDensity.comfortable, + ); + expect( + ThemeDecoder.decodeVisualDensity('compact'), + VisualDensity.compact, + ); + expect( + ThemeDecoder.decodeVisualDensity('standard'), + VisualDensity.standard, + ); + + expect( + ThemeEncoder.encodeVisualDensity(VisualDensity.comfortable), + 'comfortable', + ); + expect( + ThemeEncoder.encodeVisualDensity(VisualDensity.compact), + 'compact', + ); + expect( + ThemeEncoder.encodeVisualDensity(VisualDensity.standard), + 'standard', + ); + }); + + test('WidgetStateColor', () { + expect(ThemeDecoder.decodeWidgetStateColor(null), null); + expect(ThemeEncoder.encodeWidgetStateColor(null), null); + + final states = { + 'disabled': WidgetState.disabled, + 'dragged': WidgetState.dragged, + 'error': WidgetState.error, + 'focused': WidgetState.focused, + 'hovered': WidgetState.hovered, + 'pressed': WidgetState.pressed, + 'scrolledUnder': WidgetState.scrolledUnder, + 'selected': WidgetState.selected, + }; + + final colors = { + 'disabled': '#ff111111', + 'dragged': '#ff222222', + 'error': '#ff333333', + 'focused': '#ff444444', + 'hovered': '#ff555555', + 'pressed': '#ff666666', + 'scrolledUnder': '#ff888888', + 'selected': '#ff777777', + 'empty': '#00000000', + }; + + for (var entry in states.entries) { + final stateKey = entry.key; + final state = entry.value; + + final colorStr = colors[stateKey]; + final color = ThemeDecoder.decodeColor(colorStr); + + var decoded = ThemeDecoder.decodeWidgetStateColor(color); + expect(decoded!.resolve({state}), color); + + decoded = ThemeDecoder.decodeWidgetStateColor(colorStr); + expect(decoded!.resolve({state}), color); + + final encoded = ThemeEncoder.encodeWidgetStateColor(decoded); + expect(encoded![stateKey], colorStr); + } + + for (var entry in states.entries) { + final stateKey = entry.key; + final state = entry.value; + + final colorStr = colors[stateKey]; + final color = ThemeDecoder.decodeColor(colorStr); + final encodedColor = ThemeEncoder.encodeColor(color); + + final decoded = ThemeDecoder.decodeWidgetStateColor( + encodedColor, + ); + + expect(decoded!.resolve({state}), color); + + final encoded = ThemeEncoder.encodeWidgetStateColor(decoded); + + expect(encoded![stateKey], colorStr); + } + + /// Test if pressed takes precedence over hovered + final materialColor = ThemeDecoder.decodeWidgetStateColor( + colors, + ); + final color = materialColor?.resolve({ + states['pressed']!, + }); + expect(ThemeEncoder.encodeColor(color), colors['pressed']); + }); + + test('WidgetStatePropertyBool', () { + expect(ThemeDecoder.decodeWidgetStatePropertyBool(null), null); + expect(ThemeEncoder.encodeWidgetStatePropertyBool(null), null); + + final stateMap = { + WidgetState.disabled: 'disabled', + WidgetState.dragged: 'dragged', + WidgetState.error: 'error', + WidgetState.focused: 'focused', + WidgetState.hovered: 'hovered', + WidgetState.pressed: 'pressed', + WidgetState.scrolledUnder: 'scrolledUnder', + WidgetState.selected: 'selected', + }; + + final states = { + 'disabled': WidgetState.disabled, + 'dragged': WidgetState.dragged, + 'error': WidgetState.error, + 'focused': WidgetState.focused, + 'hovered': WidgetState.hovered, + 'pressed': WidgetState.pressed, + 'scrolledUnder': WidgetState.scrolledUnder, + 'selected': WidgetState.selected, + }; + + final values = { + 'disabled': true, + 'dragged': true, + 'error': true, + 'focused': true, + 'hovered': false, + 'pressed': true, + 'scrolledUnder': false, + 'selected': false, + }; + + for (var entry in states.entries) { + final stateKey = entry.key; + final state = entry.value; + + final value = values[stateKey]; + + var decoded = ThemeDecoder.decodeWidgetStatePropertyBool(value); + expect(decoded?.resolve({state}), value); + + decoded = ThemeDecoder.decodeWidgetStatePropertyBool(value.toString()); + expect(decoded?.resolve({state}), value); + + final encoded = ThemeEncoder.encodeWidgetStatePropertyBool(decoded); + expect(encoded![stateKey], value); + } + + bool? func(Set states) => + states.isEmpty ? null : values[stateMap[states.first]!]; + + final prop = WidgetStateProperty.resolveWith(func); + final decoded = ThemeDecoder.decodeWidgetStatePropertyBool(prop); + for (var entry in states.entries) { + final value = values[stateMap[entry.value]!]; + + expect(decoded!.resolve({entry.value}), value); + + final encoded = ThemeEncoder.encodeWidgetStatePropertyBool(decoded); + + expect(encoded?[entry.key], value); + } + + for (var entry in states.entries) { + final stateKey = entry.key; + final state = entry.value; + + final value = values[stateKey]; + + final decoded = ThemeDecoder.decodeWidgetStatePropertyBool(value); + + expect(decoded!.resolve({state}), value); + + final encoded = ThemeEncoder.encodeWidgetStatePropertyBool(decoded); + + expect(encoded![stateKey], value); + } + }); + + test('WidgetStatePropertyBorderSide', () { + expect(ThemeDecoder.decodeWidgetStatePropertyBorderSide(null), null); + expect(ThemeEncoder.encodeWidgetStatePropertyBorderSide(null), null); + + final states = { + 'disabled': WidgetState.disabled, + 'dragged': WidgetState.dragged, + 'error': WidgetState.error, + 'focused': WidgetState.focused, + 'hovered': WidgetState.hovered, + 'pressed': WidgetState.pressed, + 'scrolledUnder': WidgetState.scrolledUnder, + 'selected': WidgetState.selected, + }; + + var count = 1.0; + final sides = {}; + + for (var entry in states.entries) { + final stateKey = entry.key; + final state = entry.value; + + final side = BorderSide( + color: _kColor, + style: BorderStyle.solid, + width: ++count, + ); + sides[state] = side; + + final decoded = ThemeDecoder.decodeWidgetStatePropertyBorderSide(side); + + expect(decoded!.resolve({state}), side); + + final encoded = ThemeEncoder.encodeWidgetStatePropertyBorderSide(decoded); + + expect(encoded![stateKey]['width'], side.width); + } + + BorderSide? func(Set states) => + states.isEmpty ? null : sides[states.first]; + + final prop = WidgetStateProperty.resolveWith(func); + final decoded = ThemeDecoder.decodeWidgetStatePropertyBorderSide(prop); + for (var entry in states.entries) { + final side = sides[entry.value]; + + expect(decoded!.resolve({entry.value}), side); + + final encoded = ThemeEncoder.encodeWidgetStatePropertyBorderSide(decoded); + + expect(encoded![entry.key]['width'], side!.width); + } + + for (var entry in states.entries) { + final stateKey = entry.key; + final state = entry.value; + + final side = BorderSide( + color: _kColor, + style: BorderStyle.solid, + width: ++count, + ); + final encodedSide = ThemeEncoder.encodeBorderSide(side); + + final decoded = ThemeDecoder.decodeWidgetStatePropertyBorderSide( + encodedSide, + ); + + expect(decoded!.resolve({state}), side); + + final encoded = ThemeEncoder.encodeWidgetStatePropertyBorderSide(decoded); + + expect(encoded![stateKey]['width'], side.width); + } + }); + + test('WidgetStatePropertyColor', () { + expect(ThemeDecoder.decodeWidgetStatePropertyColor(null), null); + expect(ThemeEncoder.encodeWidgetStatePropertyColor(null), null); + + final stateMap = { + WidgetState.disabled: 'disabled', + WidgetState.dragged: 'dragged', + WidgetState.error: 'error', + WidgetState.focused: 'focused', + WidgetState.hovered: 'hovered', + WidgetState.pressed: 'pressed', + WidgetState.scrolledUnder: 'scrolledUnder', + WidgetState.selected: 'selected', + }; + final states = { + 'disabled': WidgetState.disabled, + 'dragged': WidgetState.dragged, + 'error': WidgetState.error, + 'focused': WidgetState.focused, + 'hovered': WidgetState.hovered, + 'pressed': WidgetState.pressed, + 'scrolledUnder': WidgetState.scrolledUnder, + 'selected': WidgetState.selected, + }; + + final colors = { + 'disabled': '#ff111111', + 'dragged': '#ff222222', + 'error': '#ff333333', + 'focused': '#ff444444', + 'hovered': '#ff555555', + 'pressed': '#ff666666', + 'scrolledUnder': '#ff888888', + 'selected': '#ff777777', + }; + + for (var entry in states.entries) { + final stateKey = entry.key; + final state = entry.value; + + final colorStr = colors[stateKey]; + final color = ThemeDecoder.decodeColor(colorStr); + + var decoded = ThemeDecoder.decodeWidgetStatePropertyColor(color); + expect(decoded!.resolve({state}), color); + + decoded = ThemeDecoder.decodeWidgetStatePropertyColor(colorStr); + expect(decoded!.resolve({state}), color); + + final encoded = ThemeEncoder.encodeWidgetStatePropertyColor(decoded); + expect(encoded![stateKey], colorStr); + } + + Color? func(Set states) => states.isEmpty + ? null + : ThemeDecoder.decodeColor(colors[stateMap[states.first]]); + + final prop = WidgetStateProperty.resolveWith(func); + final decoded = ThemeDecoder.decodeWidgetStatePropertyColor(prop); + for (var entry in states.entries) { + final colorStr = colors[stateMap[entry.value]]; + final color = ThemeDecoder.decodeColor(colorStr); + + expect(decoded!.resolve({entry.value}), color); + + final encoded = ThemeEncoder.encodeWidgetStatePropertyColor(decoded); + + expect(encoded?[entry.key], colorStr); + } + + for (var entry in states.entries) { + final stateKey = entry.key; + final state = entry.value; + + final colorStr = colors[stateKey]; + final color = ThemeDecoder.decodeColor(colorStr); + final encodedColor = ThemeEncoder.encodeColor(color); + + final decoded = ThemeDecoder.decodeWidgetStatePropertyColor( + encodedColor, + ); + + expect(decoded!.resolve({state}), color); + + final encoded = ThemeEncoder.encodeWidgetStatePropertyColor(decoded); + + expect(encoded![stateKey], colorStr); + } + + /// Test if pressed takes precedence over hovered + final materialColor = ThemeDecoder.decodeWidgetStatePropertyColor( + colors, + ); + final color = materialColor?.resolve({ + states['hovered']!, + states['pressed']!, + }); + expect(ThemeEncoder.encodeColor(color), colors['pressed']); + }); + + test('WidgetStatePropertyDouble', () { + expect(ThemeDecoder.decodeWidgetStatePropertyDouble(null), null); + expect(ThemeEncoder.encodeWidgetStatePropertyDouble(null), null); + final stateMap = { + WidgetState.disabled: 'disabled', + WidgetState.dragged: 'dragged', + WidgetState.error: 'error', + WidgetState.focused: 'focused', + WidgetState.hovered: 'hovered', + WidgetState.pressed: 'pressed', + WidgetState.scrolledUnder: 'scrolledUnder', + WidgetState.selected: 'selected', + }; + + final states = { + 'disabled': WidgetState.disabled, + 'dragged': WidgetState.dragged, + 'error': WidgetState.error, + 'focused': WidgetState.focused, + 'hovered': WidgetState.hovered, + 'pressed': WidgetState.pressed, + 'scrolledUnder': WidgetState.scrolledUnder, + 'selected': WidgetState.selected, + }; - final reencoded = ThemeEncoder.encodeThemeData(decoded); - expect(reencoded, jsonMap); + final values = { + 'disabled': 1.0, + 'dragged': 2.0, + 'error': 3.0, + 'focused': 4.0, + 'hovered': 5.0, + 'pressed': 6.0, + 'scrolledUnder': 8.0, + 'selected': 7.0, + }; + + for (var entry in states.entries) { + final stateKey = entry.key; + final state = entry.value; + + final value = values[stateKey]; + + var decoded = ThemeDecoder.decodeWidgetStatePropertyDouble(value); + expect(decoded!.resolve({state}), value); + + decoded = ThemeDecoder.decodeWidgetStatePropertyDouble(value.toString()); + expect(decoded!.resolve({state}), value); + + final encoded = ThemeEncoder.encodeWidgetStatePropertyDouble(decoded); + expect(encoded![stateKey], value); + } + + double? func(Set states) => + states.isEmpty ? null : values[stateMap[states.first]]; + + final prop = WidgetStateProperty.resolveWith(func); + final decoded = ThemeDecoder.decodeWidgetStatePropertyDouble(prop); + for (var entry in states.entries) { + final value = values[stateMap[entry.value]]; + + expect(decoded!.resolve({entry.value}), value); + + final encoded = ThemeEncoder.encodeWidgetStatePropertyDouble(decoded); + + expect(encoded?[entry.key], value); + } + + for (var entry in states.entries) { + final stateKey = entry.key; + final state = entry.value; + + final value = values[stateKey]; + + final decoded = ThemeDecoder.decodeWidgetStatePropertyDouble(value); + + expect(decoded!.resolve({state}), value); + + final encoded = ThemeEncoder.encodeWidgetStatePropertyDouble(decoded); + + expect(encoded![stateKey], value); + } }); - test('TileMode', () { - expect(ThemeDecoder.decodeTileMode(null), null); - expect(ThemeEncoder.encodeTileMode(null), null); + test('WidgetStatePropertyEdgeInsetsGeometry', () { + expect( + ThemeDecoder.decodeWidgetStatePropertyEdgeInsetsGeometry(null), null); + expect( + ThemeEncoder.encodeWidgetStatePropertyEdgeInsetsGeometry(null), null); + + final states = { + 'disabled': WidgetState.disabled, + 'dragged': WidgetState.dragged, + 'error': WidgetState.error, + 'focused': WidgetState.focused, + 'hovered': WidgetState.hovered, + 'pressed': WidgetState.pressed, + 'scrolledUnder': WidgetState.scrolledUnder, + 'selected': WidgetState.selected, + }; + + var count = 1.0; + final sides = {}; + + for (var entry in states.entries) { + final stateKey = entry.key; + final state = entry.value; + + final side = EdgeInsets.all(++count); + sides[state] = side; + + final decoded = + ThemeDecoder.decodeWidgetStatePropertyEdgeInsetsGeometry(side); + + expect(decoded!.resolve({state}), side); + + final encoded = + ThemeEncoder.encodeWidgetStatePropertyEdgeInsetsGeometry(decoded); + + expect(encoded![stateKey]['bottom'], side.bottom); + } + + EdgeInsetsGeometry? func(Set states) => + states.isEmpty ? null : sides[states.first]; + + final prop = WidgetStateProperty.resolveWith(func); + final decoded = + ThemeDecoder.decodeWidgetStatePropertyEdgeInsetsGeometry(prop); + for (var entry in states.entries) { + final side = sides[entry.value]; + + expect(decoded!.resolve({entry.value}), side); + + final encoded = + ThemeEncoder.encodeWidgetStatePropertyEdgeInsetsGeometry(decoded); + + expect(encoded![entry.key]['bottom'], (side as EdgeInsets).bottom); + } + + for (var entry in states.entries) { + final stateKey = entry.key; + final state = entry.value; + + final side = EdgeInsets.all(++count); + final encodedSide = ThemeEncoder.encodeEdgeInsetsGeometry(side); + + final decoded = ThemeDecoder.decodeWidgetStatePropertyEdgeInsetsGeometry( + encodedSide, + ); + + expect(decoded!.resolve({state}), side); + + final encoded = + ThemeEncoder.encodeWidgetStatePropertyEdgeInsetsGeometry(decoded); + + expect(encoded![stateKey]['bottom'], side.bottom); + } + + final symmetricDecoded = + ThemeDecoder.decodeWidgetStatePropertyEdgeInsetsGeometry([1, 2]); + for (var state in states.values) { + expect(symmetricDecoded!.resolve({state}), + const EdgeInsets.symmetric(horizontal: 1, vertical: 2)); + } + + final ltrbDecoded = + ThemeDecoder.decodeWidgetStatePropertyEdgeInsetsGeometry([1, 2, 3, 4]); + for (var state in states.values) { + expect( + ltrbDecoded!.resolve({state}), const EdgeInsets.fromLTRB(1, 2, 3, 4)); + } + + final allDecoded = + ThemeDecoder.decodeWidgetStatePropertyEdgeInsetsGeometry(1); + for (var state in states.values) { + expect(allDecoded!.resolve({state}), const EdgeInsets.all(1)); + } + }); + + test('WidgetStatePropertyIconThemeData', () { + expect(ThemeDecoder.decodeWidgetStatePropertyIconThemeData(null), null); + expect(ThemeEncoder.encodeWidgetStatePropertyIconThemeData(null), null); + + final states = { + 'disabled': WidgetState.disabled, + 'dragged': WidgetState.dragged, + 'error': WidgetState.error, + 'focused': WidgetState.focused, + 'hovered': WidgetState.hovered, + 'pressed': WidgetState.pressed, + 'scrolledUnder': WidgetState.scrolledUnder, + 'selected': WidgetState.selected, + }; + + final icons = {}; + + for (var entry in states.entries) { + final stateKey = entry.key; + final state = entry.value; + + const icon = IconThemeData( + color: _kColor, + opacity: 0.5, + size: 12.0, + ); + icons[state] = icon; + + final decoded = ThemeDecoder.decodeWidgetStatePropertyIconThemeData(icon); + + expect(decoded!.resolve({state}), icon); + + final encoded = + ThemeEncoder.encodeWidgetStatePropertyIconThemeData(decoded); + + expect(encoded![stateKey]['color'], _kColorStr); + } + + IconThemeData? func(Set states) => + states.isEmpty ? null : icons[states.first]; + + final prop = WidgetStateProperty.resolveWith(func); + final decoded = ThemeDecoder.decodeWidgetStatePropertyIconThemeData(prop); + for (var entry in states.entries) { + final icon = icons[entry.value]; + + expect(decoded!.resolve({entry.value}), icon); + + final encoded = ThemeEncoder.encodeWidgetStatePropertyIconThemeData( + decoded, + ); + + expect(encoded![entry.key]['color'], _kColorStr); + } + + for (var entry in states.entries) { + final stateKey = entry.key; + final state = entry.value; + + final icon = icons[state]; + final encodedSide = ThemeEncoder.encodeIconThemeData(icon); + + final decoded = ThemeDecoder.decodeWidgetStatePropertyIconThemeData( + encodedSide, + ); + + expect(decoded!.resolve({state}), icon); + + final encoded = + ThemeEncoder.encodeWidgetStatePropertyIconThemeData(decoded); + + expect(encoded![stateKey]['color'], _kColorStr); + } + }); + + test('WidgetStatePropertyMouseCursor', () { + expect(ThemeDecoder.decodeWidgetStatePropertyColor(null), null); + expect(ThemeEncoder.encodeWidgetStatePropertyColor(null), null); + final stateMap = { + WidgetState.disabled: 'disabled', + WidgetState.dragged: 'dragged', + WidgetState.error: 'error', + WidgetState.focused: 'focused', + WidgetState.hovered: 'hovered', + WidgetState.pressed: 'pressed', + WidgetState.scrolledUnder: 'scrolledUnder', + WidgetState.selected: 'selected', + }; + + final states = { + 'disabled': WidgetState.disabled, + 'dragged': WidgetState.dragged, + 'error': WidgetState.error, + 'focused': WidgetState.focused, + 'hovered': WidgetState.hovered, + 'pressed': WidgetState.pressed, + 'scrolledUnder': WidgetState.scrolledUnder, + 'selected': WidgetState.selected, + }; + + final cursors = { + 'disabled': {'type': 'system', 'cursor': 'alias'}, + 'dragged': {'type': 'system', 'cursor': 'allScroll'}, + 'error': {'type': 'system', 'cursor': 'basic'}, + 'focused': {'type': 'system', 'cursor': 'cell'}, + 'hovered': {'type': 'system', 'cursor': 'click'}, + 'pressed': {'type': 'system', 'cursor': 'contextMenu'}, + 'scrolledUnder': {'type': 'system', 'cursor': 'grab'}, + 'selected': {'type': 'system', 'cursor': 'copy'}, + }; + + for (var entry in states.entries) { + final stateKey = entry.key; + final state = entry.value; + + final cursorStr = cursors[stateKey]; + final cursor = ThemeDecoder.decodeMouseCursor(cursorStr); + + var decoded = ThemeDecoder.decodeWidgetStatePropertyMouseCursor(cursor); + expect(decoded!.resolve({state}), cursor); + + decoded = ThemeDecoder.decodeWidgetStatePropertyMouseCursor(cursorStr); + expect(decoded!.resolve({state}), cursor); + + final encoded = + ThemeEncoder.encodeWidgetStatePropertyMouseCursor(decoded); + expect(encoded![stateKey], cursorStr); + } + + MouseCursor? func(Set states) => states.isEmpty + ? null + : ThemeDecoder.decodeMouseCursor(cursors[stateMap[states.first]]); + + final prop = WidgetStateProperty.resolveWith(func); + final decoded = ThemeDecoder.decodeWidgetStatePropertyMouseCursor(prop); + for (var entry in states.entries) { + final cursorStr = cursors[stateMap[entry.value]]; + final cursor = ThemeDecoder.decodeMouseCursor(cursorStr); + + expect(decoded!.resolve({entry.value}), cursor); + + final encoded = + ThemeEncoder.encodeWidgetStatePropertyMouseCursor(decoded); + + expect(encoded?[entry.key], cursorStr); + } + + for (var entry in states.entries) { + final stateKey = entry.key; + final state = entry.value; + + final cursorStr = cursors[stateKey]; + final cursor = ThemeDecoder.decodeMouseCursor(cursorStr); + final encodedCursor = ThemeEncoder.encodeMouseCursor(cursor); - expect( - ThemeDecoder.decodeTileMode( - TileMode.clamp, - ), - TileMode.clamp, - ); + final decoded = ThemeDecoder.decodeWidgetStatePropertyMouseCursor( + encodedCursor, + ); - expect(ThemeDecoder.decodeTileMode('clamp'), TileMode.clamp); - expect(ThemeDecoder.decodeTileMode('mirror'), TileMode.mirror); - expect(ThemeDecoder.decodeTileMode('repeated'), TileMode.repeated); + expect(decoded!.resolve({state}), cursor); - expect(ThemeEncoder.encodeTileMode(TileMode.clamp), 'clamp'); - expect(ThemeEncoder.encodeTileMode(TileMode.mirror), 'mirror'); - expect(ThemeEncoder.encodeTileMode(TileMode.repeated), 'repeated'); + final encoded = + ThemeEncoder.encodeWidgetStatePropertyMouseCursor(decoded); + + expect(encoded![stateKey], cursorStr); + } }); - test('TimePickerThemeData', () { - expect(ThemeDecoder.decodeTimePickerThemeData(null), null); - expect(ThemeEncoder.encodeTimePickerThemeData(null), null); + test('WidgetStatePropertyOutlinedBorder', () { + expect(ThemeDecoder.decodeWidgetStatePropertyOutlinedBorder(null), null); + expect(ThemeEncoder.encodeWidgetStatePropertyOutlinedBorder(null), null); - final entry = TimePickerThemeData( - backgroundColor: const Color(0xff000001), - dayPeriodBorderSide: const BorderSide( - color: Color(0xff000002), - style: BorderStyle.solid, - width: 1.0, - ), - dayPeriodColor: MaterialStateColor.resolveWith( - (_) => const Color(0xff000003), - ), - dayPeriodShape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(4.0), - ), - dayPeriodTextColor: const Color(0xff000004), - dayPeriodTextStyle: const TextStyle(fontSize: 1.0), - dialBackgroundColor: const Color(0xff000005), - dialHandColor: const Color(0xff000006), - dialTextColor: const Color(0xff000007), - entryModeIconColor: const Color(0xff000008), - helpTextStyle: const TextStyle(fontSize: 2.0), - hourMinuteColor: const Color(0xff000009), - hourMinuteShape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5.0), - ), - hourMinuteTextColor: const Color(0xff000010), - hourMinuteTextStyle: const TextStyle(fontSize: 3.0), - inputDecorationTheme: - const InputDecorationTheme(fillColor: Color(0xff000011)), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(6.0)), - ); + final states = { + 'disabled': WidgetState.disabled, + 'dragged': WidgetState.dragged, + 'error': WidgetState.error, + 'focused': WidgetState.focused, + 'hovered': WidgetState.hovered, + 'pressed': WidgetState.pressed, + 'scrolledUnder': WidgetState.scrolledUnder, + 'selected': WidgetState.selected, + }; - expect(ThemeDecoder.decodeTimePickerThemeData(entry), entry); + var count = 1.0; + final sides = {}; - final encoded = ThemeEncoder.encodeTimePickerThemeData(entry); - final decoded = ThemeDecoder.decodeTimePickerThemeData(encoded); + for (var entry in states.entries) { + final stateKey = entry.key; + final state = entry.value; - expect(encoded, { - 'backgroundColor': '#ff000001', - 'dayPeriodBorderSide': { - 'color': '#ff000002', - 'strokeAlign': -1.0, - 'style': 'solid', - 'width': 1.0, - }, - 'dayPeriodColor': '#ff000003', - 'dayPeriodShape': { - 'borderRadius': { - 'bottomLeft': {'type': 'elliptical', 'x': 4.0, 'y': 4.0}, - 'bottomRight': {'type': 'elliptical', 'x': 4.0, 'y': 4.0}, - 'topLeft': {'type': 'elliptical', 'x': 4.0, 'y': 4.0}, - 'topRight': {'type': 'elliptical', 'x': 4.0, 'y': 4.0}, - 'type': 'only' - }, - 'side': { - 'color': '#ff000000', - 'strokeAlign': -1.0, - 'style': 'none', - 'width': 0.0, - }, - 'type': 'rounded', - }, - 'dayPeriodTextColor': '#ff000004', - 'dayPeriodTextStyle': { - 'fontSize': 1.0, - 'inherit': true, - }, - 'dialBackgroundColor': '#ff000005', - 'dialHandColor': '#ff000006', - 'dialTextColor': '#ff000007', - 'entryModeIconColor': '#ff000008', - 'helpTextStyle': { - 'fontSize': 2.0, - 'inherit': true, - }, - 'hourMinuteColor': '#ff000009', - 'hourMinuteShape': { - 'borderRadius': { - 'bottomLeft': {'type': 'elliptical', 'x': 5.0, 'y': 5.0}, - 'bottomRight': {'type': 'elliptical', 'x': 5.0, 'y': 5.0}, - 'topLeft': {'type': 'elliptical', 'x': 5.0, 'y': 5.0}, - 'topRight': {'type': 'elliptical', 'x': 5.0, 'y': 5.0}, - 'type': 'only' - }, - 'side': { - 'color': '#ff000000', - 'strokeAlign': -1.0, - 'style': 'none', - 'width': 0.0, - }, - 'type': 'rounded', - }, - 'hourMinuteTextColor': '#ff000010', - 'hourMinuteTextStyle': { - 'fontSize': 3.0, - 'inherit': true, - }, - 'inputDecorationTheme': { - 'alignLabelWithHint': false, - 'fillColor': '#ff000011', - 'filled': false, - 'floatingLabelAlignment': 'start', - 'floatingLabelBehavior': 'auto', - 'isCollapsed': false, - 'isDense': false, - }, - 'shape': { - 'borderRadius': { - 'bottomLeft': {'type': 'elliptical', 'x': 6.0, 'y': 6.0}, - 'bottomRight': {'type': 'elliptical', 'x': 6.0, 'y': 6.0}, - 'topLeft': {'type': 'elliptical', 'x': 6.0, 'y': 6.0}, - 'topRight': {'type': 'elliptical', 'x': 6.0, 'y': 6.0}, - 'type': 'only' - }, - 'side': { - 'color': '#ff000000', - 'strokeAlign': -1.0, - 'style': 'none', - 'width': 0.0, - }, - 'type': 'rounded', - }, - }); + final side = RoundedRectangleBorder( + side: BorderSide( + color: Colors.black, + style: BorderStyle.solid, + width: ++count, + ), + ); + sides[state] = side; - expect( - decoded, - entry, - ); - }); + final decoded = + ThemeDecoder.decodeWidgetStatePropertyOutlinedBorder(side); - test('ToggleButtonsThemeData', () { - expect(ThemeDecoder.decodeToggleButtonsThemeData(null), null); - expect(ThemeEncoder.encodeToggleButtonsThemeData(null), null); + expect(decoded!.resolve({state}), side); - final entry = ToggleButtonsThemeData( - borderColor: const Color(0xff111111), - borderRadius: BorderRadius.circular(1.0), - borderWidth: 2.0, - color: const Color(0xff222222), - constraints: const BoxConstraints( - maxHeight: 30.0, - maxWidth: 40.0, - minHeight: 5.0, - minWidth: 6.0, - ), - disabledBorderColor: const Color(0xff333333), - disabledColor: const Color(0xff444444), - fillColor: const Color(0xff555555), - focusColor: const Color(0xff666666), - highlightColor: const Color(0xff777777), - hoverColor: const Color(0xff888888), - selectedBorderColor: const Color(0xff999999), - selectedColor: const Color(0xff000000), - splashColor: const Color(0xffaaaaaa), - textStyle: const TextStyle(color: Color(0xffbbbbbb)), - ); + final encoded = + ThemeEncoder.encodeWidgetStatePropertyOutlinedBorder(decoded); - expect(ThemeDecoder.decodeToggleButtonsThemeData(entry), entry); + expect(encoded![stateKey]['side']['width'], side.side.width); + } - final encoded = ThemeEncoder.encodeToggleButtonsThemeData(entry); - final decoded = ThemeDecoder.decodeToggleButtonsThemeData(encoded); + OutlinedBorder? func(Set states) => + states.isEmpty ? null : sides[states.first]; - expect( - encoded, - { - 'borderColor': '#ff111111', - 'borderRadius': { - 'bottomLeft': {'type': 'elliptical', 'x': 1.0, 'y': 1.0}, - 'bottomRight': {'type': 'elliptical', 'x': 1.0, 'y': 1.0}, - 'topLeft': {'type': 'elliptical', 'x': 1.0, 'y': 1.0}, - 'topRight': {'type': 'elliptical', 'x': 1.0, 'y': 1.0}, - 'type': 'only' - }, - 'borderWidth': 2.0, - 'color': '#ff222222', - 'constraints': { - 'maxHeight': 30.0, - 'maxWidth': 40.0, - 'minHeight': 5.0, - 'minWidth': 6.0 - }, - 'disabledBorderColor': '#ff333333', - 'disabledColor': '#ff444444', - 'fillColor': '#ff555555', - 'focusColor': '#ff666666', - 'highlightColor': '#ff777777', - 'hoverColor': '#ff888888', - 'selectedBorderColor': '#ff999999', - 'selectedColor': '#ff000000', - 'splashColor': '#ffaaaaaa', - 'textStyle': {'color': '#ffbbbbbb', 'inherit': true} - }, - ); + final prop = WidgetStateProperty.resolveWith(func); + final decoded = ThemeDecoder.decodeWidgetStatePropertyOutlinedBorder(prop); + for (var entry in states.entries) { + final side = sides[entry.value]; - expect( - decoded, - entry, - ); - }); + expect(decoded!.resolve({entry.value}), side); - test('TooltipThemeData', () { - expect(ThemeDecoder.decodeTooltipThemeData(null), null); - expect(ThemeEncoder.encodeTooltipThemeData(null), null); + final encoded = + ThemeEncoder.encodeWidgetStatePropertyOutlinedBorder(decoded); - const entry = TooltipThemeData( - enableFeedback: true, - excludeFromSemantics: true, - height: 1.0, - margin: EdgeInsets.all(2.0), - padding: EdgeInsets.all(3.0), - preferBelow: true, - showDuration: Duration(milliseconds: 4), - textAlign: TextAlign.center, - textStyle: _kTextStyle, - triggerMode: TooltipTriggerMode.longPress, - verticalOffset: 5.0, - waitDuration: Duration(milliseconds: 6), - ); + expect(encoded![entry.key]['side']['width'], side!.side.width); + } - expect(ThemeDecoder.decodeTooltipThemeData(entry), entry); + for (var entry in states.entries) { + final stateKey = entry.key; + final state = entry.value; - final encoded = ThemeEncoder.encodeTooltipThemeData(entry); - final decoded = ThemeDecoder.decodeTooltipThemeData(encoded); + final side = sides[state]; + final encodedSide = ThemeEncoder.encodeOutlinedBorder(side); - expect( - encoded, - { - 'enableFeedback': true, - 'excludeFromSemantics': true, - 'height': 1.0, - 'margin': { - 'bottom': 2.0, - 'left': 2.0, - 'right': 2.0, - 'top': 2.0, - }, - 'padding': { - 'bottom': 3.0, - 'left': 3.0, - 'right': 3.0, - 'top': 3.0, - }, - 'preferBelow': true, - 'showDuration': 4, - 'textAlign': 'center', - 'textStyle': {'color': '#00123456', 'inherit': true}, - 'triggerMode': 'longPress', - 'verticalOffset': 5.0, - 'waitDuration': 6 - }, - ); + final decoded = ThemeDecoder.decodeWidgetStatePropertyOutlinedBorder( + encodedSide, + ); - expect( - decoded, - entry, - ); - }); + expect(decoded!.resolve({state}), side); - test('TooltipTriggerMode', () { - expect(ThemeDecoder.decodeTooltipTriggerMode(null), null); - expect(ThemeEncoder.encodeTooltipTriggerMode(null), null); + final encoded = + ThemeEncoder.encodeWidgetStatePropertyOutlinedBorder(decoded); - expect( - ThemeDecoder.decodeTooltipTriggerMode(TooltipTriggerMode.longPress), - TooltipTriggerMode.longPress, - ); + expect(encoded![stateKey]['side']['width'], side!.side.width); + } + }); + test('WidgetStatePropertySize', () { expect( - ThemeDecoder.decodeTooltipTriggerMode('longPress'), - TooltipTriggerMode.longPress, - ); - expect( - ThemeDecoder.decodeTooltipTriggerMode('manual'), - TooltipTriggerMode.manual, + ThemeDecoder.decodeWidgetStatePropertySize(null), + null, ); expect( - ThemeDecoder.decodeTooltipTriggerMode('tap'), - TooltipTriggerMode.tap, + ThemeEncoder.encodeWidgetStatePropertySize(null), + null, ); - expect( - ThemeEncoder.encodeTooltipTriggerMode(TooltipTriggerMode.longPress), - 'longPress', - ); - expect( - ThemeEncoder.encodeTooltipTriggerMode(TooltipTriggerMode.manual), - 'manual', - ); - expect( - ThemeEncoder.encodeTooltipTriggerMode(TooltipTriggerMode.tap), - 'tap', - ); - }); + final states = { + 'disabled': WidgetState.disabled, + 'dragged': WidgetState.dragged, + 'error': WidgetState.error, + 'focused': WidgetState.focused, + 'hovered': WidgetState.hovered, + 'pressed': WidgetState.pressed, + 'scrolledUnder': WidgetState.scrolledUnder, + 'selected': WidgetState.selected, + }; - test('Typography', () { - expect(ThemeDecoder.decodeTypography(null), null); - expect(ThemeEncoder.encodeTypography(null), null); + var count = 1.0; + final sides = {}; - final entry = Typography.material2018( - black: const TextTheme(bodyLarge: TextStyle(color: Color(0xff111111))), - dense: const TextTheme(bodyLarge: TextStyle(color: Color(0xff222222))), - englishLike: - const TextTheme(bodyLarge: TextStyle(color: Color(0xff333333))), - tall: const TextTheme(bodyLarge: TextStyle(color: Color(0xff444444))), - white: const TextTheme(bodyLarge: TextStyle(color: Color(0xff555555))), - ); + for (var entry in states.entries) { + final stateKey = entry.key; + final state = entry.value; - expect(ThemeDecoder.decodeTypography(entry), entry); + final side = Size( + ++count, + ++count, + ); + sides[state] = side; - final encoded = ThemeEncoder.encodeTypography(entry); - final decoded = ThemeDecoder.decodeTypography(encoded); + final decoded = ThemeDecoder.decodeWidgetStatePropertySize(side); - expect( - encoded, - { - 'black': { - 'bodyLarge': {'color': '#ff111111', 'inherit': true} - }, - 'dense': { - 'bodyLarge': {'color': '#ff222222', 'inherit': true} - }, - 'englishLike': { - 'bodyLarge': {'color': '#ff333333', 'inherit': true} - }, - 'tall': { - 'bodyLarge': {'color': '#ff444444', 'inherit': true} - }, - 'white': { - 'bodyLarge': {'color': '#ff555555', 'inherit': true} - } - }, - ); + expect(decoded!.resolve({state}), side); - expect( - decoded, - entry, - ); - }); - test('VerticalDirection', () { - expect(ThemeDecoder.decodeVerticalDirection(null), null); - expect(ThemeEncoder.encodeVerticalDirection(null), null); + final encoded = ThemeEncoder.encodeWidgetStatePropertySize(decoded); - expect( - ThemeDecoder.decodeVerticalDirection( - VerticalDirection.down, - ), - VerticalDirection.down, - ); + expect(encoded![stateKey]['width'], side.width); + } - expect( - ThemeDecoder.decodeVerticalDirection('down'), - VerticalDirection.down, - ); - expect( - ThemeDecoder.decodeVerticalDirection('up'), - VerticalDirection.up, - ); + Size? func(Set states) => + states.isEmpty ? null : sides[states.first]; - expect( - ThemeEncoder.encodeVerticalDirection(VerticalDirection.down), - 'down', - ); - expect( - ThemeEncoder.encodeVerticalDirection(VerticalDirection.up), - 'up', - ); + final prop = WidgetStateProperty.resolveWith(func); + final decoded = ThemeDecoder.decodeWidgetStatePropertySize(prop); + for (var entry in states.entries) { + final side = sides[entry.value]; + + expect(decoded!.resolve({entry.value}), side); + + final encoded = ThemeEncoder.encodeWidgetStatePropertySize(decoded); + + expect(encoded![entry.key]['width'], side!.width); + } + + for (var entry in states.entries) { + final stateKey = entry.key; + final state = entry.value; + + final side = sides[state]; + final encodedSide = ThemeEncoder.encodeSize(side); + + final decoded = ThemeDecoder.decodeWidgetStatePropertySize( + encodedSide, + ); + + expect(decoded!.resolve({state}), side); + + final encoded = ThemeEncoder.encodeWidgetStatePropertySize(decoded); + + expect(encoded![stateKey]['width'], side!.width); + } }); - test('VisualDensity', () { - expect(ThemeDecoder.decodeVisualDensity(null), null); - expect(ThemeEncoder.encodeVisualDensity(null), null); + test('WidgetStatePropertyTextStyle', () { + expect(ThemeDecoder.decodeWidgetStatePropertyTextStyle(null), null); + expect(ThemeEncoder.encodeWidgetStatePropertyTextStyle(null), null); - expect( - ThemeDecoder.decodeVisualDensity( - VisualDensity.adaptivePlatformDensity, - ), - VisualDensity.adaptivePlatformDensity, - ); + final states = { + 'disabled': WidgetState.disabled, + 'dragged': WidgetState.dragged, + 'error': WidgetState.error, + 'focused': WidgetState.focused, + 'hovered': WidgetState.hovered, + 'pressed': WidgetState.pressed, + 'scrolledUnder': WidgetState.scrolledUnder, + 'selected': WidgetState.selected, + }; - expect( - ThemeDecoder.decodeVisualDensity('adaptivePlatformDensity'), - VisualDensity.adaptivePlatformDensity, - ); - expect( - ThemeDecoder.decodeVisualDensity('comfortable'), - VisualDensity.comfortable, - ); - expect( - ThemeDecoder.decodeVisualDensity('compact'), - VisualDensity.compact, - ); - expect( - ThemeDecoder.decodeVisualDensity('standard'), - VisualDensity.standard, - ); + var count = 1.0; + final sides = {}; - expect( - ThemeEncoder.encodeVisualDensity(VisualDensity.comfortable), - 'comfortable', - ); - expect( - ThemeEncoder.encodeVisualDensity(VisualDensity.compact), - 'compact', - ); - expect( - ThemeEncoder.encodeVisualDensity(VisualDensity.standard), - 'standard', - ); + for (var entry in states.entries) { + final stateKey = entry.key; + final state = entry.value; + + final side = TextStyle(fontSize: ++count); + sides[state] = side; + + final decoded = ThemeDecoder.decodeWidgetStatePropertyTextStyle(side); + + expect(decoded!.resolve({state}), side); + + final encoded = ThemeEncoder.encodeWidgetStatePropertyTextStyle(decoded); + + expect(encoded![stateKey]['fontSize'], side.fontSize); + } + + TextStyle? func(Set states) => + states.isEmpty ? null : sides[states.first]; + + final prop = WidgetStateProperty.resolveWith(func); + final decoded = ThemeDecoder.decodeWidgetStatePropertyTextStyle(prop); + for (var entry in states.entries) { + final side = sides[entry.value]; + + expect(decoded!.resolve({entry.value}), side); + + final encoded = ThemeEncoder.encodeWidgetStatePropertyTextStyle(decoded); + + expect(encoded![entry.key]['fontSize'], side!.fontSize); + } + + for (var entry in states.entries) { + final stateKey = entry.key; + final state = entry.value; + + final side = sides[state]; + final encodedSide = ThemeEncoder.encodeTextStyle(side); + + final decoded = ThemeDecoder.decodeWidgetStatePropertyTextStyle( + encodedSide, + ); + + expect(decoded!.resolve({state}), side); + + final encoded = ThemeEncoder.encodeWidgetStatePropertyTextStyle(decoded); + + expect(encoded![stateKey]['fontSize'], side!.fontSize); + } }); test('WrapAlignment', () { diff --git a/json_theme/test/src/model/json_material_state_property_test.dart b/json_theme/test/src/model/json_widget_state_property_test.dart similarity index 62% rename from json_theme/test/src/model/json_material_state_property_test.dart rename to json_theme/test/src/model/json_widget_state_property_test.dart index f939faa..98c6c7e 100644 --- a/json_theme/test/src/model/json_material_state_property_test.dart +++ b/json_theme/test/src/model/json_widget_state_property_test.dart @@ -1,13 +1,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:json_theme/src/model/json_material_state_property.dart'; +import 'package:json_theme/src/model/json_widget_state_property.dart'; -void main() => group('JsonMaterialStateProperty', () { +void main() => group('JsonWidgetStateProperty', () { group('with empty map input', () { - const emptyMap = JsonMaterialStateProperty({}); + const emptyMap = JsonWidgetStateProperty({}); test( 'should return null on resolve() call', - () => expect(emptyMap.resolve(MaterialState.values.toSet()), isNull), + () => expect(emptyMap.resolve(WidgetState.values.toSet()), isNull), ); test( @@ -23,11 +23,11 @@ void main() => group('JsonMaterialStateProperty', () { group('with non-empty map input', () { const map = { - MaterialState.disabled: true, - MaterialState.error: false, + WidgetState.disabled: true, + WidgetState.error: false, null: true }; - const property = JsonMaterialStateProperty(map); + const property = JsonWidgetStateProperty(map); test( 'should return null on empty (null) key in map', () => expect(property.resolve({}), isTrue), @@ -36,9 +36,9 @@ void main() => group('JsonMaterialStateProperty', () { 'should throw assertion error on resolve() call', () { expect( - property.resolve(MaterialState.values.toSet()), + property.resolve(WidgetState.values.toSet()), isNull, - reason: 'provides no value for ${MaterialState.values.first}', + reason: 'provides no value for ${WidgetState.values.first}', ); expect( property.resolve({map.keys.first!}), @@ -50,10 +50,10 @@ void main() => group('JsonMaterialStateProperty', () { ); test( - 'should return full JsonMaterialStateProperty object on toString()', + 'should return full JsonWidgetStateProperty object on toString()', () => expect( property.toString(), - '''JsonMaterialStateProperty({MaterialState.disabled: true, MaterialState.error: false, null: true,})''', + '''JsonWidgetStateProperty({WidgetState.disabled: true, WidgetState.error: false, null: true,})''', ), ); }); diff --git a/json_theme/test/src/model/map_material_state_property_test.dart b/json_theme/test/src/model/map_widget_state_property_test.dart similarity index 51% rename from json_theme/test/src/model/map_material_state_property_test.dart rename to json_theme/test/src/model/map_widget_state_property_test.dart index 0457d9b..6c57bc5 100644 --- a/json_theme/test/src/model/map_material_state_property_test.dart +++ b/json_theme/test/src/model/map_widget_state_property_test.dart @@ -1,15 +1,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:json_theme/src/model/json_material_state_property.dart'; -import 'package:json_theme/src/model/map_material_state_property.dart'; +import 'package:json_theme/src/model/json_widget_state_property.dart'; +import 'package:json_theme/src/model/map_widget_state_property.dart'; -void main() => group('MapMaterialStateProperty', () { +void main() => group('MapWidgetStateProperty', () { group('toString()', () { test( 'should return null on resolve() call', () { - final empty = MapMaterialStateProperty.resolveWith((_) => null); - expect(empty.resolve(MaterialState.values.toSet()), isNull); + final empty = MapWidgetStateProperty.resolveWith((_) => null); + expect(empty.resolve(WidgetState.values.toSet()), isNull); expect(empty.toString(), null.toString()); }, ); @@ -17,19 +17,19 @@ void main() => group('MapMaterialStateProperty', () { test( 'should not-return null on resolve() call', () { - const json = JsonMaterialStateProperty({ - MaterialState.focused: false, - MaterialState.disabled: true, + const json = JsonWidgetStateProperty({ + WidgetState.focused: false, + WidgetState.disabled: true, }); - final nonEmpty = MapMaterialStateProperty.resolveWith((s) { + final nonEmpty = MapWidgetStateProperty.resolveWith((s) { if (s.contains(json.map.keys.last)) return json.map.values.last; if (s.contains(json.map.keys.first)) return json.map.values.first; return null; }); expect(nonEmpty.toString(), json.toString()); - expect(nonEmpty.resolve({MaterialState.values.first}), isNull); + expect(nonEmpty.resolve({WidgetState.values.first}), isNull); expect( - nonEmpty.resolve(MaterialState.values.toSet()), + nonEmpty.resolve(WidgetState.values.toSet()), json.map.values.last, ); },