diff --git a/examples/stac_gallery/assets/json/container_example.json b/examples/stac_gallery/assets/json/container_example.json index 32391e0d..7750feed 100644 --- a/examples/stac_gallery/assets/json/container_example.json +++ b/examples/stac_gallery/assets/json/container_example.json @@ -9,7 +9,6 @@ }, "body": { "type": "listView", - "physics": "never", "shrinkWrap": true, "children": [ { @@ -17,30 +16,62 @@ "height": 52 }, { - "type": "container", - "color": "#672BFF", - "height": 250, - "width": 200 + "type": "center", + "child": { + "type": "container", + "color": "#672BFF", + "height": 250, + "width": "maxFinite" + } + }, + { + "type": "sizedBox", + "height": 52 + }, + { + "type": "center", + "child": { + "type": "container", + "color": "#FC5632", + "height": 100, + "width": "200", + "child": { + "type": "align", + "alignment": "bottomCenter", + "child": { + "type": "text", + "data": "Flutter", + "align": "center", + "style": { + "fontSize": 23, + "fontWeight": "w600" + } + } + } + } }, { "type": "sizedBox", "height": 52 }, { - "type": "container", - "color": "#FC5632", - "height": 250, - "width": 200, + "type": "center", "child": { - "type": "align", - "alignment": "bottomCenter", + "type": "container", + "color": "#FFFF00", + "height": 250, + "width": 250, "child": { - "type": "text", - "data": "Flutter", - "align": "center", - "style": { - "fontSize": 23, - "fontWeight": "w600" + "type": "align", + "alignment": "bottomCenter", + "child": { + "type": "text", + "data": "Flutter", + "align": "center", + "style": { + "fontSize": 23, + "fontWeight": "w600" + } } } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_alert_dialog/stac_alert_dialog.dart b/packages/stac/lib/src/parsers/widgets/stac_alert_dialog/stac_alert_dialog.dart index 6a1fc13b..449f90cb 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_alert_dialog/stac_alert_dialog.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_alert_dialog/stac_alert_dialog.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:stac/src/parsers/widgets/stac_alignment_geometry/stac_alignment_geometry.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; import 'package:stac/src/parsers/widgets/stac_shape_border/stac_shape_border.dart'; import 'package:stac/src/parsers/widgets/stac_text_style/stac_text_style.dart'; @@ -27,14 +28,18 @@ abstract class StacAlertDialog with _$StacAlertDialog { MainAxisAlignment? actionsAlignment, OverflowBarAlignment? actionsOverflowAlignment, VerticalDirection? actionsOverflowDirection, - double? actionsOverflowButtonSpacing, + StacDouble? actionsOverflowButtonSpacing, StacEdgeInsets? buttonPadding, String? backgroundColor, - double? elevation, + StacDouble? elevation, String? shadowColor, String? surfaceTintColor, String? semanticLabel, - @Default(StacEdgeInsets(left: 40, right: 40, top: 24, bottom: 24)) + @Default(StacEdgeInsets( + left: StacDouble(40), + right: StacDouble(40), + top: StacDouble(24), + bottom: StacDouble(24))) StacEdgeInsets insetPadding, @Default(Clip.none) Clip clipBehavior, StacShapeBorder? shape, diff --git a/packages/stac/lib/src/parsers/widgets/stac_alert_dialog/stac_alert_dialog.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_alert_dialog/stac_alert_dialog.freezed.dart index fdbf07f9..7691f8f6 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_alert_dialog/stac_alert_dialog.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_alert_dialog/stac_alert_dialog.freezed.dart @@ -29,10 +29,10 @@ mixin _$StacAlertDialog { MainAxisAlignment? get actionsAlignment; OverflowBarAlignment? get actionsOverflowAlignment; VerticalDirection? get actionsOverflowDirection; - double? get actionsOverflowButtonSpacing; + StacDouble? get actionsOverflowButtonSpacing; StacEdgeInsets? get buttonPadding; String? get backgroundColor; - double? get elevation; + StacDouble? get elevation; String? get shadowColor; String? get surfaceTintColor; String? get semanticLabel; @@ -170,10 +170,10 @@ abstract mixin class $StacAlertDialogCopyWith<$Res> { MainAxisAlignment? actionsAlignment, OverflowBarAlignment? actionsOverflowAlignment, VerticalDirection? actionsOverflowDirection, - double? actionsOverflowButtonSpacing, + StacDouble? actionsOverflowButtonSpacing, StacEdgeInsets? buttonPadding, String? backgroundColor, - double? elevation, + StacDouble? elevation, String? shadowColor, String? surfaceTintColor, String? semanticLabel, @@ -295,7 +295,7 @@ class _$StacAlertDialogCopyWithImpl<$Res> actionsOverflowButtonSpacing: freezed == actionsOverflowButtonSpacing ? _self.actionsOverflowButtonSpacing : actionsOverflowButtonSpacing // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, buttonPadding: freezed == buttonPadding ? _self.buttonPadding : buttonPadding // ignore: cast_nullable_to_non_nullable @@ -307,7 +307,7 @@ class _$StacAlertDialogCopyWithImpl<$Res> elevation: freezed == elevation ? _self.elevation : elevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, shadowColor: freezed == shadowColor ? _self.shadowColor : shadowColor // ignore: cast_nullable_to_non_nullable @@ -505,8 +505,11 @@ class _StacAlertDialog implements StacAlertDialog { this.shadowColor, this.surfaceTintColor, this.semanticLabel, - this.insetPadding = - const StacEdgeInsets(left: 40, right: 40, top: 24, bottom: 24), + this.insetPadding = const StacEdgeInsets( + left: StacDouble(40), + right: StacDouble(40), + top: StacDouble(24), + bottom: StacDouble(24)), this.clipBehavior = Clip.none, this.shape, this.alignment, @@ -579,13 +582,13 @@ class _StacAlertDialog implements StacAlertDialog { @override final VerticalDirection? actionsOverflowDirection; @override - final double? actionsOverflowButtonSpacing; + final StacDouble? actionsOverflowButtonSpacing; @override final StacEdgeInsets? buttonPadding; @override final String? backgroundColor; @override - final double? elevation; + final StacDouble? elevation; @override final String? shadowColor; @override @@ -740,10 +743,10 @@ abstract mixin class _$StacAlertDialogCopyWith<$Res> MainAxisAlignment? actionsAlignment, OverflowBarAlignment? actionsOverflowAlignment, VerticalDirection? actionsOverflowDirection, - double? actionsOverflowButtonSpacing, + StacDouble? actionsOverflowButtonSpacing, StacEdgeInsets? buttonPadding, String? backgroundColor, - double? elevation, + StacDouble? elevation, String? shadowColor, String? surfaceTintColor, String? semanticLabel, @@ -875,7 +878,7 @@ class __$StacAlertDialogCopyWithImpl<$Res> actionsOverflowButtonSpacing: freezed == actionsOverflowButtonSpacing ? _self.actionsOverflowButtonSpacing : actionsOverflowButtonSpacing // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, buttonPadding: freezed == buttonPadding ? _self.buttonPadding : buttonPadding // ignore: cast_nullable_to_non_nullable @@ -887,7 +890,7 @@ class __$StacAlertDialogCopyWithImpl<$Res> elevation: freezed == elevation ? _self.elevation : elevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, shadowColor: freezed == shadowColor ? _self.shadowColor : shadowColor // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_alert_dialog/stac_alert_dialog.g.dart b/packages/stac/lib/src/parsers/widgets/stac_alert_dialog/stac_alert_dialog.g.dart index 9d2d8808..6f41d3f2 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_alert_dialog/stac_alert_dialog.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_alert_dialog/stac_alert_dialog.g.dart @@ -39,18 +39,25 @@ _StacAlertDialog _$StacAlertDialogFromJson(Map json) => _$OverflowBarAlignmentEnumMap, json['actionsOverflowAlignment']), actionsOverflowDirection: $enumDecodeNullable( _$VerticalDirectionEnumMap, json['actionsOverflowDirection']), - actionsOverflowButtonSpacing: - (json['actionsOverflowButtonSpacing'] as num?)?.toDouble(), + actionsOverflowButtonSpacing: json['actionsOverflowButtonSpacing'] == null + ? null + : StacDouble.fromJson(json['actionsOverflowButtonSpacing']), buttonPadding: json['buttonPadding'] == null ? null : StacEdgeInsets.fromJson(json['buttonPadding']), backgroundColor: json['backgroundColor'] as String?, - elevation: (json['elevation'] as num?)?.toDouble(), + elevation: json['elevation'] == null + ? null + : StacDouble.fromJson(json['elevation']), shadowColor: json['shadowColor'] as String?, surfaceTintColor: json['surfaceTintColor'] as String?, semanticLabel: json['semanticLabel'] as String?, insetPadding: json['insetPadding'] == null - ? const StacEdgeInsets(left: 40, right: 40, top: 24, bottom: 24) + ? const StacEdgeInsets( + left: StacDouble(40), + right: StacDouble(40), + top: StacDouble(24), + bottom: StacDouble(24)) : StacEdgeInsets.fromJson(json['insetPadding']), clipBehavior: $enumDecodeNullable(_$ClipEnumMap, json['clipBehavior']) ?? Clip.none, diff --git a/packages/stac/lib/src/parsers/widgets/stac_alert_dialog/stac_alert_dialog_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_alert_dialog/stac_alert_dialog_parser.dart index 5f015ea2..3714375d 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_alert_dialog/stac_alert_dialog_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_alert_dialog/stac_alert_dialog_parser.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; import 'package:stac/src/parsers/widgets/stac_alert_dialog/stac_alert_dialog.dart'; import 'package:stac/src/parsers/widgets/stac_alignment_geometry/stac_alignment_geometry.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; import 'package:stac/src/parsers/widgets/stac_shape_border/stac_shape_border.dart'; import 'package:stac/src/parsers/widgets/stac_text_style/stac_text_style.dart'; @@ -38,10 +39,10 @@ class StacAlertDialogParser extends StacParser { actionsAlignment: model.actionsAlignment, actionsOverflowAlignment: model.actionsOverflowAlignment, actionsOverflowDirection: model.actionsOverflowDirection, - actionsOverflowButtonSpacing: model.actionsOverflowButtonSpacing, + actionsOverflowButtonSpacing: model.actionsOverflowButtonSpacing?.parse, buttonPadding: model.buttonPadding.parse, backgroundColor: model.backgroundColor.toColor(context), - elevation: model.elevation, + elevation: model.elevation?.parse, shadowColor: model.shadowColor.toColor(context), surfaceTintColor: model.surfaceTintColor.toColor(context), semanticLabel: model.semanticLabel, diff --git a/packages/stac/lib/src/parsers/widgets/stac_align/stac_align.dart b/packages/stac/lib/src/parsers/widgets/stac_align/stac_align.dart index e679a17a..1eb16313 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_align/stac_align.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_align/stac_align.dart @@ -1,5 +1,6 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:stac/src/parsers/widgets/stac_alignment_directional/stac_alignment_directional.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; export 'stac_align_parser.dart'; @@ -11,8 +12,8 @@ abstract class StacAlign with _$StacAlign { const factory StacAlign({ @Default(StacAlignmentDirectional.center) StacAlignmentDirectional alignment, - double? widthFactor, - double? heightFactor, + StacDouble? widthFactor, + StacDouble? heightFactor, Map? child, }) = _StacAlign; diff --git a/packages/stac/lib/src/parsers/widgets/stac_align/stac_align.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_align/stac_align.freezed.dart index 1a6f1e9a..fc3390c2 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_align/stac_align.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_align/stac_align.freezed.dart @@ -16,8 +16,8 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacAlign { StacAlignmentDirectional get alignment; - double? get widthFactor; - double? get heightFactor; + StacDouble? get widthFactor; + StacDouble? get heightFactor; Map? get child; /// Create a copy of StacAlign @@ -62,8 +62,8 @@ abstract mixin class $StacAlignCopyWith<$Res> { @useResult $Res call( {StacAlignmentDirectional alignment, - double? widthFactor, - double? heightFactor, + StacDouble? widthFactor, + StacDouble? heightFactor, Map? child}); } @@ -92,11 +92,11 @@ class _$StacAlignCopyWithImpl<$Res> implements $StacAlignCopyWith<$Res> { widthFactor: freezed == widthFactor ? _self.widthFactor : widthFactor // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, heightFactor: freezed == heightFactor ? _self.heightFactor : heightFactor // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, child: freezed == child ? _self.child : child // ignore: cast_nullable_to_non_nullable @@ -121,9 +121,9 @@ class _StacAlign implements StacAlign { @JsonKey() final StacAlignmentDirectional alignment; @override - final double? widthFactor; + final StacDouble? widthFactor; @override - final double? heightFactor; + final StacDouble? heightFactor; final Map? _child; @override Map? get child { @@ -184,8 +184,8 @@ abstract mixin class _$StacAlignCopyWith<$Res> @useResult $Res call( {StacAlignmentDirectional alignment, - double? widthFactor, - double? heightFactor, + StacDouble? widthFactor, + StacDouble? heightFactor, Map? child}); } @@ -214,11 +214,11 @@ class __$StacAlignCopyWithImpl<$Res> implements _$StacAlignCopyWith<$Res> { widthFactor: freezed == widthFactor ? _self.widthFactor : widthFactor // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, heightFactor: freezed == heightFactor ? _self.heightFactor : heightFactor // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, child: freezed == child ? _self._child : child // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_align/stac_align.g.dart b/packages/stac/lib/src/parsers/widgets/stac_align/stac_align.g.dart index 32848373..53baa5ee 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_align/stac_align.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_align/stac_align.g.dart @@ -10,8 +10,12 @@ _StacAlign _$StacAlignFromJson(Map json) => _StacAlign( alignment: $enumDecodeNullable( _$StacAlignmentDirectionalEnumMap, json['alignment']) ?? StacAlignmentDirectional.center, - widthFactor: (json['widthFactor'] as num?)?.toDouble(), - heightFactor: (json['heightFactor'] as num?)?.toDouble(), + widthFactor: json['widthFactor'] == null + ? null + : StacDouble.fromJson(json['widthFactor']), + heightFactor: json['heightFactor'] == null + ? null + : StacDouble.fromJson(json['heightFactor']), child: json['child'] as Map?, ); diff --git a/packages/stac/lib/src/parsers/widgets/stac_align/stac_align_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_align/stac_align_parser.dart index db496131..71e4de92 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_align/stac_align_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_align/stac_align_parser.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; import 'package:stac/src/parsers/widgets/stac_align/stac_align.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; @@ -18,8 +19,8 @@ class StacAlignParser extends StacParser { Widget parse(BuildContext context, StacAlign model) { return Align( alignment: model.alignment.value, - heightFactor: model.heightFactor, - widthFactor: model.widthFactor, + heightFactor: model.heightFactor?.parse, + widthFactor: model.widthFactor?.parse, child: Stac.fromJson(model.child, context), ); } diff --git a/packages/stac/lib/src/parsers/widgets/stac_alignment_geometry/stac_alignment_geometry.dart b/packages/stac/lib/src/parsers/widgets/stac_alignment_geometry/stac_alignment_geometry.dart index 3c440e70..f885cb7d 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_alignment_geometry/stac_alignment_geometry.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_alignment_geometry/stac_alignment_geometry.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; part 'stac_alignment_geometry.freezed.dart'; part 'stac_alignment_geometry.g.dart'; @@ -7,8 +8,8 @@ part 'stac_alignment_geometry.g.dart'; @freezed abstract class StacAlignmentGeometry with _$StacAlignmentGeometry { const factory StacAlignmentGeometry({ - required double dx, - required double dy, + required StacDouble dx, + required StacDouble dy, }) = _StacAlignmentGeometry; factory StacAlignmentGeometry.fromJson(Map json) => @@ -17,6 +18,6 @@ abstract class StacAlignmentGeometry with _$StacAlignmentGeometry { extension StacOffsetParser on StacAlignmentGeometry { Alignment get parse { - return Alignment(dx, dy); + return Alignment(dx.parse, dy.parse); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_alignment_geometry/stac_alignment_geometry.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_alignment_geometry/stac_alignment_geometry.freezed.dart index d83856ea..66309f81 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_alignment_geometry/stac_alignment_geometry.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_alignment_geometry/stac_alignment_geometry.freezed.dart @@ -15,8 +15,8 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacAlignmentGeometry { - double get dx; - double get dy; + StacDouble get dx; + StacDouble get dy; /// Create a copy of StacAlignmentGeometry /// with the given fields replaced by the non-null parameter values. @@ -54,7 +54,7 @@ abstract mixin class $StacAlignmentGeometryCopyWith<$Res> { $Res Function(StacAlignmentGeometry) _then) = _$StacAlignmentGeometryCopyWithImpl; @useResult - $Res call({double dx, double dy}); + $Res call({StacDouble dx, StacDouble dy}); } /// @nodoc @@ -77,11 +77,11 @@ class _$StacAlignmentGeometryCopyWithImpl<$Res> dx: null == dx ? _self.dx : dx // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, dy: null == dy ? _self.dy : dy // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, )); } } @@ -94,9 +94,9 @@ class _StacAlignmentGeometry implements StacAlignmentGeometry { _$StacAlignmentGeometryFromJson(json); @override - final double dx; + final StacDouble dx; @override - final double dy; + final StacDouble dy; /// Create a copy of StacAlignmentGeometry /// with the given fields replaced by the non-null parameter values. @@ -141,7 +141,7 @@ abstract mixin class _$StacAlignmentGeometryCopyWith<$Res> __$StacAlignmentGeometryCopyWithImpl; @override @useResult - $Res call({double dx, double dy}); + $Res call({StacDouble dx, StacDouble dy}); } /// @nodoc @@ -164,11 +164,11 @@ class __$StacAlignmentGeometryCopyWithImpl<$Res> dx: null == dx ? _self.dx : dx // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, dy: null == dy ? _self.dy : dy // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, )); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_alignment_geometry/stac_alignment_geometry.g.dart b/packages/stac/lib/src/parsers/widgets/stac_alignment_geometry/stac_alignment_geometry.g.dart index bb0e0157..a3a9abc0 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_alignment_geometry/stac_alignment_geometry.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_alignment_geometry/stac_alignment_geometry.g.dart @@ -9,8 +9,8 @@ part of 'stac_alignment_geometry.dart'; _StacAlignmentGeometry _$StacAlignmentGeometryFromJson( Map json) => _StacAlignmentGeometry( - dx: (json['dx'] as num).toDouble(), - dy: (json['dy'] as num).toDouble(), + dx: StacDouble.fromJson(json['dx']), + dy: StacDouble.fromJson(json['dy']), ); Map _$StacAlignmentGeometryToJson( diff --git a/packages/stac/lib/src/parsers/widgets/stac_app_bar/stac_app_bar.dart b/packages/stac/lib/src/parsers/widgets/stac_app_bar/stac_app_bar.dart index b237bff3..8be6ad45 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_app_bar/stac_app_bar.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_app_bar/stac_app_bar.dart @@ -1,4 +1,5 @@ import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_text_style/stac_text_style.dart'; export 'stac_app_bar_parser.dart'; @@ -19,15 +20,15 @@ abstract class StacAppBar with _$StacAppBar { String? surfaceTintColor, @Default([]) List> actions, Map? bottom, - double? titleSpacing, - @Default(1.0) double toolbarOpacity, - @Default(1.0) double bottomOpacity, - double? toolbarHeight, - double? leadingWidth, + StacDouble? titleSpacing, + @Default(StacDouble(1.0)) StacDouble toolbarOpacity, + @Default(StacDouble(1.0)) StacDouble bottomOpacity, + StacDouble? toolbarHeight, + StacDouble? leadingWidth, @Default(true) bool primary, bool? centerTitle, - double? elevation, - double? scrolledUnderElevation, + StacDouble? elevation, + StacDouble? scrolledUnderElevation, }) = _StacAppBar; factory StacAppBar.fromJson(Map json) => diff --git a/packages/stac/lib/src/parsers/widgets/stac_app_bar/stac_app_bar.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_app_bar/stac_app_bar.freezed.dart index 9e7c99b7..d8bf518f 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_app_bar/stac_app_bar.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_app_bar/stac_app_bar.freezed.dart @@ -25,15 +25,15 @@ mixin _$StacAppBar { String? get surfaceTintColor; List> get actions; Map? get bottom; - double? get titleSpacing; - double get toolbarOpacity; - double get bottomOpacity; - double? get toolbarHeight; - double? get leadingWidth; + StacDouble? get titleSpacing; + StacDouble get toolbarOpacity; + StacDouble get bottomOpacity; + StacDouble? get toolbarHeight; + StacDouble? get leadingWidth; bool get primary; bool? get centerTitle; - double? get elevation; - double? get scrolledUnderElevation; + StacDouble? get elevation; + StacDouble? get scrolledUnderElevation; /// Create a copy of StacAppBar /// with the given fields replaced by the non-null parameter values. @@ -133,15 +133,15 @@ abstract mixin class $StacAppBarCopyWith<$Res> { String? surfaceTintColor, List> actions, Map? bottom, - double? titleSpacing, - double toolbarOpacity, - double bottomOpacity, - double? toolbarHeight, - double? leadingWidth, + StacDouble? titleSpacing, + StacDouble toolbarOpacity, + StacDouble bottomOpacity, + StacDouble? toolbarHeight, + StacDouble? leadingWidth, bool primary, bool? centerTitle, - double? elevation, - double? scrolledUnderElevation}); + StacDouble? elevation, + StacDouble? scrolledUnderElevation}); $StacTextStyleCopyWith<$Res>? get titleTextStyle; $StacTextStyleCopyWith<$Res>? get toolbarTextStyle; @@ -223,23 +223,23 @@ class _$StacAppBarCopyWithImpl<$Res> implements $StacAppBarCopyWith<$Res> { titleSpacing: freezed == titleSpacing ? _self.titleSpacing : titleSpacing // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, toolbarOpacity: null == toolbarOpacity ? _self.toolbarOpacity : toolbarOpacity // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, bottomOpacity: null == bottomOpacity ? _self.bottomOpacity : bottomOpacity // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, toolbarHeight: freezed == toolbarHeight ? _self.toolbarHeight : toolbarHeight // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, leadingWidth: freezed == leadingWidth ? _self.leadingWidth : leadingWidth // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, primary: null == primary ? _self.primary : primary // ignore: cast_nullable_to_non_nullable @@ -251,11 +251,11 @@ class _$StacAppBarCopyWithImpl<$Res> implements $StacAppBarCopyWith<$Res> { elevation: freezed == elevation ? _self.elevation : elevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, scrolledUnderElevation: freezed == scrolledUnderElevation ? _self.scrolledUnderElevation : scrolledUnderElevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, )); } @@ -303,8 +303,8 @@ class _StacAppBar implements StacAppBar { final List> actions = const [], final Map? bottom, this.titleSpacing, - this.toolbarOpacity = 1.0, - this.bottomOpacity = 1.0, + this.toolbarOpacity = const StacDouble(1.0), + this.bottomOpacity = const StacDouble(1.0), this.toolbarHeight, this.leadingWidth, this.primary = true, @@ -370,26 +370,26 @@ class _StacAppBar implements StacAppBar { } @override - final double? titleSpacing; + final StacDouble? titleSpacing; @override @JsonKey() - final double toolbarOpacity; + final StacDouble toolbarOpacity; @override @JsonKey() - final double bottomOpacity; + final StacDouble bottomOpacity; @override - final double? toolbarHeight; + final StacDouble? toolbarHeight; @override - final double? leadingWidth; + final StacDouble? leadingWidth; @override @JsonKey() final bool primary; @override final bool? centerTitle; @override - final double? elevation; + final StacDouble? elevation; @override - final double? scrolledUnderElevation; + final StacDouble? scrolledUnderElevation; /// Create a copy of StacAppBar /// with the given fields replaced by the non-null parameter values. @@ -496,15 +496,15 @@ abstract mixin class _$StacAppBarCopyWith<$Res> String? surfaceTintColor, List> actions, Map? bottom, - double? titleSpacing, - double toolbarOpacity, - double bottomOpacity, - double? toolbarHeight, - double? leadingWidth, + StacDouble? titleSpacing, + StacDouble toolbarOpacity, + StacDouble bottomOpacity, + StacDouble? toolbarHeight, + StacDouble? leadingWidth, bool primary, bool? centerTitle, - double? elevation, - double? scrolledUnderElevation}); + StacDouble? elevation, + StacDouble? scrolledUnderElevation}); @override $StacTextStyleCopyWith<$Res>? get titleTextStyle; @@ -588,23 +588,23 @@ class __$StacAppBarCopyWithImpl<$Res> implements _$StacAppBarCopyWith<$Res> { titleSpacing: freezed == titleSpacing ? _self.titleSpacing : titleSpacing // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, toolbarOpacity: null == toolbarOpacity ? _self.toolbarOpacity : toolbarOpacity // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, bottomOpacity: null == bottomOpacity ? _self.bottomOpacity : bottomOpacity // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, toolbarHeight: freezed == toolbarHeight ? _self.toolbarHeight : toolbarHeight // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, leadingWidth: freezed == leadingWidth ? _self.leadingWidth : leadingWidth // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, primary: null == primary ? _self.primary : primary // ignore: cast_nullable_to_non_nullable @@ -616,11 +616,11 @@ class __$StacAppBarCopyWithImpl<$Res> implements _$StacAppBarCopyWith<$Res> { elevation: freezed == elevation ? _self.elevation : elevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, scrolledUnderElevation: freezed == scrolledUnderElevation ? _self.scrolledUnderElevation : scrolledUnderElevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, )); } diff --git a/packages/stac/lib/src/parsers/widgets/stac_app_bar/stac_app_bar.g.dart b/packages/stac/lib/src/parsers/widgets/stac_app_bar/stac_app_bar.g.dart index 2b0d9709..b6f1a2f5 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_app_bar/stac_app_bar.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_app_bar/stac_app_bar.g.dart @@ -24,16 +24,29 @@ _StacAppBar _$StacAppBarFromJson(Map json) => _StacAppBar( .toList() ?? const [], bottom: json['bottom'] as Map?, - titleSpacing: (json['titleSpacing'] as num?)?.toDouble(), - toolbarOpacity: (json['toolbarOpacity'] as num?)?.toDouble() ?? 1.0, - bottomOpacity: (json['bottomOpacity'] as num?)?.toDouble() ?? 1.0, - toolbarHeight: (json['toolbarHeight'] as num?)?.toDouble(), - leadingWidth: (json['leadingWidth'] as num?)?.toDouble(), + titleSpacing: json['titleSpacing'] == null + ? null + : StacDouble.fromJson(json['titleSpacing']), + toolbarOpacity: json['toolbarOpacity'] == null + ? const StacDouble(1.0) + : StacDouble.fromJson(json['toolbarOpacity']), + bottomOpacity: json['bottomOpacity'] == null + ? const StacDouble(1.0) + : StacDouble.fromJson(json['bottomOpacity']), + toolbarHeight: json['toolbarHeight'] == null + ? null + : StacDouble.fromJson(json['toolbarHeight']), + leadingWidth: json['leadingWidth'] == null + ? null + : StacDouble.fromJson(json['leadingWidth']), primary: json['primary'] as bool? ?? true, centerTitle: json['centerTitle'] as bool?, - elevation: (json['elevation'] as num?)?.toDouble(), - scrolledUnderElevation: - (json['scrolledUnderElevation'] as num?)?.toDouble(), + elevation: json['elevation'] == null + ? null + : StacDouble.fromJson(json['elevation']), + scrolledUnderElevation: json['scrolledUnderElevation'] == null + ? null + : StacDouble.fromJson(json['scrolledUnderElevation']), ); Map _$StacAppBarToJson(_StacAppBar instance) => diff --git a/packages/stac/lib/src/parsers/widgets/stac_app_bar/stac_app_bar_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_app_bar/stac_app_bar_parser.dart index 05c6436e..24ba4b52 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_app_bar/stac_app_bar_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_app_bar/stac_app_bar_parser.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; import 'package:stac/src/parsers/widgets/stac_app_bar/stac_app_bar.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_text_style/stac_text_style.dart'; import 'package:stac/src/utils/color_utils.dart'; import 'package:stac/src/utils/widget_type.dart'; @@ -30,15 +31,15 @@ class StacAppBarParser extends StacParser { .map((action) => Stac.fromJson(action, context) ?? const SizedBox()) .toList(), bottom: Stac.fromJson(model.bottom, context).toPreferredSizeWidget, - titleSpacing: model.titleSpacing, - toolbarOpacity: model.toolbarOpacity, - bottomOpacity: model.bottomOpacity, - toolbarHeight: model.toolbarHeight, - leadingWidth: model.leadingWidth, + titleSpacing: model.titleSpacing?.parse, + toolbarOpacity: model.toolbarOpacity.parse, + bottomOpacity: model.bottomOpacity.parse, + toolbarHeight: model.toolbarHeight?.parse, + leadingWidth: model.leadingWidth?.parse, primary: model.primary, centerTitle: model.centerTitle, - elevation: model.elevation, - scrolledUnderElevation: model.scrolledUnderElevation, + elevation: model.elevation?.parse, + scrolledUnderElevation: model.scrolledUnderElevation?.parse, ); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_aspect_ratio/stac_aspect_ratio.dart b/packages/stac/lib/src/parsers/widgets/stac_aspect_ratio/stac_aspect_ratio.dart index 6caae5de..f9357af8 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_aspect_ratio/stac_aspect_ratio.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_aspect_ratio/stac_aspect_ratio.dart @@ -1,4 +1,5 @@ import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; export 'stac_aspect_ratio_parser.dart'; @@ -8,7 +9,7 @@ part 'stac_aspect_ratio.g.dart'; @freezed abstract class StacAspectRatio with _$StacAspectRatio { const factory StacAspectRatio({ - @Default(1) double aspectRatio, + @Default(StacDouble(1)) StacDouble aspectRatio, Map? child, }) = _StacAspectRatio; diff --git a/packages/stac/lib/src/parsers/widgets/stac_aspect_ratio/stac_aspect_ratio.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_aspect_ratio/stac_aspect_ratio.freezed.dart index 72a5d959..7662829b 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_aspect_ratio/stac_aspect_ratio.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_aspect_ratio/stac_aspect_ratio.freezed.dart @@ -15,7 +15,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacAspectRatio { - double get aspectRatio; + StacDouble get aspectRatio; Map? get child; /// Create a copy of StacAspectRatio @@ -56,7 +56,7 @@ abstract mixin class $StacAspectRatioCopyWith<$Res> { StacAspectRatio value, $Res Function(StacAspectRatio) _then) = _$StacAspectRatioCopyWithImpl; @useResult - $Res call({double aspectRatio, Map? child}); + $Res call({StacDouble aspectRatio, Map? child}); } /// @nodoc @@ -79,7 +79,7 @@ class _$StacAspectRatioCopyWithImpl<$Res> aspectRatio: null == aspectRatio ? _self.aspectRatio : aspectRatio // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, child: freezed == child ? _self.child : child // ignore: cast_nullable_to_non_nullable @@ -92,14 +92,15 @@ class _$StacAspectRatioCopyWithImpl<$Res> @JsonSerializable() class _StacAspectRatio implements StacAspectRatio { const _StacAspectRatio( - {this.aspectRatio = 1, final Map? child}) + {this.aspectRatio = const StacDouble(1), + final Map? child}) : _child = child; factory _StacAspectRatio.fromJson(Map json) => _$StacAspectRatioFromJson(json); @override @JsonKey() - final double aspectRatio; + final StacDouble aspectRatio; final Map? _child; @override Map? get child { @@ -154,7 +155,7 @@ abstract mixin class _$StacAspectRatioCopyWith<$Res> __$StacAspectRatioCopyWithImpl; @override @useResult - $Res call({double aspectRatio, Map? child}); + $Res call({StacDouble aspectRatio, Map? child}); } /// @nodoc @@ -177,7 +178,7 @@ class __$StacAspectRatioCopyWithImpl<$Res> aspectRatio: null == aspectRatio ? _self.aspectRatio : aspectRatio // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, child: freezed == child ? _self._child : child // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_aspect_ratio/stac_aspect_ratio.g.dart b/packages/stac/lib/src/parsers/widgets/stac_aspect_ratio/stac_aspect_ratio.g.dart index cb736d09..f661ca15 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_aspect_ratio/stac_aspect_ratio.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_aspect_ratio/stac_aspect_ratio.g.dart @@ -8,7 +8,9 @@ part of 'stac_aspect_ratio.dart'; _StacAspectRatio _$StacAspectRatioFromJson(Map json) => _StacAspectRatio( - aspectRatio: (json['aspectRatio'] as num?)?.toDouble() ?? 1, + aspectRatio: json['aspectRatio'] == null + ? const StacDouble(1) + : StacDouble.fromJson(json['aspectRatio']), child: json['child'] as Map?, ); diff --git a/packages/stac/lib/src/parsers/widgets/stac_aspect_ratio/stac_aspect_ratio_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_aspect_ratio/stac_aspect_ratio_parser.dart index 23c51f18..3efbec20 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_aspect_ratio/stac_aspect_ratio_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_aspect_ratio/stac_aspect_ratio_parser.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; import 'package:stac/src/parsers/widgets/stac_aspect_ratio/stac_aspect_ratio.dart'; - +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; @@ -18,7 +18,7 @@ class StacAspectRatioParser extends StacParser { @override Widget parse(BuildContext context, StacAspectRatio model) { return AspectRatio( - aspectRatio: model.aspectRatio, + aspectRatio: model.aspectRatio.parse, child: Stac.fromJson(model.child, context), ); } diff --git a/packages/stac/lib/src/parsers/widgets/stac_auto_complete/stac_auto_complete.dart b/packages/stac/lib/src/parsers/widgets/stac_auto_complete/stac_auto_complete.dart index 2115d3a4..8017062e 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_auto_complete/stac_auto_complete.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_auto_complete/stac_auto_complete.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; export 'stac_auto_complete_parser.dart'; @@ -11,7 +12,7 @@ abstract class StacAutoComplete with _$StacAutoComplete { const factory StacAutoComplete({ required List options, Map? onSelected, - @Default(200) double optionsMaxHeight, + @Default(StacDouble(200)) StacDouble optionsMaxHeight, @Default(OptionsViewOpenDirection.down) OptionsViewOpenDirection optionsViewOpenDirection, String? initialValue, diff --git a/packages/stac/lib/src/parsers/widgets/stac_auto_complete/stac_auto_complete.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_auto_complete/stac_auto_complete.freezed.dart index 01696564..fb940194 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_auto_complete/stac_auto_complete.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_auto_complete/stac_auto_complete.freezed.dart @@ -17,7 +17,7 @@ T _$identity(T value) => value; mixin _$StacAutoComplete { List get options; Map? get onSelected; - double get optionsMaxHeight; + StacDouble get optionsMaxHeight; OptionsViewOpenDirection get optionsViewOpenDirection; String? get initialValue; @@ -74,7 +74,7 @@ abstract mixin class $StacAutoCompleteCopyWith<$Res> { $Res call( {List options, Map? onSelected, - double optionsMaxHeight, + StacDouble optionsMaxHeight, OptionsViewOpenDirection optionsViewOpenDirection, String? initialValue}); } @@ -110,7 +110,7 @@ class _$StacAutoCompleteCopyWithImpl<$Res> optionsMaxHeight: null == optionsMaxHeight ? _self.optionsMaxHeight : optionsMaxHeight // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, optionsViewOpenDirection: null == optionsViewOpenDirection ? _self.optionsViewOpenDirection : optionsViewOpenDirection // ignore: cast_nullable_to_non_nullable @@ -129,7 +129,7 @@ class _StacAutoComplete implements StacAutoComplete { const _StacAutoComplete( {required final List options, final Map? onSelected, - this.optionsMaxHeight = 200, + this.optionsMaxHeight = const StacDouble(200), this.optionsViewOpenDirection = OptionsViewOpenDirection.down, this.initialValue}) : _options = options, @@ -157,7 +157,7 @@ class _StacAutoComplete implements StacAutoComplete { @override @JsonKey() - final double optionsMaxHeight; + final StacDouble optionsMaxHeight; @override @JsonKey() final OptionsViewOpenDirection optionsViewOpenDirection; @@ -223,7 +223,7 @@ abstract mixin class _$StacAutoCompleteCopyWith<$Res> $Res call( {List options, Map? onSelected, - double optionsMaxHeight, + StacDouble optionsMaxHeight, OptionsViewOpenDirection optionsViewOpenDirection, String? initialValue}); } @@ -259,7 +259,7 @@ class __$StacAutoCompleteCopyWithImpl<$Res> optionsMaxHeight: null == optionsMaxHeight ? _self.optionsMaxHeight : optionsMaxHeight // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, optionsViewOpenDirection: null == optionsViewOpenDirection ? _self.optionsViewOpenDirection : optionsViewOpenDirection // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_auto_complete/stac_auto_complete.g.dart b/packages/stac/lib/src/parsers/widgets/stac_auto_complete/stac_auto_complete.g.dart index d342049c..e1ef4f27 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_auto_complete/stac_auto_complete.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_auto_complete/stac_auto_complete.g.dart @@ -11,7 +11,9 @@ _StacAutoComplete _$StacAutoCompleteFromJson(Map json) => options: (json['options'] as List).map((e) => e as String).toList(), onSelected: json['onSelected'] as Map?, - optionsMaxHeight: (json['optionsMaxHeight'] as num?)?.toDouble() ?? 200, + optionsMaxHeight: json['optionsMaxHeight'] == null + ? const StacDouble(200) + : StacDouble.fromJson(json['optionsMaxHeight']), optionsViewOpenDirection: $enumDecodeNullable( _$OptionsViewOpenDirectionEnumMap, json['optionsViewOpenDirection']) ?? diff --git a/packages/stac/lib/src/parsers/widgets/stac_auto_complete/stac_auto_complete_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_auto_complete/stac_auto_complete_parser.dart index 1f9adafe..b040b874 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_auto_complete/stac_auto_complete_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_auto_complete/stac_auto_complete_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'stac_auto_complete.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; @@ -27,7 +28,7 @@ class StacAutoCompleteParser extends StacParser { }, onSelected: (String val) => Stac.onCallFromJson(model.onSelected, context), - optionsMaxHeight: model.optionsMaxHeight, + optionsMaxHeight: model.optionsMaxHeight.parse, optionsViewOpenDirection: model.optionsViewOpenDirection, initialValue: model.initialValue != null ? TextEditingValue(text: model.initialValue!) diff --git a/packages/stac/lib/src/parsers/widgets/stac_border/stac_border.dart b/packages/stac/lib/src/parsers/widgets/stac_border/stac_border.dart index c0748ad3..6c10b297 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_border/stac_border.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_border/stac_border.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/color_utils.dart'; part 'stac_border.freezed.dart'; @@ -10,8 +11,8 @@ abstract class StacBorder with _$StacBorder { const factory StacBorder({ String? color, @Default(BorderStyle.solid) BorderStyle borderStyle, - @Default(1.0) double width, - @Default(BorderSide.strokeAlignInside) double strokeAlign, + @Default(StacDouble(1.0)) StacDouble width, + @Default(StacDouble(BorderSide.strokeAlignInside)) StacDouble strokeAlign, }) = _StacBorder; factory StacBorder.fromJson(Map json) => @@ -22,9 +23,9 @@ extension StacBorderParser on StacBorder { Border parse(BuildContext context) { return Border.all( color: color.toColor(context) ?? const Color(0xFF000000), - width: width, + width: width.parse, style: borderStyle, - strokeAlign: strokeAlign, + strokeAlign: strokeAlign.parse, ); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_border/stac_border.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_border/stac_border.freezed.dart index ecd1636d..d871d966 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_border/stac_border.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_border/stac_border.freezed.dart @@ -17,8 +17,8 @@ T _$identity(T value) => value; mixin _$StacBorder { String? get color; BorderStyle get borderStyle; - double get width; - double get strokeAlign; + StacDouble get width; + StacDouble get strokeAlign; /// Create a copy of StacBorder /// with the given fields replaced by the non-null parameter values. @@ -63,8 +63,8 @@ abstract mixin class $StacBorderCopyWith<$Res> { $Res call( {String? color, BorderStyle borderStyle, - double width, - double strokeAlign}); + StacDouble width, + StacDouble strokeAlign}); } /// @nodoc @@ -96,11 +96,11 @@ class _$StacBorderCopyWithImpl<$Res> implements $StacBorderCopyWith<$Res> { width: null == width ? _self.width : width // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, strokeAlign: null == strokeAlign ? _self.strokeAlign : strokeAlign // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, )); } } @@ -111,8 +111,8 @@ class _StacBorder implements StacBorder { const _StacBorder( {this.color, this.borderStyle = BorderStyle.solid, - this.width = 1.0, - this.strokeAlign = BorderSide.strokeAlignInside}); + this.width = const StacDouble(1.0), + this.strokeAlign = const StacDouble(BorderSide.strokeAlignInside)}); factory _StacBorder.fromJson(Map json) => _$StacBorderFromJson(json); @@ -123,10 +123,10 @@ class _StacBorder implements StacBorder { final BorderStyle borderStyle; @override @JsonKey() - final double width; + final StacDouble width; @override @JsonKey() - final double strokeAlign; + final StacDouble strokeAlign; /// Create a copy of StacBorder /// with the given fields replaced by the non-null parameter values. @@ -178,8 +178,8 @@ abstract mixin class _$StacBorderCopyWith<$Res> $Res call( {String? color, BorderStyle borderStyle, - double width, - double strokeAlign}); + StacDouble width, + StacDouble strokeAlign}); } /// @nodoc @@ -211,11 +211,11 @@ class __$StacBorderCopyWithImpl<$Res> implements _$StacBorderCopyWith<$Res> { width: null == width ? _self.width : width // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, strokeAlign: null == strokeAlign ? _self.strokeAlign : strokeAlign // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, )); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_border/stac_border.g.dart b/packages/stac/lib/src/parsers/widgets/stac_border/stac_border.g.dart index 1fd19e3f..9dc564c9 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_border/stac_border.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_border/stac_border.g.dart @@ -11,9 +11,12 @@ _StacBorder _$StacBorderFromJson(Map json) => _StacBorder( borderStyle: $enumDecodeNullable(_$BorderStyleEnumMap, json['borderStyle']) ?? BorderStyle.solid, - width: (json['width'] as num?)?.toDouble() ?? 1.0, - strokeAlign: (json['strokeAlign'] as num?)?.toDouble() ?? - BorderSide.strokeAlignInside, + width: json['width'] == null + ? const StacDouble(1.0) + : StacDouble.fromJson(json['width']), + strokeAlign: json['strokeAlign'] == null + ? const StacDouble(BorderSide.strokeAlignInside) + : StacDouble.fromJson(json['strokeAlign']), ); Map _$StacBorderToJson(_StacBorder instance) => diff --git a/packages/stac/lib/src/parsers/widgets/stac_border_radius/stac_border_radius.dart b/packages/stac/lib/src/parsers/widgets/stac_border_radius/stac_border_radius.dart index c9f27963..d214ff66 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_border_radius/stac_border_radius.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_border_radius/stac_border_radius.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; part 'stac_border_radius.freezed.dart'; part 'stac_border_radius.g.dart'; @@ -7,10 +8,10 @@ part 'stac_border_radius.g.dart'; @freezed abstract class StacBorderRadius with _$StacBorderRadius { const factory StacBorderRadius({ - @Default(0.0) double topLeft, - @Default(0.0) double topRight, - @Default(0.0) double bottomLeft, - @Default(0.0) double bottomRight, + @Default(StacDouble.zero) StacDouble topLeft, + @Default(StacDouble.zero) StacDouble topRight, + @Default(StacDouble.zero) StacDouble bottomLeft, + @Default(StacDouble.zero) StacDouble bottomRight, }) = _StacBorder; factory StacBorderRadius.fromJson(dynamic json) => _fromJson(json); @@ -49,10 +50,10 @@ abstract class StacBorderRadius with _$StacBorderRadius { extension StacBorderRadiusParser on StacBorderRadius? { BorderRadius get parse { return BorderRadius.only( - topLeft: Radius.circular(this?.topLeft ?? 0.0), - topRight: Radius.circular(this?.topRight ?? 0.0), - bottomLeft: Radius.circular(this?.bottomLeft ?? 0.0), - bottomRight: Radius.circular(this?.bottomRight ?? 0.0), + topLeft: Radius.circular(this?.topLeft.parse ?? 0.0), + topRight: Radius.circular(this?.topRight.parse ?? 0.0), + bottomLeft: Radius.circular(this?.bottomLeft.parse ?? 0.0), + bottomRight: Radius.circular(this?.bottomRight.parse ?? 0.0), ); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_border_radius/stac_border_radius.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_border_radius/stac_border_radius.freezed.dart index c4ecf342..21ad14af 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_border_radius/stac_border_radius.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_border_radius/stac_border_radius.freezed.dart @@ -18,10 +18,10 @@ StacBorderRadius _$StacBorderRadiusFromJson(Map json) { /// @nodoc mixin _$StacBorderRadius { - double get topLeft; - double get topRight; - double get bottomLeft; - double get bottomRight; + StacDouble get topLeft; + StacDouble get topRight; + StacDouble get bottomLeft; + StacDouble get bottomRight; /// Create a copy of StacBorderRadius /// with the given fields replaced by the non-null parameter values. @@ -66,7 +66,10 @@ abstract mixin class $StacBorderRadiusCopyWith<$Res> { _$StacBorderRadiusCopyWithImpl; @useResult $Res call( - {double topLeft, double topRight, double bottomLeft, double bottomRight}); + {StacDouble topLeft, + StacDouble topRight, + StacDouble bottomLeft, + StacDouble bottomRight}); } /// @nodoc @@ -91,19 +94,19 @@ class _$StacBorderRadiusCopyWithImpl<$Res> topLeft: null == topLeft ? _self.topLeft : topLeft // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, topRight: null == topRight ? _self.topRight : topRight // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, bottomLeft: null == bottomLeft ? _self.bottomLeft : bottomLeft // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, bottomRight: null == bottomRight ? _self.bottomRight : bottomRight // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, )); } } @@ -112,25 +115,25 @@ class _$StacBorderRadiusCopyWithImpl<$Res> @JsonSerializable() class _StacBorder implements StacBorderRadius { const _StacBorder( - {this.topLeft = 0.0, - this.topRight = 0.0, - this.bottomLeft = 0.0, - this.bottomRight = 0.0}); + {this.topLeft = StacDouble.zero, + this.topRight = StacDouble.zero, + this.bottomLeft = StacDouble.zero, + this.bottomRight = StacDouble.zero}); factory _StacBorder.fromJson(Map json) => _$StacBorderFromJson(json); @override @JsonKey() - final double topLeft; + final StacDouble topLeft; @override @JsonKey() - final double topRight; + final StacDouble topRight; @override @JsonKey() - final double bottomLeft; + final StacDouble bottomLeft; @override @JsonKey() - final double bottomRight; + final StacDouble bottomRight; /// Create a copy of StacBorderRadius /// with the given fields replaced by the non-null parameter values. @@ -181,7 +184,10 @@ abstract mixin class _$StacBorderCopyWith<$Res> @override @useResult $Res call( - {double topLeft, double topRight, double bottomLeft, double bottomRight}); + {StacDouble topLeft, + StacDouble topRight, + StacDouble bottomLeft, + StacDouble bottomRight}); } /// @nodoc @@ -205,19 +211,19 @@ class __$StacBorderCopyWithImpl<$Res> implements _$StacBorderCopyWith<$Res> { topLeft: null == topLeft ? _self.topLeft : topLeft // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, topRight: null == topRight ? _self.topRight : topRight // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, bottomLeft: null == bottomLeft ? _self.bottomLeft : bottomLeft // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, bottomRight: null == bottomRight ? _self.bottomRight : bottomRight // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, )); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_border_radius/stac_border_radius.g.dart b/packages/stac/lib/src/parsers/widgets/stac_border_radius/stac_border_radius.g.dart index 52b0babd..ad563cb5 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_border_radius/stac_border_radius.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_border_radius/stac_border_radius.g.dart @@ -7,10 +7,18 @@ part of 'stac_border_radius.dart'; // ************************************************************************** _StacBorder _$StacBorderFromJson(Map json) => _StacBorder( - topLeft: (json['topLeft'] as num?)?.toDouble() ?? 0.0, - topRight: (json['topRight'] as num?)?.toDouble() ?? 0.0, - bottomLeft: (json['bottomLeft'] as num?)?.toDouble() ?? 0.0, - bottomRight: (json['bottomRight'] as num?)?.toDouble() ?? 0.0, + topLeft: json['topLeft'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['topLeft']), + topRight: json['topRight'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['topRight']), + bottomLeft: json['bottomLeft'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['bottomLeft']), + bottomRight: json['bottomRight'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['bottomRight']), ); Map _$StacBorderToJson(_StacBorder instance) => diff --git a/packages/stac/lib/src/parsers/widgets/stac_border_side/stac_border_side.dart b/packages/stac/lib/src/parsers/widgets/stac_border_side/stac_border_side.dart index d0de0a2f..51dee70d 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_border_side/stac_border_side.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_border_side/stac_border_side.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/color_utils.dart'; part 'stac_border_side.freezed.dart'; @@ -9,15 +10,15 @@ part 'stac_border_side.g.dart'; abstract class StacBorderSide with _$StacBorderSide { const factory StacBorderSide({ String? color, - @Default(0.0) double width, - @Default(0.0) double strokeAlign, + @Default(StacDouble.zero) StacDouble width, + @Default(StacDouble.zero) StacDouble strokeAlign, @Default(BorderStyle.solid) BorderStyle borderStyle, }) = _StacBorderSide; static const none = StacBorderSide( color: '000000', - width: 0.0, - strokeAlign: -1.0, + width: StacDouble.zero, + strokeAlign: StacDouble(-1.0), borderStyle: BorderStyle.none, ); @@ -29,9 +30,9 @@ extension StacBorderSideParser on StacBorderSide? { BorderSide parse(BuildContext context) { return BorderSide( color: this?.color.toColor(context) ?? const Color(0xFF000000), - width: this?.width ?? 0.0, + width: this?.width.parse ?? 0.0, style: this?.borderStyle ?? BorderStyle.solid, - strokeAlign: this?.strokeAlign ?? 0.0, + strokeAlign: this?.strokeAlign.parse ?? 0.0, ); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_border_side/stac_border_side.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_border_side/stac_border_side.freezed.dart index a3994c8e..6eea1bbc 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_border_side/stac_border_side.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_border_side/stac_border_side.freezed.dart @@ -16,8 +16,8 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacBorderSide { String? get color; - double get width; - double get strokeAlign; + StacDouble get width; + StacDouble get strokeAlign; BorderStyle get borderStyle; /// Create a copy of StacBorderSide @@ -63,8 +63,8 @@ abstract mixin class $StacBorderSideCopyWith<$Res> { @useResult $Res call( {String? color, - double width, - double strokeAlign, + StacDouble width, + StacDouble strokeAlign, BorderStyle borderStyle}); } @@ -94,11 +94,11 @@ class _$StacBorderSideCopyWithImpl<$Res> width: null == width ? _self.width : width // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, strokeAlign: null == strokeAlign ? _self.strokeAlign : strokeAlign // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, borderStyle: null == borderStyle ? _self.borderStyle : borderStyle // ignore: cast_nullable_to_non_nullable @@ -112,8 +112,8 @@ class _$StacBorderSideCopyWithImpl<$Res> class _StacBorderSide implements StacBorderSide { const _StacBorderSide( {this.color, - this.width = 0.0, - this.strokeAlign = 0.0, + this.width = StacDouble.zero, + this.strokeAlign = StacDouble.zero, this.borderStyle = BorderStyle.solid}); factory _StacBorderSide.fromJson(Map json) => _$StacBorderSideFromJson(json); @@ -122,10 +122,10 @@ class _StacBorderSide implements StacBorderSide { final String? color; @override @JsonKey() - final double width; + final StacDouble width; @override @JsonKey() - final double strokeAlign; + final StacDouble strokeAlign; @override @JsonKey() final BorderStyle borderStyle; @@ -179,8 +179,8 @@ abstract mixin class _$StacBorderSideCopyWith<$Res> @useResult $Res call( {String? color, - double width, - double strokeAlign, + StacDouble width, + StacDouble strokeAlign, BorderStyle borderStyle}); } @@ -210,11 +210,11 @@ class __$StacBorderSideCopyWithImpl<$Res> width: null == width ? _self.width : width // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, strokeAlign: null == strokeAlign ? _self.strokeAlign : strokeAlign // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, borderStyle: null == borderStyle ? _self.borderStyle : borderStyle // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_border_side/stac_border_side.g.dart b/packages/stac/lib/src/parsers/widgets/stac_border_side/stac_border_side.g.dart index 8d5742e6..4442e74e 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_border_side/stac_border_side.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_border_side/stac_border_side.g.dart @@ -9,8 +9,12 @@ part of 'stac_border_side.dart'; _StacBorderSide _$StacBorderSideFromJson(Map json) => _StacBorderSide( color: json['color'] as String?, - width: (json['width'] as num?)?.toDouble() ?? 0.0, - strokeAlign: (json['strokeAlign'] as num?)?.toDouble() ?? 0.0, + width: json['width'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['width']), + strokeAlign: json['strokeAlign'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['strokeAlign']), borderStyle: $enumDecodeNullable(_$BorderStyleEnumMap, json['borderStyle']) ?? BorderStyle.solid, diff --git a/packages/stac/lib/src/parsers/widgets/stac_bottom_navigation_bar/stac_bottom_navigation_bar.dart b/packages/stac/lib/src/parsers/widgets/stac_bottom_navigation_bar/stac_bottom_navigation_bar.dart index e288a84d..6e1870ef 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_bottom_navigation_bar/stac_bottom_navigation_bar.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_bottom_navigation_bar/stac_bottom_navigation_bar.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_navigation_bar_item/stac_bottom_navigation_bar_item.dart'; import 'package:stac/src/parsers/widgets/stac_text_style/stac_text_style.dart'; @@ -12,15 +13,15 @@ part 'stac_bottom_navigation_bar.g.dart'; abstract class StacBottomNavigationBar with _$StacBottomNavigationBar { const factory StacBottomNavigationBar({ required List items, - double? elevation, + StacDouble? elevation, BottomNavigationBarType? bottomNavigationBarType, String? fixedColor, String? backgroundColor, - @Default(24) double iconSize, + @Default(StacDouble(24)) StacDouble iconSize, String? selectedItemColor, String? unselectedItemColor, - @Default(14.0) double selectedFontSize, - @Default(12.0) double unselectedFontSize, + @Default(StacDouble(14.0)) StacDouble selectedFontSize, + @Default(StacDouble(12.0)) StacDouble unselectedFontSize, StacTextStyle? selectedLabelStyle, StacTextStyle? unselectedLabelStyle, bool? showSelectedLabels, diff --git a/packages/stac/lib/src/parsers/widgets/stac_bottom_navigation_bar/stac_bottom_navigation_bar.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_bottom_navigation_bar/stac_bottom_navigation_bar.freezed.dart index afc7fea3..91dec88a 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_bottom_navigation_bar/stac_bottom_navigation_bar.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_bottom_navigation_bar/stac_bottom_navigation_bar.freezed.dart @@ -16,15 +16,15 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacBottomNavigationBar { List get items; - double? get elevation; + StacDouble? get elevation; BottomNavigationBarType? get bottomNavigationBarType; String? get fixedColor; String? get backgroundColor; - double get iconSize; + StacDouble get iconSize; String? get selectedItemColor; String? get unselectedItemColor; - double get selectedFontSize; - double get unselectedFontSize; + StacDouble get selectedFontSize; + StacDouble get unselectedFontSize; StacTextStyle? get selectedLabelStyle; StacTextStyle? get unselectedLabelStyle; bool? get showSelectedLabels; @@ -117,15 +117,15 @@ abstract mixin class $StacBottomNavigationBarCopyWith<$Res> { @useResult $Res call( {List items, - double? elevation, + StacDouble? elevation, BottomNavigationBarType? bottomNavigationBarType, String? fixedColor, String? backgroundColor, - double iconSize, + StacDouble iconSize, String? selectedItemColor, String? unselectedItemColor, - double selectedFontSize, - double unselectedFontSize, + StacDouble selectedFontSize, + StacDouble unselectedFontSize, StacTextStyle? selectedLabelStyle, StacTextStyle? unselectedLabelStyle, bool? showSelectedLabels, @@ -175,7 +175,7 @@ class _$StacBottomNavigationBarCopyWithImpl<$Res> elevation: freezed == elevation ? _self.elevation : elevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, bottomNavigationBarType: freezed == bottomNavigationBarType ? _self.bottomNavigationBarType : bottomNavigationBarType // ignore: cast_nullable_to_non_nullable @@ -191,7 +191,7 @@ class _$StacBottomNavigationBarCopyWithImpl<$Res> iconSize: null == iconSize ? _self.iconSize : iconSize // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, selectedItemColor: freezed == selectedItemColor ? _self.selectedItemColor : selectedItemColor // ignore: cast_nullable_to_non_nullable @@ -203,11 +203,11 @@ class _$StacBottomNavigationBarCopyWithImpl<$Res> selectedFontSize: null == selectedFontSize ? _self.selectedFontSize : selectedFontSize // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, unselectedFontSize: null == unselectedFontSize ? _self.unselectedFontSize : unselectedFontSize // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, selectedLabelStyle: freezed == selectedLabelStyle ? _self.selectedLabelStyle : selectedLabelStyle // ignore: cast_nullable_to_non_nullable @@ -273,11 +273,11 @@ class _StacBottomNavigationBar implements StacBottomNavigationBar { this.bottomNavigationBarType, this.fixedColor, this.backgroundColor, - this.iconSize = 24, + this.iconSize = const StacDouble(24), this.selectedItemColor, this.unselectedItemColor, - this.selectedFontSize = 14.0, - this.unselectedFontSize = 12.0, + this.selectedFontSize = const StacDouble(14.0), + this.unselectedFontSize = const StacDouble(12.0), this.selectedLabelStyle, this.unselectedLabelStyle, this.showSelectedLabels, @@ -297,7 +297,7 @@ class _StacBottomNavigationBar implements StacBottomNavigationBar { } @override - final double? elevation; + final StacDouble? elevation; @override final BottomNavigationBarType? bottomNavigationBarType; @override @@ -306,17 +306,17 @@ class _StacBottomNavigationBar implements StacBottomNavigationBar { final String? backgroundColor; @override @JsonKey() - final double iconSize; + final StacDouble iconSize; @override final String? selectedItemColor; @override final String? unselectedItemColor; @override @JsonKey() - final double selectedFontSize; + final StacDouble selectedFontSize; @override @JsonKey() - final double unselectedFontSize; + final StacDouble unselectedFontSize; @override final StacTextStyle? selectedLabelStyle; @override @@ -422,15 +422,15 @@ abstract mixin class _$StacBottomNavigationBarCopyWith<$Res> @useResult $Res call( {List items, - double? elevation, + StacDouble? elevation, BottomNavigationBarType? bottomNavigationBarType, String? fixedColor, String? backgroundColor, - double iconSize, + StacDouble iconSize, String? selectedItemColor, String? unselectedItemColor, - double selectedFontSize, - double unselectedFontSize, + StacDouble selectedFontSize, + StacDouble unselectedFontSize, StacTextStyle? selectedLabelStyle, StacTextStyle? unselectedLabelStyle, bool? showSelectedLabels, @@ -482,7 +482,7 @@ class __$StacBottomNavigationBarCopyWithImpl<$Res> elevation: freezed == elevation ? _self.elevation : elevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, bottomNavigationBarType: freezed == bottomNavigationBarType ? _self.bottomNavigationBarType : bottomNavigationBarType // ignore: cast_nullable_to_non_nullable @@ -498,7 +498,7 @@ class __$StacBottomNavigationBarCopyWithImpl<$Res> iconSize: null == iconSize ? _self.iconSize : iconSize // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, selectedItemColor: freezed == selectedItemColor ? _self.selectedItemColor : selectedItemColor // ignore: cast_nullable_to_non_nullable @@ -510,11 +510,11 @@ class __$StacBottomNavigationBarCopyWithImpl<$Res> selectedFontSize: null == selectedFontSize ? _self.selectedFontSize : selectedFontSize // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, unselectedFontSize: null == unselectedFontSize ? _self.unselectedFontSize : unselectedFontSize // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, selectedLabelStyle: freezed == selectedLabelStyle ? _self.selectedLabelStyle : selectedLabelStyle // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_bottom_navigation_bar/stac_bottom_navigation_bar.g.dart b/packages/stac/lib/src/parsers/widgets/stac_bottom_navigation_bar/stac_bottom_navigation_bar.g.dart index 2dea0dcb..1af79dca 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_bottom_navigation_bar/stac_bottom_navigation_bar.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_bottom_navigation_bar/stac_bottom_navigation_bar.g.dart @@ -13,17 +13,24 @@ _StacBottomNavigationBar _$StacBottomNavigationBarFromJson( .map((e) => StacBottomNavigationBarItem.fromJson(e as Map)) .toList(), - elevation: (json['elevation'] as num?)?.toDouble(), + elevation: json['elevation'] == null + ? null + : StacDouble.fromJson(json['elevation']), bottomNavigationBarType: $enumDecodeNullable( _$BottomNavigationBarTypeEnumMap, json['bottomNavigationBarType']), fixedColor: json['fixedColor'] as String?, backgroundColor: json['backgroundColor'] as String?, - iconSize: (json['iconSize'] as num?)?.toDouble() ?? 24, + iconSize: json['iconSize'] == null + ? const StacDouble(24) + : StacDouble.fromJson(json['iconSize']), selectedItemColor: json['selectedItemColor'] as String?, unselectedItemColor: json['unselectedItemColor'] as String?, - selectedFontSize: (json['selectedFontSize'] as num?)?.toDouble() ?? 14.0, - unselectedFontSize: - (json['unselectedFontSize'] as num?)?.toDouble() ?? 12.0, + selectedFontSize: json['selectedFontSize'] == null + ? const StacDouble(14.0) + : StacDouble.fromJson(json['selectedFontSize']), + unselectedFontSize: json['unselectedFontSize'] == null + ? const StacDouble(12.0) + : StacDouble.fromJson(json['unselectedFontSize']), selectedLabelStyle: json['selectedLabelStyle'] == null ? null : StacTextStyle.fromJson(json['selectedLabelStyle']), diff --git a/packages/stac/lib/src/parsers/widgets/stac_bottom_navigation_bar/stac_bottom_navigation_bar_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_bottom_navigation_bar/stac_bottom_navigation_bar_parser.dart index 01f38274..591ac878 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_bottom_navigation_bar/stac_bottom_navigation_bar_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_bottom_navigation_bar/stac_bottom_navigation_bar_parser.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:stac/src/parsers/widgets/stac_bottom_navigation_bar/stac_bottom_navigation_bar.dart'; import 'package:stac/src/parsers/widgets/stac_default_bottom_navigation_controller/stac_default_bottom_navigation_controller.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_navigation_bar_item/stac_bottom_navigation_bar_item.dart'; import 'package:stac/src/parsers/widgets/stac_text_style/stac_text_style.dart'; import 'package:stac/src/utils/color_utils.dart'; @@ -26,15 +27,15 @@ class StacBottomNavigationBarParser items: model.items.map((item) => item.parse(context)).toList(), onTap: (index) => controller?.index = index, currentIndex: controller?.index ?? 0, - elevation: model.elevation, + elevation: model.elevation?.parse, type: model.bottomNavigationBarType, fixedColor: model.fixedColor?.toColor(context), backgroundColor: model.backgroundColor?.toColor(context), - iconSize: model.iconSize, + iconSize: model.iconSize.parse, selectedItemColor: model.selectedItemColor?.toColor(context), unselectedItemColor: model.unselectedItemColor?.toColor(context), - selectedFontSize: model.selectedFontSize, - unselectedFontSize: model.unselectedFontSize, + selectedFontSize: model.selectedFontSize.parse, + unselectedFontSize: model.unselectedFontSize.parse, selectedLabelStyle: model.selectedLabelStyle?.parse(context), unselectedLabelStyle: model.unselectedLabelStyle?.parse(context), showSelectedLabels: model.showSelectedLabels, diff --git a/packages/stac/lib/src/parsers/widgets/stac_box_constraints/stac_box_constraints.dart b/packages/stac/lib/src/parsers/widgets/stac_box_constraints/stac_box_constraints.dart index 9cbbda66..d3f39042 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_box_constraints/stac_box_constraints.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_box_constraints/stac_box_constraints.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; part 'stac_box_constraints.freezed.dart'; part 'stac_box_constraints.g.dart'; @@ -7,10 +8,10 @@ part 'stac_box_constraints.g.dart'; @freezed abstract class StacBoxConstraints with _$StacBoxConstraints { const factory StacBoxConstraints({ - required double minWidth, - required double maxWidth, - required double minHeight, - required double maxHeight, + required StacDouble minWidth, + required StacDouble maxWidth, + required StacDouble minHeight, + required StacDouble maxHeight, }) = _StacBoxConstraints; factory StacBoxConstraints.fromJson(Map json) => @@ -20,10 +21,10 @@ abstract class StacBoxConstraints with _$StacBoxConstraints { extension StacBoxConstraintsParser on StacBoxConstraints { BoxConstraints get parse { return BoxConstraints( - minWidth: minWidth, - maxWidth: maxWidth, - minHeight: minHeight, - maxHeight: maxHeight, + minWidth: minWidth.parse, + maxWidth: maxWidth.parse, + minHeight: minHeight.parse, + maxHeight: maxHeight.parse, ); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_box_constraints/stac_box_constraints.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_box_constraints/stac_box_constraints.freezed.dart index 418ec078..26399761 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_box_constraints/stac_box_constraints.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_box_constraints/stac_box_constraints.freezed.dart @@ -15,10 +15,10 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacBoxConstraints { - double get minWidth; - double get maxWidth; - double get minHeight; - double get maxHeight; + StacDouble get minWidth; + StacDouble get maxWidth; + StacDouble get minHeight; + StacDouble get maxHeight; /// Create a copy of StacBoxConstraints /// with the given fields replaced by the non-null parameter values. @@ -64,7 +64,10 @@ abstract mixin class $StacBoxConstraintsCopyWith<$Res> { _$StacBoxConstraintsCopyWithImpl; @useResult $Res call( - {double minWidth, double maxWidth, double minHeight, double maxHeight}); + {StacDouble minWidth, + StacDouble maxWidth, + StacDouble minHeight, + StacDouble maxHeight}); } /// @nodoc @@ -89,19 +92,19 @@ class _$StacBoxConstraintsCopyWithImpl<$Res> minWidth: null == minWidth ? _self.minWidth : minWidth // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, maxWidth: null == maxWidth ? _self.maxWidth : maxWidth // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, minHeight: null == minHeight ? _self.minHeight : minHeight // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, maxHeight: null == maxHeight ? _self.maxHeight : maxHeight // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, )); } } @@ -118,13 +121,13 @@ class _StacBoxConstraints implements StacBoxConstraints { _$StacBoxConstraintsFromJson(json); @override - final double minWidth; + final StacDouble minWidth; @override - final double maxWidth; + final StacDouble maxWidth; @override - final double minHeight; + final StacDouble minHeight; @override - final double maxHeight; + final StacDouble maxHeight; /// Create a copy of StacBoxConstraints /// with the given fields replaced by the non-null parameter values. @@ -176,7 +179,10 @@ abstract mixin class _$StacBoxConstraintsCopyWith<$Res> @override @useResult $Res call( - {double minWidth, double maxWidth, double minHeight, double maxHeight}); + {StacDouble minWidth, + StacDouble maxWidth, + StacDouble minHeight, + StacDouble maxHeight}); } /// @nodoc @@ -201,19 +207,19 @@ class __$StacBoxConstraintsCopyWithImpl<$Res> minWidth: null == minWidth ? _self.minWidth : minWidth // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, maxWidth: null == maxWidth ? _self.maxWidth : maxWidth // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, minHeight: null == minHeight ? _self.minHeight : minHeight // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, maxHeight: null == maxHeight ? _self.maxHeight : maxHeight // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, )); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_box_constraints/stac_box_constraints.g.dart b/packages/stac/lib/src/parsers/widgets/stac_box_constraints/stac_box_constraints.g.dart index 65b9cd93..6cf8171f 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_box_constraints/stac_box_constraints.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_box_constraints/stac_box_constraints.g.dart @@ -8,10 +8,10 @@ part of 'stac_box_constraints.dart'; _StacBoxConstraints _$StacBoxConstraintsFromJson(Map json) => _StacBoxConstraints( - minWidth: (json['minWidth'] as num).toDouble(), - maxWidth: (json['maxWidth'] as num).toDouble(), - minHeight: (json['minHeight'] as num).toDouble(), - maxHeight: (json['maxHeight'] as num).toDouble(), + minWidth: StacDouble.fromJson(json['minWidth']), + maxWidth: StacDouble.fromJson(json['maxWidth']), + minHeight: StacDouble.fromJson(json['minHeight']), + maxHeight: StacDouble.fromJson(json['maxHeight']), ); Map _$StacBoxConstraintsToJson(_StacBoxConstraints instance) => diff --git a/packages/stac/lib/src/parsers/widgets/stac_box_shadow/stac_box_shadow.dart b/packages/stac/lib/src/parsers/widgets/stac_box_shadow/stac_box_shadow.dart index d9714c2d..4597f325 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_box_shadow/stac_box_shadow.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_box_shadow/stac_box_shadow.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_offset/stac_offset.dart'; import 'package:stac/src/utils/color_utils.dart'; @@ -10,9 +11,10 @@ part 'stac_box_shadow.g.dart'; abstract class StacBoxShadow with _$StacBoxShadow { const factory StacBoxShadow({ String? color, - @Default(0.0) double? blurRadius, - @Default(StacOffset(dx: 0, dy: 0)) StacOffset offset, - @Default(0.0) double? spreadRadius, + @Default(StacDouble.zero) StacDouble? blurRadius, + @Default(StacOffset(dx: StacDouble.zero, dy: StacDouble.zero)) + StacOffset offset, + @Default(StacDouble.zero) StacDouble? spreadRadius, @Default(BlurStyle.normal) BlurStyle? blurStyle, }) = _StacBoxShadow; @@ -24,9 +26,9 @@ extension StacBoxShadowParser on StacBoxShadow? { BoxShadow parse(BuildContext context) { return BoxShadow( color: this?.color.toColor(context) ?? const Color(0xFF000000), - blurRadius: this?.blurRadius ?? 0.0, + blurRadius: this?.blurRadius?.parse ?? 0.0, offset: this?.offset.parse ?? Offset.zero, - spreadRadius: this?.spreadRadius ?? 0.0, + spreadRadius: this?.spreadRadius?.parse ?? 0.0, blurStyle: this?.blurStyle ?? BlurStyle.normal, ); } diff --git a/packages/stac/lib/src/parsers/widgets/stac_box_shadow/stac_box_shadow.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_box_shadow/stac_box_shadow.freezed.dart index 68b00ee6..7fc3efb4 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_box_shadow/stac_box_shadow.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_box_shadow/stac_box_shadow.freezed.dart @@ -16,9 +16,9 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacBoxShadow { String? get color; - double? get blurRadius; + StacDouble? get blurRadius; StacOffset get offset; - double? get spreadRadius; + StacDouble? get spreadRadius; BlurStyle? get blurStyle; /// Create a copy of StacBoxShadow @@ -66,9 +66,9 @@ abstract mixin class $StacBoxShadowCopyWith<$Res> { @useResult $Res call( {String? color, - double? blurRadius, + StacDouble? blurRadius, StacOffset offset, - double? spreadRadius, + StacDouble? spreadRadius, BlurStyle? blurStyle}); $StacOffsetCopyWith<$Res> get offset; @@ -101,7 +101,7 @@ class _$StacBoxShadowCopyWithImpl<$Res> blurRadius: freezed == blurRadius ? _self.blurRadius : blurRadius // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, offset: null == offset ? _self.offset : offset // ignore: cast_nullable_to_non_nullable @@ -109,7 +109,7 @@ class _$StacBoxShadowCopyWithImpl<$Res> spreadRadius: freezed == spreadRadius ? _self.spreadRadius : spreadRadius // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, blurStyle: freezed == blurStyle ? _self.blurStyle : blurStyle // ignore: cast_nullable_to_non_nullable @@ -133,9 +133,9 @@ class _$StacBoxShadowCopyWithImpl<$Res> class _StacBoxShadow implements StacBoxShadow { const _StacBoxShadow( {this.color, - this.blurRadius = 0.0, - this.offset = const StacOffset(dx: 0, dy: 0), - this.spreadRadius = 0.0, + this.blurRadius = StacDouble.zero, + this.offset = const StacOffset(dx: StacDouble.zero, dy: StacDouble.zero), + this.spreadRadius = StacDouble.zero, this.blurStyle = BlurStyle.normal}); factory _StacBoxShadow.fromJson(Map json) => _$StacBoxShadowFromJson(json); @@ -144,13 +144,13 @@ class _StacBoxShadow implements StacBoxShadow { final String? color; @override @JsonKey() - final double? blurRadius; + final StacDouble? blurRadius; @override @JsonKey() final StacOffset offset; @override @JsonKey() - final double? spreadRadius; + final StacDouble? spreadRadius; @override @JsonKey() final BlurStyle? blurStyle; @@ -206,9 +206,9 @@ abstract mixin class _$StacBoxShadowCopyWith<$Res> @useResult $Res call( {String? color, - double? blurRadius, + StacDouble? blurRadius, StacOffset offset, - double? spreadRadius, + StacDouble? spreadRadius, BlurStyle? blurStyle}); @override @@ -242,7 +242,7 @@ class __$StacBoxShadowCopyWithImpl<$Res> blurRadius: freezed == blurRadius ? _self.blurRadius : blurRadius // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, offset: null == offset ? _self.offset : offset // ignore: cast_nullable_to_non_nullable @@ -250,7 +250,7 @@ class __$StacBoxShadowCopyWithImpl<$Res> spreadRadius: freezed == spreadRadius ? _self.spreadRadius : spreadRadius // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, blurStyle: freezed == blurStyle ? _self.blurStyle : blurStyle // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_box_shadow/stac_box_shadow.g.dart b/packages/stac/lib/src/parsers/widgets/stac_box_shadow/stac_box_shadow.g.dart index 3b89c8dc..0a652bf2 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_box_shadow/stac_box_shadow.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_box_shadow/stac_box_shadow.g.dart @@ -9,11 +9,15 @@ part of 'stac_box_shadow.dart'; _StacBoxShadow _$StacBoxShadowFromJson(Map json) => _StacBoxShadow( color: json['color'] as String?, - blurRadius: (json['blurRadius'] as num?)?.toDouble() ?? 0.0, + blurRadius: json['blurRadius'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['blurRadius']), offset: json['offset'] == null - ? const StacOffset(dx: 0, dy: 0) + ? const StacOffset(dx: StacDouble.zero, dy: StacDouble.zero) : StacOffset.fromJson(json['offset'] as Map), - spreadRadius: (json['spreadRadius'] as num?)?.toDouble() ?? 0.0, + spreadRadius: json['spreadRadius'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['spreadRadius']), blurStyle: $enumDecodeNullable(_$BlurStyleEnumMap, json['blurStyle']) ?? BlurStyle.normal, ); diff --git a/packages/stac/lib/src/parsers/widgets/stac_card/stac_card.dart b/packages/stac/lib/src/parsers/widgets/stac_card/stac_card.dart index a26de6d2..5af58469 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_card/stac_card.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_card/stac_card.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; import 'package:stac/src/parsers/widgets/stac_shape_border/stac_shape_border.dart'; @@ -14,7 +15,7 @@ abstract class StacCard with _$StacCard { String? color, String? shadowColor, String? surfaceTintColor, - double? elevation, + StacDouble? elevation, StacShapeBorder? shape, @Default(true) bool borderOnForeground, StacEdgeInsets? margin, diff --git a/packages/stac/lib/src/parsers/widgets/stac_card/stac_card.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_card/stac_card.freezed.dart index 171115e3..2dff4108 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_card/stac_card.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_card/stac_card.freezed.dart @@ -18,7 +18,7 @@ mixin _$StacCard { String? get color; String? get shadowColor; String? get surfaceTintColor; - double? get elevation; + StacDouble? get elevation; StacShapeBorder? get shape; bool get borderOnForeground; StacEdgeInsets? get margin; @@ -89,7 +89,7 @@ abstract mixin class $StacCardCopyWith<$Res> { {String? color, String? shadowColor, String? surfaceTintColor, - double? elevation, + StacDouble? elevation, StacShapeBorder? shape, bool borderOnForeground, StacEdgeInsets? margin, @@ -140,7 +140,7 @@ class _$StacCardCopyWithImpl<$Res> implements $StacCardCopyWith<$Res> { elevation: freezed == elevation ? _self.elevation : elevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, shape: freezed == shape ? _self.shape : shape // ignore: cast_nullable_to_non_nullable @@ -222,7 +222,7 @@ class _StacCard implements StacCard { @override final String? surfaceTintColor; @override - final double? elevation; + final StacDouble? elevation; @override final StacShapeBorder? shape; @override @@ -316,7 +316,7 @@ abstract mixin class _$StacCardCopyWith<$Res> {String? color, String? shadowColor, String? surfaceTintColor, - double? elevation, + StacDouble? elevation, StacShapeBorder? shape, bool borderOnForeground, StacEdgeInsets? margin, @@ -369,7 +369,7 @@ class __$StacCardCopyWithImpl<$Res> implements _$StacCardCopyWith<$Res> { elevation: freezed == elevation ? _self.elevation : elevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, shape: freezed == shape ? _self.shape : shape // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_card/stac_card.g.dart b/packages/stac/lib/src/parsers/widgets/stac_card/stac_card.g.dart index afd014a2..fb287c86 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_card/stac_card.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_card/stac_card.g.dart @@ -10,7 +10,9 @@ _StacCard _$StacCardFromJson(Map json) => _StacCard( color: json['color'] as String?, shadowColor: json['shadowColor'] as String?, surfaceTintColor: json['surfaceTintColor'] as String?, - elevation: (json['elevation'] as num?)?.toDouble(), + elevation: json['elevation'] == null + ? null + : StacDouble.fromJson(json['elevation']), shape: json['shape'] == null ? null : StacShapeBorder.fromJson(json['shape'] as Map), diff --git a/packages/stac/lib/src/parsers/widgets/stac_card/stac_card_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_card/stac_card_parser.dart index f5856e13..17c2d223 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_card/stac_card_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_card/stac_card_parser.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; import 'package:stac/src/parsers/widgets/stac_card/stac_card.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; import 'package:stac/src/parsers/widgets/stac_shape_border/stac_shape_border.dart'; import 'package:stac/src/utils/color_utils.dart'; @@ -22,7 +23,7 @@ class StacCardParser extends StacParser { color: model.color?.toColor(context), shadowColor: model.shadowColor?.toColor(context), surfaceTintColor: model.surfaceTintColor?.toColor(context), - elevation: model.elevation, + elevation: model.elevation?.parse, shape: model.shape?.parse(context), borderOnForeground: model.borderOnForeground, clipBehavior: model.clipBehavior, diff --git a/packages/stac/lib/src/parsers/widgets/stac_carousel_view/stac_carousel_view.dart b/packages/stac/lib/src/parsers/widgets/stac_carousel_view/stac_carousel_view.dart index 89ed7737..dfd77657 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_carousel_view/stac_carousel_view.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_carousel_view/stac_carousel_view.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; export 'stac_carousel_view_parser.dart'; @@ -18,15 +19,15 @@ abstract class StacCarouselView with _$StacCarouselView { @Default(StacCarouselViewType.regular) StacCarouselViewType carouselType, StacEdgeInsets? padding, String? backgroundColor, - double? elevation, + StacDouble? elevation, String? overlayColor, @Default(false) bool itemSnapping, - @Default(0.0) double shrinkExtent, + @Default(StacDouble.zero) StacDouble shrinkExtent, @Default(Axis.horizontal) Axis scrollDirection, @Default(false) bool reverse, Map? onTap, @Default(true) bool enableSplash, - double? itemExtent, + StacDouble? itemExtent, List? flexWeights, required List>? children, }) = _StacCarouselView; diff --git a/packages/stac/lib/src/parsers/widgets/stac_carousel_view/stac_carousel_view.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_carousel_view/stac_carousel_view.freezed.dart index b262720a..8adff592 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_carousel_view/stac_carousel_view.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_carousel_view/stac_carousel_view.freezed.dart @@ -18,15 +18,15 @@ mixin _$StacCarouselView { StacCarouselViewType get carouselType; StacEdgeInsets? get padding; String? get backgroundColor; - double? get elevation; + StacDouble? get elevation; String? get overlayColor; bool get itemSnapping; - double get shrinkExtent; + StacDouble get shrinkExtent; Axis get scrollDirection; bool get reverse; Map? get onTap; bool get enableSplash; - double? get itemExtent; + StacDouble? get itemExtent; List? get flexWeights; List>? get children; @@ -107,15 +107,15 @@ abstract mixin class $StacCarouselViewCopyWith<$Res> { {StacCarouselViewType carouselType, StacEdgeInsets? padding, String? backgroundColor, - double? elevation, + StacDouble? elevation, String? overlayColor, bool itemSnapping, - double shrinkExtent, + StacDouble shrinkExtent, Axis scrollDirection, bool reverse, Map? onTap, bool enableSplash, - double? itemExtent, + StacDouble? itemExtent, List? flexWeights, List>? children}); @@ -166,7 +166,7 @@ class _$StacCarouselViewCopyWithImpl<$Res> elevation: freezed == elevation ? _self.elevation : elevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, overlayColor: freezed == overlayColor ? _self.overlayColor : overlayColor // ignore: cast_nullable_to_non_nullable @@ -178,7 +178,7 @@ class _$StacCarouselViewCopyWithImpl<$Res> shrinkExtent: null == shrinkExtent ? _self.shrinkExtent : shrinkExtent // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, scrollDirection: null == scrollDirection ? _self.scrollDirection : scrollDirection // ignore: cast_nullable_to_non_nullable @@ -198,7 +198,7 @@ class _$StacCarouselViewCopyWithImpl<$Res> itemExtent: freezed == itemExtent ? _self.itemExtent : itemExtent // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, flexWeights: freezed == flexWeights ? _self.flexWeights : flexWeights // ignore: cast_nullable_to_non_nullable @@ -235,7 +235,7 @@ class _StacCarouselView implements StacCarouselView { this.elevation, this.overlayColor, this.itemSnapping = false, - this.shrinkExtent = 0.0, + this.shrinkExtent = StacDouble.zero, this.scrollDirection = Axis.horizontal, this.reverse = false, final Map? onTap, @@ -257,7 +257,7 @@ class _StacCarouselView implements StacCarouselView { @override final String? backgroundColor; @override - final double? elevation; + final StacDouble? elevation; @override final String? overlayColor; @override @@ -265,7 +265,7 @@ class _StacCarouselView implements StacCarouselView { final bool itemSnapping; @override @JsonKey() - final double shrinkExtent; + final StacDouble shrinkExtent; @override @JsonKey() final Axis scrollDirection; @@ -286,7 +286,7 @@ class _StacCarouselView implements StacCarouselView { @JsonKey() final bool enableSplash; @override - final double? itemExtent; + final StacDouble? itemExtent; final List? _flexWeights; @override List? get flexWeights { @@ -390,15 +390,15 @@ abstract mixin class _$StacCarouselViewCopyWith<$Res> {StacCarouselViewType carouselType, StacEdgeInsets? padding, String? backgroundColor, - double? elevation, + StacDouble? elevation, String? overlayColor, bool itemSnapping, - double shrinkExtent, + StacDouble shrinkExtent, Axis scrollDirection, bool reverse, Map? onTap, bool enableSplash, - double? itemExtent, + StacDouble? itemExtent, List? flexWeights, List>? children}); @@ -450,7 +450,7 @@ class __$StacCarouselViewCopyWithImpl<$Res> elevation: freezed == elevation ? _self.elevation : elevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, overlayColor: freezed == overlayColor ? _self.overlayColor : overlayColor // ignore: cast_nullable_to_non_nullable @@ -462,7 +462,7 @@ class __$StacCarouselViewCopyWithImpl<$Res> shrinkExtent: null == shrinkExtent ? _self.shrinkExtent : shrinkExtent // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, scrollDirection: null == scrollDirection ? _self.scrollDirection : scrollDirection // ignore: cast_nullable_to_non_nullable @@ -482,7 +482,7 @@ class __$StacCarouselViewCopyWithImpl<$Res> itemExtent: freezed == itemExtent ? _self.itemExtent : itemExtent // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, flexWeights: freezed == flexWeights ? _self._flexWeights : flexWeights // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_carousel_view/stac_carousel_view.g.dart b/packages/stac/lib/src/parsers/widgets/stac_carousel_view/stac_carousel_view.g.dart index 4af7e1ad..261c56b8 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_carousel_view/stac_carousel_view.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_carousel_view/stac_carousel_view.g.dart @@ -15,17 +15,23 @@ _StacCarouselView _$StacCarouselViewFromJson(Map json) => ? null : StacEdgeInsets.fromJson(json['padding']), backgroundColor: json['backgroundColor'] as String?, - elevation: (json['elevation'] as num?)?.toDouble(), + elevation: json['elevation'] == null + ? null + : StacDouble.fromJson(json['elevation']), overlayColor: json['overlayColor'] as String?, itemSnapping: json['itemSnapping'] as bool? ?? false, - shrinkExtent: (json['shrinkExtent'] as num?)?.toDouble() ?? 0.0, + shrinkExtent: json['shrinkExtent'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['shrinkExtent']), scrollDirection: $enumDecodeNullable(_$AxisEnumMap, json['scrollDirection']) ?? Axis.horizontal, reverse: json['reverse'] as bool? ?? false, onTap: json['onTap'] as Map?, enableSplash: json['enableSplash'] as bool? ?? true, - itemExtent: (json['itemExtent'] as num?)?.toDouble(), + itemExtent: json['itemExtent'] == null + ? null + : StacDouble.fromJson(json['itemExtent']), flexWeights: (json['flexWeights'] as List?) ?.map((e) => (e as num).toInt()) .toList(), diff --git a/packages/stac/lib/src/parsers/widgets/stac_carousel_view/stac_carousel_view_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_carousel_view/stac_carousel_view_parser.dart index cd37fe41..00148a19 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_carousel_view/stac_carousel_view_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_carousel_view/stac_carousel_view_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:stac/src/parsers/widgets/stac_carousel_view/stac_carousel_view.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; import 'package:stac/src/utils/color_utils.dart'; import 'package:stac/src/utils/widget_type.dart'; @@ -24,16 +25,16 @@ class StacCarouselViewParser extends StacParser { return CarouselView( padding: model.padding.parse, backgroundColor: model.backgroundColor.toColor(context), - elevation: model.elevation, + elevation: model.elevation?.parse, overlayColor: WidgetStateProperty.all(model.overlayColor.toColor(context)), itemSnapping: model.itemSnapping, - shrinkExtent: model.shrinkExtent, + shrinkExtent: model.shrinkExtent.parse, scrollDirection: model.scrollDirection, reverse: model.reverse, onTap: (index) => Stac.fromJson(model.onTap, context), enableSplash: model.enableSplash, - itemExtent: model.itemExtent ?? 0, + itemExtent: model.itemExtent?.parse ?? 0, children: model.children ?.map((e) => Stac.fromJson(e, context) ?? SizedBox()) .toList() ?? @@ -43,11 +44,11 @@ class StacCarouselViewParser extends StacParser { return CarouselView.weighted( padding: model.padding.parse, backgroundColor: model.backgroundColor.toColor(context), - elevation: model.elevation, + elevation: model.elevation?.parse, overlayColor: WidgetStateProperty.all(model.overlayColor.toColor(context)), itemSnapping: model.itemSnapping, - shrinkExtent: model.shrinkExtent, + shrinkExtent: model.shrinkExtent.parse, scrollDirection: model.scrollDirection, reverse: model.reverse, onTap: (index) => Stac.fromJson(model.onTap, context), diff --git a/packages/stac/lib/src/parsers/widgets/stac_center/stac_center.dart b/packages/stac/lib/src/parsers/widgets/stac_center/stac_center.dart index 6ce3e0e0..d1bbee4b 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_center/stac_center.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_center/stac_center.dart @@ -1,4 +1,5 @@ import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; export 'stac_center_parser.dart'; @@ -8,8 +9,8 @@ part 'stac_center.g.dart'; @freezed abstract class StacCenter with _$StacCenter { const factory StacCenter({ - double? widthFactor, - double? heightFactor, + StacDouble? widthFactor, + StacDouble? heightFactor, Map? child, }) = _StacCenter; diff --git a/packages/stac/lib/src/parsers/widgets/stac_center/stac_center.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_center/stac_center.freezed.dart index 0c4d45f7..f20d8f16 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_center/stac_center.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_center/stac_center.freezed.dart @@ -15,8 +15,8 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacCenter { - double? get widthFactor; - double? get heightFactor; + StacDouble? get widthFactor; + StacDouble? get heightFactor; Map? get child; /// Create a copy of StacCenter @@ -59,7 +59,9 @@ abstract mixin class $StacCenterCopyWith<$Res> { _$StacCenterCopyWithImpl; @useResult $Res call( - {double? widthFactor, double? heightFactor, Map? child}); + {StacDouble? widthFactor, + StacDouble? heightFactor, + Map? child}); } /// @nodoc @@ -82,11 +84,11 @@ class _$StacCenterCopyWithImpl<$Res> implements $StacCenterCopyWith<$Res> { widthFactor: freezed == widthFactor ? _self.widthFactor : widthFactor // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, heightFactor: freezed == heightFactor ? _self.heightFactor : heightFactor // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, child: freezed == child ? _self.child : child // ignore: cast_nullable_to_non_nullable @@ -105,9 +107,9 @@ class _StacCenter implements StacCenter { _$StacCenterFromJson(json); @override - final double? widthFactor; + final StacDouble? widthFactor; @override - final double? heightFactor; + final StacDouble? heightFactor; final Map? _child; @override Map? get child { @@ -165,7 +167,9 @@ abstract mixin class _$StacCenterCopyWith<$Res> @override @useResult $Res call( - {double? widthFactor, double? heightFactor, Map? child}); + {StacDouble? widthFactor, + StacDouble? heightFactor, + Map? child}); } /// @nodoc @@ -188,11 +192,11 @@ class __$StacCenterCopyWithImpl<$Res> implements _$StacCenterCopyWith<$Res> { widthFactor: freezed == widthFactor ? _self.widthFactor : widthFactor // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, heightFactor: freezed == heightFactor ? _self.heightFactor : heightFactor // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, child: freezed == child ? _self._child : child // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_center/stac_center.g.dart b/packages/stac/lib/src/parsers/widgets/stac_center/stac_center.g.dart index 3d8ecdee..b35008b1 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_center/stac_center.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_center/stac_center.g.dart @@ -7,8 +7,12 @@ part of 'stac_center.dart'; // ************************************************************************** _StacCenter _$StacCenterFromJson(Map json) => _StacCenter( - widthFactor: (json['widthFactor'] as num?)?.toDouble(), - heightFactor: (json['heightFactor'] as num?)?.toDouble(), + widthFactor: json['widthFactor'] == null + ? null + : StacDouble.fromJson(json['widthFactor']), + heightFactor: json['heightFactor'] == null + ? null + : StacDouble.fromJson(json['heightFactor']), child: json['child'] as Map?, ); diff --git a/packages/stac/lib/src/parsers/widgets/stac_center/stac_center_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_center/stac_center_parser.dart index 5c8ffc88..c26ecc9a 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_center/stac_center_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_center/stac_center_parser.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; import 'package:stac/src/parsers/widgets/stac_center/stac_center.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; @@ -16,8 +17,8 @@ class StacCenterParser extends StacParser { @override Widget parse(BuildContext context, StacCenter model) { return Center( - widthFactor: model.widthFactor, - heightFactor: model.heightFactor, + widthFactor: model.widthFactor?.parse, + heightFactor: model.heightFactor?.parse, child: Stac.fromJson(model.child, context), ); } diff --git a/packages/stac/lib/src/parsers/widgets/stac_check_box/stac_check_box.dart b/packages/stac/lib/src/parsers/widgets/stac_check_box/stac_check_box.dart index 7a2f97d6..2cf36181 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_check_box/stac_check_box.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_check_box/stac_check_box.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:stac/src/parsers/theme/stac_material_color/stac_material_color.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_mouse_cursor/stac_mouse_cursor.dart'; export 'stac_check_box_parser.dart'; @@ -22,7 +23,7 @@ abstract class StacCheckBox with _$StacCheckBox { String? focusColor, String? hoverColor, StacMaterialColor? overlayColor, - double? splashRadius, + StacDouble? splashRadius, MaterialTapTargetSize? materialTapTargetSize, @Default(false) bool autofocus, @Default(false) bool isError, diff --git a/packages/stac/lib/src/parsers/widgets/stac_check_box/stac_check_box.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_check_box/stac_check_box.freezed.dart index 6ab6467a..36dd389d 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_check_box/stac_check_box.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_check_box/stac_check_box.freezed.dart @@ -26,7 +26,7 @@ mixin _$StacCheckBox { String? get focusColor; String? get hoverColor; StacMaterialColor? get overlayColor; - double? get splashRadius; + StacDouble? get splashRadius; MaterialTapTargetSize? get materialTapTargetSize; bool get autofocus; bool get isError; @@ -119,7 +119,7 @@ abstract mixin class $StacCheckBoxCopyWith<$Res> { String? focusColor, String? hoverColor, StacMaterialColor? overlayColor, - double? splashRadius, + StacDouble? splashRadius, MaterialTapTargetSize? materialTapTargetSize, bool autofocus, bool isError}); @@ -204,7 +204,7 @@ class _$StacCheckBoxCopyWithImpl<$Res> implements $StacCheckBoxCopyWith<$Res> { splashRadius: freezed == splashRadius ? _self.splashRadius : splashRadius // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, materialTapTargetSize: freezed == materialTapTargetSize ? _self.materialTapTargetSize : materialTapTargetSize // ignore: cast_nullable_to_non_nullable @@ -304,7 +304,7 @@ class _StacCheckBox implements StacCheckBox { @override final StacMaterialColor? overlayColor; @override - final double? splashRadius; + final StacDouble? splashRadius; @override final MaterialTapTargetSize? materialTapTargetSize; @override @@ -409,7 +409,7 @@ abstract mixin class _$StacCheckBoxCopyWith<$Res> String? focusColor, String? hoverColor, StacMaterialColor? overlayColor, - double? splashRadius, + StacDouble? splashRadius, MaterialTapTargetSize? materialTapTargetSize, bool autofocus, bool isError}); @@ -497,7 +497,7 @@ class __$StacCheckBoxCopyWithImpl<$Res> splashRadius: freezed == splashRadius ? _self.splashRadius : splashRadius // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, materialTapTargetSize: freezed == materialTapTargetSize ? _self.materialTapTargetSize : materialTapTargetSize // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_check_box/stac_check_box.g.dart b/packages/stac/lib/src/parsers/widgets/stac_check_box/stac_check_box.g.dart index 2a3c85e7..f48d099b 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_check_box/stac_check_box.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_check_box/stac_check_box.g.dart @@ -26,7 +26,9 @@ _StacCheckBox _$StacCheckBoxFromJson(Map json) => ? null : StacMaterialColor.fromJson( json['overlayColor'] as Map), - splashRadius: (json['splashRadius'] as num?)?.toDouble(), + splashRadius: json['splashRadius'] == null + ? null + : StacDouble.fromJson(json['splashRadius']), materialTapTargetSize: $enumDecodeNullable( _$MaterialTapTargetSizeEnumMap, json['materialTapTargetSize']), autofocus: json['autofocus'] as bool? ?? false, diff --git a/packages/stac/lib/src/parsers/widgets/stac_check_box/stac_check_box_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_check_box/stac_check_box_parser.dart index 29502a78..3de08a60 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_check_box/stac_check_box_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_check_box/stac_check_box_parser.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:stac/src/parsers/theme/stac_material_color/stac_material_color.dart'; import 'package:stac/src/parsers/widgets/stac_check_box/stac_check_box.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_form/stac_form_scope.dart'; import 'package:stac/src/utils/color_utils.dart'; import 'package:stac/src/utils/widget_type.dart'; @@ -66,7 +67,7 @@ class _StacCheckBoxState extends State<_StacCheckBox> { hoverColor: widget.model.hoverColor.toColor(context), overlayColor: WidgetStateProperty.all(widget.model.overlayColor?.parse(context)), - splashRadius: widget.model.splashRadius, + splashRadius: widget.model.splashRadius?.parse, materialTapTargetSize: widget.model.materialTapTargetSize, autofocus: widget.model.autofocus, isError: widget.model.isError, diff --git a/packages/stac/lib/src/parsers/widgets/stac_chip/stac_chip.dart b/packages/stac/lib/src/parsers/widgets/stac_chip/stac_chip.dart index f5d268fb..e14c8b9d 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_chip/stac_chip.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_chip/stac_chip.dart @@ -3,6 +3,7 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:stac/src/parsers/theme/stac_icon_theme_data/stac_icon_theme_data.dart'; import 'package:stac/src/parsers/widgets/stac_border_side/stac_border_side.dart'; import 'package:stac/src/parsers/widgets/stac_box_constraints/stac_box_constraints.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; import 'package:stac/src/parsers/widgets/stac_rounded_rectangle_border/stac_rounded_rectangle_border.dart'; import 'package:stac/src/parsers/widgets/stac_text_style/stac_text_style.dart'; @@ -33,7 +34,7 @@ abstract class StacChip with _$StacChip { StacEdgeInsets? padding, StacVisualDensity? visualDensity, MaterialTapTargetSize? materialTapTargetSize, - double? elevation, + StacDouble? elevation, String? shadowColor, String? surfaceTintColor, StacIconThemeData? iconTheme, diff --git a/packages/stac/lib/src/parsers/widgets/stac_chip/stac_chip.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_chip/stac_chip.freezed.dart index 386c5142..044f922c 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_chip/stac_chip.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_chip/stac_chip.freezed.dart @@ -32,7 +32,7 @@ mixin _$StacChip { StacEdgeInsets? get padding; StacVisualDensity? get visualDensity; MaterialTapTargetSize? get materialTapTargetSize; - double? get elevation; + StacDouble? get elevation; String? get shadowColor; String? get surfaceTintColor; StacIconThemeData? get iconTheme; @@ -156,7 +156,7 @@ abstract mixin class $StacChipCopyWith<$Res> { StacEdgeInsets? padding, StacVisualDensity? visualDensity, MaterialTapTargetSize? materialTapTargetSize, - double? elevation, + StacDouble? elevation, String? shadowColor, String? surfaceTintColor, StacIconThemeData? iconTheme, @@ -282,7 +282,7 @@ class _$StacChipCopyWithImpl<$Res> implements $StacChipCopyWith<$Res> { elevation: freezed == elevation ? _self.elevation : elevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, shadowColor: freezed == shadowColor ? _self.shadowColor : shadowColor // ignore: cast_nullable_to_non_nullable @@ -536,7 +536,7 @@ class _StacChip implements StacChip { @override final MaterialTapTargetSize? materialTapTargetSize; @override - final double? elevation; + final StacDouble? elevation; @override final String? shadowColor; @override @@ -673,7 +673,7 @@ abstract mixin class _$StacChipCopyWith<$Res> StacEdgeInsets? padding, StacVisualDensity? visualDensity, MaterialTapTargetSize? materialTapTargetSize, - double? elevation, + StacDouble? elevation, String? shadowColor, String? surfaceTintColor, StacIconThemeData? iconTheme, @@ -808,7 +808,7 @@ class __$StacChipCopyWithImpl<$Res> implements _$StacChipCopyWith<$Res> { elevation: freezed == elevation ? _self.elevation : elevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, shadowColor: freezed == shadowColor ? _self.shadowColor : shadowColor // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_chip/stac_chip.g.dart b/packages/stac/lib/src/parsers/widgets/stac_chip/stac_chip.g.dart index 62f4c11c..12ed0e24 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_chip/stac_chip.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_chip/stac_chip.g.dart @@ -40,7 +40,9 @@ _StacChip _$StacChipFromJson(Map json) => _StacChip( json['visualDensity'] as Map), materialTapTargetSize: $enumDecodeNullable( _$MaterialTapTargetSizeEnumMap, json['materialTapTargetSize']), - elevation: (json['elevation'] as num?)?.toDouble(), + elevation: json['elevation'] == null + ? null + : StacDouble.fromJson(json['elevation']), shadowColor: json['shadowColor'] as String?, surfaceTintColor: json['surfaceTintColor'] as String?, iconTheme: json['iconTheme'] == null diff --git a/packages/stac/lib/src/parsers/widgets/stac_chip/stac_chip_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_chip/stac_chip_parser.dart index 64651881..ba235337 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_chip/stac_chip_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_chip/stac_chip_parser.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_rounded_rectangle_border/stac_rounded_rectangle_border.dart'; import 'package:stac/src/parsers/widgets/stac_visual_density/stac_visual_density.dart'; import 'package:stac/src/utils/widget_type.dart'; @@ -33,7 +34,7 @@ class StacChipParser extends StacParser { padding: model.padding.parse, visualDensity: model.visualDensity?.parse, materialTapTargetSize: model.materialTapTargetSize, - elevation: model.elevation, + elevation: model.elevation?.parse, shadowColor: model.shadowColor.toColor(context), surfaceTintColor: model.surfaceTintColor.toColor(context), iconTheme: model.iconTheme?.parse(context), diff --git a/packages/stac/lib/src/parsers/widgets/stac_circle_avatar/stac_circle_avatar.dart b/packages/stac/lib/src/parsers/widgets/stac_circle_avatar/stac_circle_avatar.dart index 3b40c63f..4371ae33 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_circle_avatar/stac_circle_avatar.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_circle_avatar/stac_circle_avatar.dart @@ -1,4 +1,5 @@ import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; export 'stac_circle_avatar_parser.dart'; @@ -15,9 +16,9 @@ abstract class StacCircleAvatar with _$StacCircleAvatar { Map? onBackgroundImageError, Map? onForegroundImageError, String? foregroundColor, - double? radius, - double? minRadius, - double? maxRadius, + StacDouble? radius, + StacDouble? minRadius, + StacDouble? maxRadius, }) = _StacCircleAvatar; factory StacCircleAvatar.fromJson(Map json) => diff --git a/packages/stac/lib/src/parsers/widgets/stac_circle_avatar/stac_circle_avatar.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_circle_avatar/stac_circle_avatar.freezed.dart index 66e0af2d..a1556276 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_circle_avatar/stac_circle_avatar.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_circle_avatar/stac_circle_avatar.freezed.dart @@ -22,9 +22,9 @@ mixin _$StacCircleAvatar { Map? get onBackgroundImageError; Map? get onForegroundImageError; String? get foregroundColor; - double? get radius; - double? get minRadius; - double? get maxRadius; + StacDouble? get radius; + StacDouble? get minRadius; + StacDouble? get maxRadius; /// Create a copy of StacCircleAvatar /// with the given fields replaced by the non-null parameter values. @@ -97,9 +97,9 @@ abstract mixin class $StacCircleAvatarCopyWith<$Res> { Map? onBackgroundImageError, Map? onForegroundImageError, String? foregroundColor, - double? radius, - double? minRadius, - double? maxRadius}); + StacDouble? radius, + StacDouble? minRadius, + StacDouble? maxRadius}); } /// @nodoc @@ -158,15 +158,15 @@ class _$StacCircleAvatarCopyWithImpl<$Res> radius: freezed == radius ? _self.radius : radius // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, minRadius: freezed == minRadius ? _self.minRadius : minRadius // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, maxRadius: freezed == maxRadius ? _self.maxRadius : maxRadius // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, )); } } @@ -232,11 +232,11 @@ class _StacCircleAvatar implements StacCircleAvatar { @override final String? foregroundColor; @override - final double? radius; + final StacDouble? radius; @override - final double? minRadius; + final StacDouble? minRadius; @override - final double? maxRadius; + final StacDouble? maxRadius; /// Create a copy of StacCircleAvatar /// with the given fields replaced by the non-null parameter values. @@ -315,9 +315,9 @@ abstract mixin class _$StacCircleAvatarCopyWith<$Res> Map? onBackgroundImageError, Map? onForegroundImageError, String? foregroundColor, - double? radius, - double? minRadius, - double? maxRadius}); + StacDouble? radius, + StacDouble? minRadius, + StacDouble? maxRadius}); } /// @nodoc @@ -376,15 +376,15 @@ class __$StacCircleAvatarCopyWithImpl<$Res> radius: freezed == radius ? _self.radius : radius // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, minRadius: freezed == minRadius ? _self.minRadius : minRadius // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, maxRadius: freezed == maxRadius ? _self.maxRadius : maxRadius // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, )); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_circle_avatar/stac_circle_avatar.g.dart b/packages/stac/lib/src/parsers/widgets/stac_circle_avatar/stac_circle_avatar.g.dart index f313ac61..ed2ddee2 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_circle_avatar/stac_circle_avatar.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_circle_avatar/stac_circle_avatar.g.dart @@ -17,9 +17,14 @@ _StacCircleAvatar _$StacCircleAvatarFromJson(Map json) => onForegroundImageError: json['onForegroundImageError'] as Map?, foregroundColor: json['foregroundColor'] as String?, - radius: (json['radius'] as num?)?.toDouble(), - minRadius: (json['minRadius'] as num?)?.toDouble(), - maxRadius: (json['maxRadius'] as num?)?.toDouble(), + radius: + json['radius'] == null ? null : StacDouble.fromJson(json['radius']), + minRadius: json['minRadius'] == null + ? null + : StacDouble.fromJson(json['minRadius']), + maxRadius: json['maxRadius'] == null + ? null + : StacDouble.fromJson(json['maxRadius']), ); Map _$StacCircleAvatarToJson(_StacCircleAvatar instance) => diff --git a/packages/stac/lib/src/parsers/widgets/stac_circle_avatar/stac_circle_avatar_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_circle_avatar/stac_circle_avatar_parser.dart index c25ac324..9fe070e2 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_circle_avatar/stac_circle_avatar_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_circle_avatar/stac_circle_avatar_parser.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac/stac.dart'; @@ -23,9 +24,9 @@ class StacCircleAvatarParser extends StacParser { ? NetworkImage(model.foregroundImage!) : null, foregroundColor: model.foregroundColor.toColor(context), - radius: model.radius, - minRadius: model.minRadius, - maxRadius: model.maxRadius, + radius: model.radius?.parse, + minRadius: model.minRadius?.parse, + maxRadius: model.maxRadius?.parse, child: Stac.fromJson(model.child, context), ); } diff --git a/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator.dart b/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator.dart index b318a802..84465094 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator.dart @@ -1,6 +1,7 @@ import 'dart:ui'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; export 'stac_circular_progress_indicator_parser.dart'; @@ -11,11 +12,11 @@ part 'stac_circular_progress_indicator.g.dart'; abstract class StacCircularProgressIndicator with _$StacCircularProgressIndicator { const factory StacCircularProgressIndicator({ - double? value, + StacDouble? value, String? backgroundColor, String? color, - @Default(4.0) double strokeWidth, - @Default(0) double strokeAlign, + @Default(StacDouble(4.0)) StacDouble strokeWidth, + @Default(StacDouble.zero) StacDouble strokeAlign, String? semanticsLabel, String? semanticsValue, StrokeCap? strokeCap, diff --git a/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator.freezed.dart index d43af8ab..34107da0 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator.freezed.dart @@ -15,11 +15,11 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacCircularProgressIndicator { - double? get value; + StacDouble? get value; String? get backgroundColor; String? get color; - double get strokeWidth; - double get strokeAlign; + StacDouble get strokeWidth; + StacDouble get strokeAlign; String? get semanticsLabel; String? get semanticsValue; StrokeCap? get strokeCap; @@ -76,11 +76,11 @@ abstract mixin class $StacCircularProgressIndicatorCopyWith<$Res> { _$StacCircularProgressIndicatorCopyWithImpl; @useResult $Res call( - {double? value, + {StacDouble? value, String? backgroundColor, String? color, - double strokeWidth, - double strokeAlign, + StacDouble strokeWidth, + StacDouble strokeAlign, String? semanticsLabel, String? semanticsValue, StrokeCap? strokeCap}); @@ -112,7 +112,7 @@ class _$StacCircularProgressIndicatorCopyWithImpl<$Res> value: freezed == value ? _self.value : value // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, backgroundColor: freezed == backgroundColor ? _self.backgroundColor : backgroundColor // ignore: cast_nullable_to_non_nullable @@ -124,11 +124,11 @@ class _$StacCircularProgressIndicatorCopyWithImpl<$Res> strokeWidth: null == strokeWidth ? _self.strokeWidth : strokeWidth // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, strokeAlign: null == strokeAlign ? _self.strokeAlign : strokeAlign // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, semanticsLabel: freezed == semanticsLabel ? _self.semanticsLabel : semanticsLabel // ignore: cast_nullable_to_non_nullable @@ -152,8 +152,8 @@ class _StacCircularProgressIndicator implements StacCircularProgressIndicator { {this.value, this.backgroundColor, this.color, - this.strokeWidth = 4.0, - this.strokeAlign = 0, + this.strokeWidth = const StacDouble(4.0), + this.strokeAlign = StacDouble.zero, this.semanticsLabel, this.semanticsValue, this.strokeCap}); @@ -161,17 +161,17 @@ class _StacCircularProgressIndicator implements StacCircularProgressIndicator { _$StacCircularProgressIndicatorFromJson(json); @override - final double? value; + final StacDouble? value; @override final String? backgroundColor; @override final String? color; @override @JsonKey() - final double strokeWidth; + final StacDouble strokeWidth; @override @JsonKey() - final double strokeAlign; + final StacDouble strokeAlign; @override final String? semanticsLabel; @override @@ -237,11 +237,11 @@ abstract mixin class _$StacCircularProgressIndicatorCopyWith<$Res> @override @useResult $Res call( - {double? value, + {StacDouble? value, String? backgroundColor, String? color, - double strokeWidth, - double strokeAlign, + StacDouble strokeWidth, + StacDouble strokeAlign, String? semanticsLabel, String? semanticsValue, StrokeCap? strokeCap}); @@ -273,7 +273,7 @@ class __$StacCircularProgressIndicatorCopyWithImpl<$Res> value: freezed == value ? _self.value : value // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, backgroundColor: freezed == backgroundColor ? _self.backgroundColor : backgroundColor // ignore: cast_nullable_to_non_nullable @@ -285,11 +285,11 @@ class __$StacCircularProgressIndicatorCopyWithImpl<$Res> strokeWidth: null == strokeWidth ? _self.strokeWidth : strokeWidth // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, strokeAlign: null == strokeAlign ? _self.strokeAlign : strokeAlign // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, semanticsLabel: freezed == semanticsLabel ? _self.semanticsLabel : semanticsLabel // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator.g.dart b/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator.g.dart index 4d6e5e34..483dea4e 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator.g.dart @@ -9,11 +9,15 @@ part of 'stac_circular_progress_indicator.dart'; _StacCircularProgressIndicator _$StacCircularProgressIndicatorFromJson( Map json) => _StacCircularProgressIndicator( - value: (json['value'] as num?)?.toDouble(), + value: json['value'] == null ? null : StacDouble.fromJson(json['value']), backgroundColor: json['backgroundColor'] as String?, color: json['color'] as String?, - strokeWidth: (json['strokeWidth'] as num?)?.toDouble() ?? 4.0, - strokeAlign: (json['strokeAlign'] as num?)?.toDouble() ?? 0, + strokeWidth: json['strokeWidth'] == null + ? const StacDouble(4.0) + : StacDouble.fromJson(json['strokeWidth']), + strokeAlign: json['strokeAlign'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['strokeAlign']), semanticsLabel: json['semanticsLabel'] as String?, semanticsValue: json['semanticsValue'] as String?, strokeCap: $enumDecodeNullable(_$StrokeCapEnumMap, json['strokeCap']), diff --git a/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator_parser.dart index a50bd8be..c8147751 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator_parser.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac/stac.dart'; @@ -16,11 +17,11 @@ class StacCircularProgressIndicatorParser @override Widget parse(BuildContext context, StacCircularProgressIndicator model) { return CircularProgressIndicator( - value: model.value, + value: model.value?.parse, backgroundColor: model.backgroundColor.toColor(context), color: model.color.toColor(context), - strokeWidth: model.strokeWidth, - strokeAlign: model.strokeAlign, + strokeWidth: model.strokeWidth.parse, + strokeAlign: model.strokeAlign.parse, semanticsLabel: model.semanticsLabel, semanticsValue: model.semanticsValue, strokeCap: model.strokeCap, diff --git a/packages/stac/lib/src/parsers/widgets/stac_column/stac_column.dart b/packages/stac/lib/src/parsers/widgets/stac_column/stac_column.dart index 6d0c70f1..ca1957f9 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_column/stac_column.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_column/stac_column.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; export 'stac_column_parser.dart'; @@ -14,7 +15,7 @@ abstract class StacColumn with _$StacColumn { @Default(MainAxisSize.max) MainAxisSize mainAxisSize, TextDirection? textDirection, @Default(VerticalDirection.down) VerticalDirection verticalDirection, - @Default(0) double spacing, + @Default(StacDouble.zero) StacDouble spacing, @Default([]) List> children, }) = _StacColumn; diff --git a/packages/stac/lib/src/parsers/widgets/stac_column/stac_column.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_column/stac_column.freezed.dart index 461a5c51..d6e6c702 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_column/stac_column.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_column/stac_column.freezed.dart @@ -20,7 +20,7 @@ mixin _$StacColumn { MainAxisSize get mainAxisSize; TextDirection? get textDirection; VerticalDirection get verticalDirection; - double get spacing; + StacDouble get spacing; List> get children; /// Create a copy of StacColumn @@ -82,7 +82,7 @@ abstract mixin class $StacColumnCopyWith<$Res> { MainAxisSize mainAxisSize, TextDirection? textDirection, VerticalDirection verticalDirection, - double spacing, + StacDouble spacing, List> children}); } @@ -130,7 +130,7 @@ class _$StacColumnCopyWithImpl<$Res> implements $StacColumnCopyWith<$Res> { spacing: null == spacing ? _self.spacing : spacing // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, children: null == children ? _self.children : children // ignore: cast_nullable_to_non_nullable @@ -148,7 +148,7 @@ class _StacColumn implements StacColumn { this.mainAxisSize = MainAxisSize.max, this.textDirection, this.verticalDirection = VerticalDirection.down, - this.spacing = 0, + this.spacing = StacDouble.zero, final List> children = const []}) : _children = children; factory _StacColumn.fromJson(Map json) => @@ -170,7 +170,7 @@ class _StacColumn implements StacColumn { final VerticalDirection verticalDirection; @override @JsonKey() - final double spacing; + final StacDouble spacing; final List> _children; @override @JsonKey() @@ -246,7 +246,7 @@ abstract mixin class _$StacColumnCopyWith<$Res> MainAxisSize mainAxisSize, TextDirection? textDirection, VerticalDirection verticalDirection, - double spacing, + StacDouble spacing, List> children}); } @@ -294,7 +294,7 @@ class __$StacColumnCopyWithImpl<$Res> implements _$StacColumnCopyWith<$Res> { spacing: null == spacing ? _self.spacing : spacing // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, children: null == children ? _self._children : children // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_column/stac_column.g.dart b/packages/stac/lib/src/parsers/widgets/stac_column/stac_column.g.dart index 30a40b92..a94d1f99 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_column/stac_column.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_column/stac_column.g.dart @@ -21,7 +21,9 @@ _StacColumn _$StacColumnFromJson(Map json) => _StacColumn( verticalDirection: $enumDecodeNullable( _$VerticalDirectionEnumMap, json['verticalDirection']) ?? VerticalDirection.down, - spacing: (json['spacing'] as num?)?.toDouble() ?? 0, + spacing: json['spacing'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['spacing']), children: (json['children'] as List?) ?.map((e) => e as Map) .toList() ?? diff --git a/packages/stac/lib/src/parsers/widgets/stac_column/stac_column_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_column/stac_column_parser.dart index 8768caae..c8338877 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_column/stac_column_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_column/stac_column_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; @@ -22,7 +23,7 @@ class StacColumnParser extends StacParser { mainAxisSize: model.mainAxisSize, textDirection: model.textDirection, verticalDirection: model.verticalDirection, - spacing: model.spacing, + spacing: model.spacing.parse, children: model.children .map( (value) => Stac.fromJson(value, context) ?? const SizedBox(), diff --git a/packages/stac/lib/src/parsers/widgets/stac_container/stac_container.dart b/packages/stac/lib/src/parsers/widgets/stac_container/stac_container.dart index 0ef0c1da..8d912276 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_container/stac_container.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_container/stac_container.dart @@ -4,6 +4,7 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:stac/src/parsers/widgets/stac_alignment/stac_alignment.dart'; import 'package:stac/src/parsers/widgets/stac_box_constraints/stac_box_constraints.dart'; import 'package:stac/src/parsers/widgets/stac_box_decoration/stac_box_decoration.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; export 'stac_container_parser.dart'; @@ -19,8 +20,8 @@ abstract class StacContainer with _$StacContainer { StacBoxDecoration? decoration, StacBoxDecoration? foregroundDecoration, String? color, - double? width, - double? height, + StacDouble? width, + StacDouble? height, StacBoxConstraints? constraints, StacEdgeInsets? margin, Map? child, diff --git a/packages/stac/lib/src/parsers/widgets/stac_container/stac_container.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_container/stac_container.freezed.dart index f3019727..4f4821da 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_container/stac_container.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_container/stac_container.freezed.dart @@ -20,8 +20,8 @@ mixin _$StacContainer { StacBoxDecoration? get decoration; StacBoxDecoration? get foregroundDecoration; String? get color; - double? get width; - double? get height; + StacDouble? get width; + StacDouble? get height; StacBoxConstraints? get constraints; StacEdgeInsets? get margin; Map? get child; @@ -95,8 +95,8 @@ abstract mixin class $StacContainerCopyWith<$Res> { StacBoxDecoration? decoration, StacBoxDecoration? foregroundDecoration, String? color, - double? width, - double? height, + StacDouble? width, + StacDouble? height, StacBoxConstraints? constraints, StacEdgeInsets? margin, Map? child, @@ -158,11 +158,11 @@ class _$StacContainerCopyWithImpl<$Res> width: freezed == width ? _self.width : width // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, height: freezed == height ? _self.height : height // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, constraints: freezed == constraints ? _self.constraints : constraints // ignore: cast_nullable_to_non_nullable @@ -284,9 +284,9 @@ class _StacContainer implements StacContainer { @override final String? color; @override - final double? width; + final StacDouble? width; @override - final double? height; + final StacDouble? height; @override final StacBoxConstraints? constraints; @override @@ -379,8 +379,8 @@ abstract mixin class _$StacContainerCopyWith<$Res> StacBoxDecoration? decoration, StacBoxDecoration? foregroundDecoration, String? color, - double? width, - double? height, + StacDouble? width, + StacDouble? height, StacBoxConstraints? constraints, StacEdgeInsets? margin, Map? child, @@ -447,11 +447,11 @@ class __$StacContainerCopyWithImpl<$Res> width: freezed == width ? _self.width : width // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, height: freezed == height ? _self.height : height // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, constraints: freezed == constraints ? _self.constraints : constraints // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_container/stac_container.g.dart b/packages/stac/lib/src/parsers/widgets/stac_container/stac_container.g.dart index 1d4d6b67..545118bf 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_container/stac_container.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_container/stac_container.g.dart @@ -21,8 +21,9 @@ _StacContainer _$StacContainerFromJson(Map json) => : StacBoxDecoration.fromJson( json['foregroundDecoration'] as Map), color: json['color'] as String?, - width: (json['width'] as num?)?.toDouble(), - height: (json['height'] as num?)?.toDouble(), + width: json['width'] == null ? null : StacDouble.fromJson(json['width']), + height: + json['height'] == null ? null : StacDouble.fromJson(json['height']), constraints: json['constraints'] == null ? null : StacBoxConstraints.fromJson( diff --git a/packages/stac/lib/src/parsers/widgets/stac_container/stac_container_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_container/stac_container_parser.dart index ef50f3f3..916a9bb9 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_container/stac_container_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_container/stac_container_parser.dart @@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart'; import 'package:stac/src/framework/framework.dart'; import 'package:stac/src/parsers/widgets/stac_box_constraints/stac_box_constraints.dart'; import 'package:stac/src/parsers/widgets/stac_box_decoration/stac_box_decoration.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; import 'package:stac/src/utils/color_utils.dart'; import 'package:stac/src/utils/widget_type.dart'; @@ -27,8 +28,8 @@ class StacContainerParser extends StacParser { color: model.color?.toColor(context), decoration: model.decoration?.parse(context), foregroundDecoration: model.foregroundDecoration?.parse(context), - width: model.width, - height: model.height, + width: model.width?.parse, + height: model.height?.parse, constraints: model.constraints?.parse, margin: model.margin?.parse, clipBehavior: model.clipBehavior, diff --git a/packages/stac/lib/src/parsers/widgets/stac_custom_scroll_view/stac_custom_scroll_view.dart b/packages/stac/lib/src/parsers/widgets/stac_custom_scroll_view/stac_custom_scroll_view.dart index 219ca8c5..2cd67b3b 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_custom_scroll_view/stac_custom_scroll_view.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_custom_scroll_view/stac_custom_scroll_view.dart @@ -1,6 +1,7 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/stac_scroll_physics.dart'; export 'package:stac/src/parsers/widgets/stac_custom_scroll_view/stac_custom_scroll_view_parser.dart'; @@ -17,8 +18,8 @@ abstract class StacCustomScrollView with _$StacCustomScrollView { bool? primary, StacScrollPhysics? physics, @Default(false) bool shrinkWrap, - @Default(0.0) double anchor, - double? cacheExtent, + @Default(StacDouble.zero) StacDouble anchor, + StacDouble? cacheExtent, int? semanticChildCount, @Default(DragStartBehavior.start) DragStartBehavior dragStartBehavior, @Default(ScrollViewKeyboardDismissBehavior.manual) diff --git a/packages/stac/lib/src/parsers/widgets/stac_custom_scroll_view/stac_custom_scroll_view.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_custom_scroll_view/stac_custom_scroll_view.freezed.dart index cd5478fe..617a7619 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_custom_scroll_view/stac_custom_scroll_view.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_custom_scroll_view/stac_custom_scroll_view.freezed.dart @@ -21,8 +21,8 @@ mixin _$StacCustomScrollView { bool? get primary; StacScrollPhysics? get physics; bool get shrinkWrap; - double get anchor; - double? get cacheExtent; + StacDouble get anchor; + StacDouble? get cacheExtent; int? get semanticChildCount; DragStartBehavior get dragStartBehavior; ScrollViewKeyboardDismissBehavior get keyboardDismissBehavior; @@ -110,8 +110,8 @@ abstract mixin class $StacCustomScrollViewCopyWith<$Res> { bool? primary, StacScrollPhysics? physics, bool shrinkWrap, - double anchor, - double? cacheExtent, + StacDouble anchor, + StacDouble? cacheExtent, int? semanticChildCount, DragStartBehavior dragStartBehavior, ScrollViewKeyboardDismissBehavior keyboardDismissBehavior, @@ -176,11 +176,11 @@ class _$StacCustomScrollViewCopyWithImpl<$Res> anchor: null == anchor ? _self.anchor : anchor // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, cacheExtent: freezed == cacheExtent ? _self.cacheExtent : cacheExtent // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, semanticChildCount: freezed == semanticChildCount ? _self.semanticChildCount : semanticChildCount // ignore: cast_nullable_to_non_nullable @@ -219,7 +219,7 @@ class _StacCustomScrollView implements StacCustomScrollView { this.primary, this.physics, this.shrinkWrap = false, - this.anchor = 0.0, + this.anchor = StacDouble.zero, this.cacheExtent, this.semanticChildCount, this.dragStartBehavior = DragStartBehavior.start, @@ -255,9 +255,9 @@ class _StacCustomScrollView implements StacCustomScrollView { final bool shrinkWrap; @override @JsonKey() - final double anchor; + final StacDouble anchor; @override - final double? cacheExtent; + final StacDouble? cacheExtent; @override final int? semanticChildCount; @override @@ -362,8 +362,8 @@ abstract mixin class _$StacCustomScrollViewCopyWith<$Res> bool? primary, StacScrollPhysics? physics, bool shrinkWrap, - double anchor, - double? cacheExtent, + StacDouble anchor, + StacDouble? cacheExtent, int? semanticChildCount, DragStartBehavior dragStartBehavior, ScrollViewKeyboardDismissBehavior keyboardDismissBehavior, @@ -428,11 +428,11 @@ class __$StacCustomScrollViewCopyWithImpl<$Res> anchor: null == anchor ? _self.anchor : anchor // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, cacheExtent: freezed == cacheExtent ? _self.cacheExtent : cacheExtent // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, semanticChildCount: freezed == semanticChildCount ? _self.semanticChildCount : semanticChildCount // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_custom_scroll_view/stac_custom_scroll_view.g.dart b/packages/stac/lib/src/parsers/widgets/stac_custom_scroll_view/stac_custom_scroll_view.g.dart index d2e17d23..f3b65e9a 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_custom_scroll_view/stac_custom_scroll_view.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_custom_scroll_view/stac_custom_scroll_view.g.dart @@ -20,8 +20,12 @@ _StacCustomScrollView _$StacCustomScrollViewFromJson( primary: json['primary'] as bool?, physics: $enumDecodeNullable(_$StacScrollPhysicsEnumMap, json['physics']), shrinkWrap: json['shrinkWrap'] as bool? ?? false, - anchor: (json['anchor'] as num?)?.toDouble() ?? 0.0, - cacheExtent: (json['cacheExtent'] as num?)?.toDouble(), + anchor: json['anchor'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['anchor']), + cacheExtent: json['cacheExtent'] == null + ? null + : StacDouble.fromJson(json['cacheExtent']), semanticChildCount: (json['semanticChildCount'] as num?)?.toInt(), dragStartBehavior: $enumDecodeNullable( _$DragStartBehaviorEnumMap, json['dragStartBehavior']) ?? diff --git a/packages/stac/lib/src/parsers/widgets/stac_custom_scroll_view/stac_custom_scroll_view_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_custom_scroll_view/stac_custom_scroll_view_parser.dart index f17fee0a..c868c816 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_custom_scroll_view/stac_custom_scroll_view_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_custom_scroll_view/stac_custom_scroll_view_parser.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac/stac.dart'; @@ -22,8 +23,8 @@ class StacCustomScrollViewParser extends StacParser { primary: model.primary, physics: model.physics?.parse, shrinkWrap: model.shrinkWrap, - anchor: model.anchor, - cacheExtent: model.cacheExtent, + anchor: model.anchor.parse, + cacheExtent: model.cacheExtent?.parse, semanticChildCount: model.semanticChildCount, dragStartBehavior: model.dragStartBehavior, keyboardDismissBehavior: model.keyboardDismissBehavior, diff --git a/packages/stac/lib/src/parsers/widgets/stac_decoration_image/stac_decoration_image.dart b/packages/stac/lib/src/parsers/widgets/stac_decoration_image/stac_decoration_image.dart index 827fd545..deb4195f 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_decoration_image/stac_decoration_image.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_decoration_image/stac_decoration_image.dart @@ -2,6 +2,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_rect/stac_rect.dart'; import 'package:stac/stac.dart'; @@ -20,8 +21,8 @@ abstract class StacDecorationImage with _$StacDecorationImage { StacRect? centerSlice, @Default(ImageRepeat.noRepeat) ImageRepeat repeat, @Default(false) bool matchTextDirection, - @Default(1.0) double scale, - @Default(1.0) double opacity, + @Default(StacDouble(1.0)) StacDouble scale, + @Default(StacDouble(1.0)) StacDouble opacity, @Default(FilterQuality.low) FilterQuality filterQuality, @Default(false) bool invertColors, @Default(false) bool isAntiAlias, @@ -57,8 +58,8 @@ extension StacDecorationImageParser on StacDecorationImage? { centerSlice: this?.centerSlice?.parse, repeat: this?.repeat ?? ImageRepeat.noRepeat, matchTextDirection: this?.matchTextDirection ?? false, - scale: this?.scale ?? 1.0, - opacity: this?.opacity ?? 1.0, + scale: this?.scale.parse ?? 1.0, + opacity: this?.opacity.parse ?? 1.0, filterQuality: this?.filterQuality ?? FilterQuality.low, invertColors: this?.invertColors ?? false, isAntiAlias: this?.isAntiAlias ?? false, diff --git a/packages/stac/lib/src/parsers/widgets/stac_decoration_image/stac_decoration_image.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_decoration_image/stac_decoration_image.freezed.dart index ed744b44..652182f8 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_decoration_image/stac_decoration_image.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_decoration_image/stac_decoration_image.freezed.dart @@ -22,8 +22,8 @@ mixin _$StacDecorationImage { StacRect? get centerSlice; ImageRepeat get repeat; bool get matchTextDirection; - double get scale; - double get opacity; + StacDouble get scale; + StacDouble get opacity; FilterQuality get filterQuality; bool get invertColors; bool get isAntiAlias; @@ -102,8 +102,8 @@ abstract mixin class $StacDecorationImageCopyWith<$Res> { StacRect? centerSlice, ImageRepeat repeat, bool matchTextDirection, - double scale, - double opacity, + StacDouble scale, + StacDouble opacity, FilterQuality filterQuality, bool invertColors, bool isAntiAlias}); @@ -169,11 +169,11 @@ class _$StacDecorationImageCopyWithImpl<$Res> scale: null == scale ? _self.scale : scale // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, opacity: null == opacity ? _self.opacity : opacity // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, filterQuality: null == filterQuality ? _self.filterQuality : filterQuality // ignore: cast_nullable_to_non_nullable @@ -215,8 +215,8 @@ class _StacDecorationImage implements StacDecorationImage { this.centerSlice, this.repeat = ImageRepeat.noRepeat, this.matchTextDirection = false, - this.scale = 1.0, - this.opacity = 1.0, + this.scale = const StacDouble(1.0), + this.opacity = const StacDouble(1.0), this.filterQuality = FilterQuality.low, this.invertColors = false, this.isAntiAlias = false}); @@ -243,10 +243,10 @@ class _StacDecorationImage implements StacDecorationImage { final bool matchTextDirection; @override @JsonKey() - final double scale; + final StacDouble scale; @override @JsonKey() - final double opacity; + final StacDouble opacity; @override @JsonKey() final FilterQuality filterQuality; @@ -338,8 +338,8 @@ abstract mixin class _$StacDecorationImageCopyWith<$Res> StacRect? centerSlice, ImageRepeat repeat, bool matchTextDirection, - double scale, - double opacity, + StacDouble scale, + StacDouble opacity, FilterQuality filterQuality, bool invertColors, bool isAntiAlias}); @@ -406,11 +406,11 @@ class __$StacDecorationImageCopyWithImpl<$Res> scale: null == scale ? _self.scale : scale // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, opacity: null == opacity ? _self.opacity : opacity // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, filterQuality: null == filterQuality ? _self.filterQuality : filterQuality // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_decoration_image/stac_decoration_image.g.dart b/packages/stac/lib/src/parsers/widgets/stac_decoration_image/stac_decoration_image.g.dart index c7f8d58b..f846df3c 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_decoration_image/stac_decoration_image.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_decoration_image/stac_decoration_image.g.dart @@ -22,8 +22,12 @@ _StacDecorationImage _$StacDecorationImageFromJson(Map json) => repeat: $enumDecodeNullable(_$ImageRepeatEnumMap, json['repeat']) ?? ImageRepeat.noRepeat, matchTextDirection: json['matchTextDirection'] as bool? ?? false, - scale: (json['scale'] as num?)?.toDouble() ?? 1.0, - opacity: (json['opacity'] as num?)?.toDouble() ?? 1.0, + scale: json['scale'] == null + ? const StacDouble(1.0) + : StacDouble.fromJson(json['scale']), + opacity: json['opacity'] == null + ? const StacDouble(1.0) + : StacDouble.fromJson(json['opacity']), filterQuality: $enumDecodeNullable(_$FilterQualityEnumMap, json['filterQuality']) ?? FilterQuality.low, diff --git a/packages/stac/lib/src/parsers/widgets/stac_divider/stac_divider.dart b/packages/stac/lib/src/parsers/widgets/stac_divider/stac_divider.dart index a8410fc7..4d6c0776 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_divider/stac_divider.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_divider/stac_divider.dart @@ -1,4 +1,5 @@ import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; export 'stac_divider_parser.dart'; @@ -8,8 +9,8 @@ part 'stac_divider.g.dart'; @freezed abstract class StacDivider with _$StacDivider { const factory StacDivider({ - double? thickness, - double? height, + StacDouble? thickness, + StacDouble? height, String? color, }) = _StacDivider; diff --git a/packages/stac/lib/src/parsers/widgets/stac_divider/stac_divider.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_divider/stac_divider.freezed.dart index 1b070040..ba7ee37d 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_divider/stac_divider.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_divider/stac_divider.freezed.dart @@ -15,8 +15,8 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacDivider { - double? get thickness; - double? get height; + StacDouble? get thickness; + StacDouble? get height; String? get color; /// Create a copy of StacDivider @@ -56,7 +56,7 @@ abstract mixin class $StacDividerCopyWith<$Res> { StacDivider value, $Res Function(StacDivider) _then) = _$StacDividerCopyWithImpl; @useResult - $Res call({double? thickness, double? height, String? color}); + $Res call({StacDouble? thickness, StacDouble? height, String? color}); } /// @nodoc @@ -79,11 +79,11 @@ class _$StacDividerCopyWithImpl<$Res> implements $StacDividerCopyWith<$Res> { thickness: freezed == thickness ? _self.thickness : thickness // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, height: freezed == height ? _self.height : height // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, color: freezed == color ? _self.color : color // ignore: cast_nullable_to_non_nullable @@ -100,9 +100,9 @@ class _StacDivider implements StacDivider { _$StacDividerFromJson(json); @override - final double? thickness; + final StacDouble? thickness; @override - final double? height; + final StacDouble? height; @override final String? color; @@ -150,7 +150,7 @@ abstract mixin class _$StacDividerCopyWith<$Res> __$StacDividerCopyWithImpl; @override @useResult - $Res call({double? thickness, double? height, String? color}); + $Res call({StacDouble? thickness, StacDouble? height, String? color}); } /// @nodoc @@ -173,11 +173,11 @@ class __$StacDividerCopyWithImpl<$Res> implements _$StacDividerCopyWith<$Res> { thickness: freezed == thickness ? _self.thickness : thickness // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, height: freezed == height ? _self.height : height // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, color: freezed == color ? _self.color : color // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_divider/stac_divider.g.dart b/packages/stac/lib/src/parsers/widgets/stac_divider/stac_divider.g.dart index 84e91bdf..ff7d018b 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_divider/stac_divider.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_divider/stac_divider.g.dart @@ -7,8 +7,11 @@ part of 'stac_divider.dart'; // ************************************************************************** _StacDivider _$StacDividerFromJson(Map json) => _StacDivider( - thickness: (json['thickness'] as num?)?.toDouble(), - height: (json['height'] as num?)?.toDouble(), + thickness: json['thickness'] == null + ? null + : StacDouble.fromJson(json['thickness']), + height: + json['height'] == null ? null : StacDouble.fromJson(json['height']), color: json['color'] as String?, ); diff --git a/packages/stac/lib/src/parsers/widgets/stac_divider/stac_divider_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_divider/stac_divider_parser.dart index c904b13a..db6696b6 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_divider/stac_divider_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_divider/stac_divider_parser.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac/stac.dart'; @@ -13,9 +14,9 @@ class StacDividerParser extends StacParser { @override Widget parse(BuildContext context, StacDivider model) { return Divider( - thickness: model.thickness, + thickness: model.thickness?.parse, color: model.color.toColor(context), - height: model.height, + height: model.height?.parse, ); } diff --git a/packages/stac/lib/src/parsers/widgets/stac_double/stac_double.dart b/packages/stac/lib/src/parsers/widgets/stac_double/stac_double.dart new file mode 100644 index 00000000..c2ec04fb --- /dev/null +++ b/packages/stac/lib/src/parsers/widgets/stac_double/stac_double.dart @@ -0,0 +1,68 @@ +class StacDouble { + final double _value; + + const StacDouble(this._value); + + static const StacDouble zero = StacDouble(0); + static const StacDouble infinity = StacDouble(double.infinity); + static const StacDouble maxFinite = StacDouble(double.maxFinite); + static const StacDouble minPositive = StacDouble(double.minPositive); + static const StacDouble nan = StacDouble(double.nan); + static const StacDouble negativeInfinity = + StacDouble(double.negativeInfinity); + + factory StacDouble.fromJson(dynamic json) => _fromJson(json); + + static StacDouble _fromJson(dynamic json) { + if (json is num) { + return StacDouble(json.toDouble()); + } else if (json is String) { + return StacDouble(json.parseDouble()); + } + throw ("Unsupported StacDouble value"); + } + + dynamic toJson() { + if (_value == double.infinity) { + return "infinity"; + } else if (_value == double.negativeInfinity) { + return "negativeInfinity"; + } else if (_value.isNaN) { + return "nan"; + } else if (_value == double.minPositive) { + return "minPositive"; + } else if (_value == double.maxFinite) { + return "maxFinite"; + } + return _value; + } +} + +extension StacDoubleParser on StacDouble { + double get parse { + return _value.toDouble(); + } +} + +extension on String { + double parseDouble() { + try { + switch (this) { + case "infinity": + return double.infinity; + case "negativeInfinity": + return double.negativeInfinity; + case "nan": + return double.nan; + case "minPositive": + return double.minPositive; + case "maxFinite": + return double.maxFinite; + default: + return double.parse(this); + } + } catch (e) { + throw ("Error parsing double: $this"); + } + } +} diff --git a/packages/stac/lib/src/parsers/widgets/stac_dropdown_menu/stac_dropdown_menu.dart b/packages/stac/lib/src/parsers/widgets/stac_dropdown_menu/stac_dropdown_menu.dart index 9e58da6a..eef54375 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_dropdown_menu/stac_dropdown_menu.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_dropdown_menu/stac_dropdown_menu.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:stac/src/parsers/parsers.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_offset/stac_offset.dart'; import 'package:stac/src/utils/text_input_utils.dart'; @@ -13,8 +14,8 @@ part 'stac_dropdown_menu.g.dart'; abstract class StacDropdownMenu with _$StacDropdownMenu { const factory StacDropdownMenu({ @Default(true) bool enabled, - double? width, - double? menuHeight, + StacDouble? width, + StacDouble? menuHeight, Map? leadingIcon, Map? trailingIcon, Map? label, diff --git a/packages/stac/lib/src/parsers/widgets/stac_dropdown_menu/stac_dropdown_menu.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_dropdown_menu/stac_dropdown_menu.freezed.dart index bb3e771c..64d3b89b 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_dropdown_menu/stac_dropdown_menu.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_dropdown_menu/stac_dropdown_menu.freezed.dart @@ -16,8 +16,8 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacDropdownMenu { bool get enabled; - double? get width; - double? get menuHeight; + StacDouble? get width; + StacDouble? get menuHeight; Map? get leadingIcon; Map? get trailingIcon; Map? get label; @@ -143,8 +143,8 @@ abstract mixin class $StacDropdownMenuCopyWith<$Res> { @useResult $Res call( {bool enabled, - double? width, - double? menuHeight, + StacDouble? width, + StacDouble? menuHeight, Map? leadingIcon, Map? trailingIcon, Map? label, @@ -217,11 +217,11 @@ class _$StacDropdownMenuCopyWithImpl<$Res> width: freezed == width ? _self.width : width // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, menuHeight: freezed == menuHeight ? _self.menuHeight : menuHeight // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, leadingIcon: freezed == leadingIcon ? _self.leadingIcon : leadingIcon // ignore: cast_nullable_to_non_nullable @@ -403,9 +403,9 @@ class _StacDropdownMenu implements StacDropdownMenu { @JsonKey() final bool enabled; @override - final double? width; + final StacDouble? width; @override - final double? menuHeight; + final StacDouble? menuHeight; final Map? _leadingIcon; @override Map? get leadingIcon { @@ -607,8 +607,8 @@ abstract mixin class _$StacDropdownMenuCopyWith<$Res> @useResult $Res call( {bool enabled, - double? width, - double? menuHeight, + StacDouble? width, + StacDouble? menuHeight, Map? leadingIcon, Map? trailingIcon, Map? label, @@ -685,11 +685,11 @@ class __$StacDropdownMenuCopyWithImpl<$Res> width: freezed == width ? _self.width : width // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, menuHeight: freezed == menuHeight ? _self.menuHeight : menuHeight // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, leadingIcon: freezed == leadingIcon ? _self._leadingIcon : leadingIcon // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_dropdown_menu/stac_dropdown_menu.g.dart b/packages/stac/lib/src/parsers/widgets/stac_dropdown_menu/stac_dropdown_menu.g.dart index 3c41bb7e..cf337f0c 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_dropdown_menu/stac_dropdown_menu.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_dropdown_menu/stac_dropdown_menu.g.dart @@ -9,8 +9,10 @@ part of 'stac_dropdown_menu.dart'; _StacDropdownMenu _$StacDropdownMenuFromJson(Map json) => _StacDropdownMenu( enabled: json['enabled'] as bool? ?? true, - width: (json['width'] as num?)?.toDouble(), - menuHeight: (json['menuHeight'] as num?)?.toDouble(), + width: json['width'] == null ? null : StacDouble.fromJson(json['width']), + menuHeight: json['menuHeight'] == null + ? null + : StacDouble.fromJson(json['menuHeight']), leadingIcon: json['leadingIcon'] as Map?, trailingIcon: json['trailingIcon'] as Map?, label: json['label'] as Map?, diff --git a/packages/stac/lib/src/parsers/widgets/stac_dropdown_menu/stac_dropdown_menu_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_dropdown_menu/stac_dropdown_menu_parser.dart index f6e4c4de..2be8d85e 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_dropdown_menu/stac_dropdown_menu_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_dropdown_menu/stac_dropdown_menu_parser.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; import 'package:stac/src/parsers/theme/stac_input_decoration_theme/stac_input_decoration_theme.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_dropdown_menu/stac_dropdown_menu.dart'; import 'package:stac/src/parsers/widgets/stac_dropdown_menu_entry/stac_dropdown_menu_entry.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; @@ -57,8 +58,8 @@ class _DropDownMenuWidgetState extends State<_DropDownMenuWidget> { dropDownMenu.parse(context)!) .toList(), enabled: model.enabled, - width: model.width, - menuHeight: model.menuHeight, + width: model.width?.parse, + menuHeight: model.menuHeight?.parse, leadingIcon: Stac.fromJson(model.leadingIcon, context), trailingIcon: Stac.fromJson(model.trailingIcon, context), label: Stac.fromJson(model.label, context), diff --git a/packages/stac/lib/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart b/packages/stac/lib/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart index 76cc8031..5f256b04 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; part 'stac_edge_insets.freezed.dart'; part 'stac_edge_insets.g.dart'; @@ -7,10 +8,10 @@ part 'stac_edge_insets.g.dart'; @freezed abstract class StacEdgeInsets with _$StacEdgeInsets { const factory StacEdgeInsets({ - double? left, - double? top, - double? right, - double? bottom, + StacDouble? left, + StacDouble? top, + StacDouble? right, + StacDouble? bottom, }) = _StacEdgeInsets; factory StacEdgeInsets.fromJson(dynamic json) => _fromJson(json); @@ -49,10 +50,10 @@ abstract class StacEdgeInsets with _$StacEdgeInsets { extension StacEdgeInsetsParser on StacEdgeInsets? { EdgeInsets get parse { return EdgeInsets.only( - left: this?.left ?? 0, - right: this?.right ?? 0, - top: this?.top ?? 0, - bottom: this?.bottom ?? 0, + left: this?.left?.parse ?? 0, + right: this?.right?.parse ?? 0, + top: this?.top?.parse ?? 0, + bottom: this?.bottom?.parse ?? 0, ); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_edge_insets/stac_edge_insets.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_edge_insets/stac_edge_insets.freezed.dart index 4073f02a..2b3b9055 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_edge_insets/stac_edge_insets.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_edge_insets/stac_edge_insets.freezed.dart @@ -15,10 +15,10 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacEdgeInsets { - double? get left; - double? get top; - double? get right; - double? get bottom; + StacDouble? get left; + StacDouble? get top; + StacDouble? get right; + StacDouble? get bottom; /// Create a copy of StacEdgeInsets /// with the given fields replaced by the non-null parameter values. @@ -58,7 +58,11 @@ abstract mixin class $StacEdgeInsetsCopyWith<$Res> { StacEdgeInsets value, $Res Function(StacEdgeInsets) _then) = _$StacEdgeInsetsCopyWithImpl; @useResult - $Res call({double? left, double? top, double? right, double? bottom}); + $Res call( + {StacDouble? left, + StacDouble? top, + StacDouble? right, + StacDouble? bottom}); } /// @nodoc @@ -83,19 +87,19 @@ class _$StacEdgeInsetsCopyWithImpl<$Res> left: freezed == left ? _self.left : left // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, top: freezed == top ? _self.top : top // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, right: freezed == right ? _self.right : right // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, bottom: freezed == bottom ? _self.bottom : bottom // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, )); } } @@ -108,13 +112,13 @@ class _StacEdgeInsets implements StacEdgeInsets { _$StacEdgeInsetsFromJson(json); @override - final double? left; + final StacDouble? left; @override - final double? top; + final StacDouble? top; @override - final double? right; + final StacDouble? right; @override - final double? bottom; + final StacDouble? bottom; /// Create a copy of StacEdgeInsets /// with the given fields replaced by the non-null parameter values. @@ -160,7 +164,11 @@ abstract mixin class _$StacEdgeInsetsCopyWith<$Res> __$StacEdgeInsetsCopyWithImpl; @override @useResult - $Res call({double? left, double? top, double? right, double? bottom}); + $Res call( + {StacDouble? left, + StacDouble? top, + StacDouble? right, + StacDouble? bottom}); } /// @nodoc @@ -185,19 +193,19 @@ class __$StacEdgeInsetsCopyWithImpl<$Res> left: freezed == left ? _self.left : left // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, top: freezed == top ? _self.top : top // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, right: freezed == right ? _self.right : right // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, bottom: freezed == bottom ? _self.bottom : bottom // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, )); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_edge_insets/stac_edge_insets.g.dart b/packages/stac/lib/src/parsers/widgets/stac_edge_insets/stac_edge_insets.g.dart index dc080fbf..350e368c 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_edge_insets/stac_edge_insets.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_edge_insets/stac_edge_insets.g.dart @@ -8,10 +8,11 @@ part of 'stac_edge_insets.dart'; _StacEdgeInsets _$StacEdgeInsetsFromJson(Map json) => _StacEdgeInsets( - left: (json['left'] as num?)?.toDouble(), - top: (json['top'] as num?)?.toDouble(), - right: (json['right'] as num?)?.toDouble(), - bottom: (json['bottom'] as num?)?.toDouble(), + left: json['left'] == null ? null : StacDouble.fromJson(json['left']), + top: json['top'] == null ? null : StacDouble.fromJson(json['top']), + right: json['right'] == null ? null : StacDouble.fromJson(json['right']), + bottom: + json['bottom'] == null ? null : StacDouble.fromJson(json['bottom']), ); Map _$StacEdgeInsetsToJson(_StacEdgeInsets instance) => diff --git a/packages/stac/lib/src/parsers/widgets/stac_floating_action_button/stac_floating_action_button.dart b/packages/stac/lib/src/parsers/widgets/stac_floating_action_button/stac_floating_action_button.dart index 28843a38..f9be9993 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_floating_action_button/stac_floating_action_button.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_floating_action_button/stac_floating_action_button.dart @@ -1,4 +1,5 @@ import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_text_style/stac_text_style.dart'; import 'package:stac/src/utils/button_utils.dart'; @@ -22,12 +23,12 @@ abstract class StacFloatingActionButton with _$StacFloatingActionButton { String? hoverColor, String? splashColor, StacTextStyle? extendedTextStyle, - double? elevation, - double? focusElevation, - double? hoverElevation, - double? disabledElevation, - double? highlightElevation, - double? extendedIconLabelSpacing, + StacDouble? elevation, + StacDouble? focusElevation, + StacDouble? hoverElevation, + StacDouble? disabledElevation, + StacDouble? highlightElevation, + StacDouble? extendedIconLabelSpacing, bool? enableFeedback, String? tooltip, Object? heroTag, diff --git a/packages/stac/lib/src/parsers/widgets/stac_floating_action_button/stac_floating_action_button.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_floating_action_button/stac_floating_action_button.freezed.dart index 631b30a6..65833622 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_floating_action_button/stac_floating_action_button.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_floating_action_button/stac_floating_action_button.freezed.dart @@ -26,12 +26,12 @@ mixin _$StacFloatingActionButton { String? get hoverColor; String? get splashColor; StacTextStyle? get extendedTextStyle; - double? get elevation; - double? get focusElevation; - double? get hoverElevation; - double? get disabledElevation; - double? get highlightElevation; - double? get extendedIconLabelSpacing; + StacDouble? get elevation; + StacDouble? get focusElevation; + StacDouble? get hoverElevation; + StacDouble? get disabledElevation; + StacDouble? get highlightElevation; + StacDouble? get extendedIconLabelSpacing; bool? get enableFeedback; String? get tooltip; Object? get heroTag; @@ -144,12 +144,12 @@ abstract mixin class $StacFloatingActionButtonCopyWith<$Res> { String? hoverColor, String? splashColor, StacTextStyle? extendedTextStyle, - double? elevation, - double? focusElevation, - double? hoverElevation, - double? disabledElevation, - double? highlightElevation, - double? extendedIconLabelSpacing, + StacDouble? elevation, + StacDouble? focusElevation, + StacDouble? hoverElevation, + StacDouble? disabledElevation, + StacDouble? highlightElevation, + StacDouble? extendedIconLabelSpacing, bool? enableFeedback, String? tooltip, Object? heroTag, @@ -242,27 +242,27 @@ class _$StacFloatingActionButtonCopyWithImpl<$Res> elevation: freezed == elevation ? _self.elevation : elevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, focusElevation: freezed == focusElevation ? _self.focusElevation : focusElevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, hoverElevation: freezed == hoverElevation ? _self.hoverElevation : hoverElevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, disabledElevation: freezed == disabledElevation ? _self.disabledElevation : disabledElevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, highlightElevation: freezed == highlightElevation ? _self.highlightElevation : highlightElevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, extendedIconLabelSpacing: freezed == extendedIconLabelSpacing ? _self.extendedIconLabelSpacing : extendedIconLabelSpacing // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, enableFeedback: freezed == enableFeedback ? _self.enableFeedback : enableFeedback // ignore: cast_nullable_to_non_nullable @@ -380,17 +380,17 @@ class _StacFloatingActionButton implements StacFloatingActionButton { @override final StacTextStyle? extendedTextStyle; @override - final double? elevation; + final StacDouble? elevation; @override - final double? focusElevation; + final StacDouble? focusElevation; @override - final double? hoverElevation; + final StacDouble? hoverElevation; @override - final double? disabledElevation; + final StacDouble? disabledElevation; @override - final double? highlightElevation; + final StacDouble? highlightElevation; @override - final double? extendedIconLabelSpacing; + final StacDouble? extendedIconLabelSpacing; @override final bool? enableFeedback; @override @@ -520,12 +520,12 @@ abstract mixin class _$StacFloatingActionButtonCopyWith<$Res> String? hoverColor, String? splashColor, StacTextStyle? extendedTextStyle, - double? elevation, - double? focusElevation, - double? hoverElevation, - double? disabledElevation, - double? highlightElevation, - double? extendedIconLabelSpacing, + StacDouble? elevation, + StacDouble? focusElevation, + StacDouble? hoverElevation, + StacDouble? disabledElevation, + StacDouble? highlightElevation, + StacDouble? extendedIconLabelSpacing, bool? enableFeedback, String? tooltip, Object? heroTag, @@ -620,27 +620,27 @@ class __$StacFloatingActionButtonCopyWithImpl<$Res> elevation: freezed == elevation ? _self.elevation : elevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, focusElevation: freezed == focusElevation ? _self.focusElevation : focusElevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, hoverElevation: freezed == hoverElevation ? _self.hoverElevation : hoverElevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, disabledElevation: freezed == disabledElevation ? _self.disabledElevation : disabledElevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, highlightElevation: freezed == highlightElevation ? _self.highlightElevation : highlightElevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, extendedIconLabelSpacing: freezed == extendedIconLabelSpacing ? _self.extendedIconLabelSpacing : extendedIconLabelSpacing // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, enableFeedback: freezed == enableFeedback ? _self.enableFeedback : enableFeedback // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_floating_action_button/stac_floating_action_button.g.dart b/packages/stac/lib/src/parsers/widgets/stac_floating_action_button/stac_floating_action_button.g.dart index 2d30ff1c..46403174 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_floating_action_button/stac_floating_action_button.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_floating_action_button/stac_floating_action_button.g.dart @@ -26,13 +26,24 @@ _StacFloatingActionButton _$StacFloatingActionButtonFromJson( extendedTextStyle: json['extendedTextStyle'] == null ? null : StacTextStyle.fromJson(json['extendedTextStyle']), - elevation: (json['elevation'] as num?)?.toDouble(), - focusElevation: (json['focusElevation'] as num?)?.toDouble(), - hoverElevation: (json['hoverElevation'] as num?)?.toDouble(), - disabledElevation: (json['disabledElevation'] as num?)?.toDouble(), - highlightElevation: (json['highlightElevation'] as num?)?.toDouble(), - extendedIconLabelSpacing: - (json['extendedIconLabelSpacing'] as num?)?.toDouble(), + elevation: json['elevation'] == null + ? null + : StacDouble.fromJson(json['elevation']), + focusElevation: json['focusElevation'] == null + ? null + : StacDouble.fromJson(json['focusElevation']), + hoverElevation: json['hoverElevation'] == null + ? null + : StacDouble.fromJson(json['hoverElevation']), + disabledElevation: json['disabledElevation'] == null + ? null + : StacDouble.fromJson(json['disabledElevation']), + highlightElevation: json['highlightElevation'] == null + ? null + : StacDouble.fromJson(json['highlightElevation']), + extendedIconLabelSpacing: json['extendedIconLabelSpacing'] == null + ? null + : StacDouble.fromJson(json['extendedIconLabelSpacing']), enableFeedback: json['enableFeedback'] as bool?, tooltip: json['tooltip'] as String?, heroTag: json['heroTag'], diff --git a/packages/stac/lib/src/parsers/widgets/stac_floating_action_button/stac_floating_action_button_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_floating_action_button/stac_floating_action_button_parser.dart index 74386b90..6818b4e3 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_floating_action_button/stac_floating_action_button_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_floating_action_button/stac_floating_action_button_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_floating_action_button/stac_floating_action_button.dart'; import 'package:stac/src/parsers/widgets/stac_text_style/stac_text_style.dart'; import 'package:stac/src/utils/button_utils.dart'; @@ -33,12 +34,12 @@ class StacFloatingActionButtonParser hoverColor: model.hoverColor?.toColor(context), splashColor: model.splashColor?.toColor(context), extendedTextStyle: model.extendedTextStyle?.parse(context), - elevation: model.elevation, - focusElevation: model.focusElevation, - hoverElevation: model.hoverElevation, - disabledElevation: model.disabledElevation, - highlightElevation: model.highlightElevation, - extendedIconLabelSpacing: model.extendedIconLabelSpacing, + elevation: model.elevation?.parse, + focusElevation: model.focusElevation?.parse, + hoverElevation: model.hoverElevation?.parse, + disabledElevation: model.disabledElevation?.parse, + highlightElevation: model.highlightElevation?.parse, + extendedIconLabelSpacing: model.extendedIconLabelSpacing?.parse, enableFeedback: model.enableFeedback, autofocus: model.autofocus, tooltip: model.tooltip, @@ -56,11 +57,11 @@ class StacFloatingActionButtonParser focusColor: model.focusColor?.toColor(context), hoverColor: model.hoverColor?.toColor(context), splashColor: model.splashColor?.toColor(context), - elevation: model.elevation, - focusElevation: model.focusElevation, - hoverElevation: model.hoverElevation, - disabledElevation: model.disabledElevation, - highlightElevation: model.highlightElevation, + elevation: model.elevation?.parse, + focusElevation: model.focusElevation?.parse, + hoverElevation: model.hoverElevation?.parse, + disabledElevation: model.disabledElevation?.parse, + highlightElevation: model.highlightElevation?.parse, enableFeedback: model.enableFeedback, autofocus: model.autofocus, tooltip: model.tooltip, @@ -78,11 +79,11 @@ class StacFloatingActionButtonParser focusColor: model.focusColor?.toColor(context), hoverColor: model.hoverColor?.toColor(context), splashColor: model.splashColor?.toColor(context), - elevation: model.elevation, - focusElevation: model.focusElevation, - hoverElevation: model.hoverElevation, - disabledElevation: model.disabledElevation, - highlightElevation: model.highlightElevation, + elevation: model.elevation?.parse, + focusElevation: model.focusElevation?.parse, + hoverElevation: model.hoverElevation?.parse, + disabledElevation: model.disabledElevation?.parse, + highlightElevation: model.highlightElevation?.parse, enableFeedback: model.enableFeedback, autofocus: model.autofocus, tooltip: model.tooltip, @@ -100,11 +101,11 @@ class StacFloatingActionButtonParser focusColor: model.focusColor?.toColor(context), hoverColor: model.hoverColor?.toColor(context), splashColor: model.splashColor?.toColor(context), - elevation: model.elevation, - focusElevation: model.focusElevation, - hoverElevation: model.hoverElevation, - disabledElevation: model.disabledElevation, - highlightElevation: model.highlightElevation, + elevation: model.elevation?.parse, + focusElevation: model.focusElevation?.parse, + hoverElevation: model.hoverElevation?.parse, + disabledElevation: model.disabledElevation?.parse, + highlightElevation: model.highlightElevation?.parse, enableFeedback: model.enableFeedback, autofocus: model.autofocus, tooltip: model.tooltip, diff --git a/packages/stac/lib/src/parsers/widgets/stac_fractionally_sized_box/stac_fractionally_sized_box.dart b/packages/stac/lib/src/parsers/widgets/stac_fractionally_sized_box/stac_fractionally_sized_box.dart index aac0c33e..58d8a618 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_fractionally_sized_box/stac_fractionally_sized_box.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_fractionally_sized_box/stac_fractionally_sized_box.dart @@ -1,4 +1,5 @@ import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/stac.dart'; export 'stac_fractionally_sized_box_parser.dart'; @@ -10,8 +11,8 @@ part 'stac_fractionally_sized_box.g.dart'; abstract class StacFractionallySizedBox with _$StacFractionallySizedBox { const factory StacFractionallySizedBox({ StacAlignment? alignment, - double? widthFactor, - double? heightFactor, + StacDouble? widthFactor, + StacDouble? heightFactor, Map? child, }) = _StacFractionallySizedBox; diff --git a/packages/stac/lib/src/parsers/widgets/stac_fractionally_sized_box/stac_fractionally_sized_box.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_fractionally_sized_box/stac_fractionally_sized_box.freezed.dart index 51c52d75..9de3bd45 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_fractionally_sized_box/stac_fractionally_sized_box.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_fractionally_sized_box/stac_fractionally_sized_box.freezed.dart @@ -16,8 +16,8 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacFractionallySizedBox { StacAlignment? get alignment; - double? get widthFactor; - double? get heightFactor; + StacDouble? get widthFactor; + StacDouble? get heightFactor; Map? get child; /// Create a copy of StacFractionallySizedBox @@ -64,8 +64,8 @@ abstract mixin class $StacFractionallySizedBoxCopyWith<$Res> { @useResult $Res call( {StacAlignment? alignment, - double? widthFactor, - double? heightFactor, + StacDouble? widthFactor, + StacDouble? heightFactor, Map? child}); } @@ -95,11 +95,11 @@ class _$StacFractionallySizedBoxCopyWithImpl<$Res> widthFactor: freezed == widthFactor ? _self.widthFactor : widthFactor // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, heightFactor: freezed == heightFactor ? _self.heightFactor : heightFactor // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, child: freezed == child ? _self.child : child // ignore: cast_nullable_to_non_nullable @@ -123,9 +123,9 @@ class _StacFractionallySizedBox implements StacFractionallySizedBox { @override final StacAlignment? alignment; @override - final double? widthFactor; + final StacDouble? widthFactor; @override - final double? heightFactor; + final StacDouble? heightFactor; final Map? _child; @override Map? get child { @@ -187,8 +187,8 @@ abstract mixin class _$StacFractionallySizedBoxCopyWith<$Res> @useResult $Res call( {StacAlignment? alignment, - double? widthFactor, - double? heightFactor, + StacDouble? widthFactor, + StacDouble? heightFactor, Map? child}); } @@ -218,11 +218,11 @@ class __$StacFractionallySizedBoxCopyWithImpl<$Res> widthFactor: freezed == widthFactor ? _self.widthFactor : widthFactor // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, heightFactor: freezed == heightFactor ? _self.heightFactor : heightFactor // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, child: freezed == child ? _self._child : child // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_fractionally_sized_box/stac_fractionally_sized_box.g.dart b/packages/stac/lib/src/parsers/widgets/stac_fractionally_sized_box/stac_fractionally_sized_box.g.dart index dc765e04..3c54c3af 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_fractionally_sized_box/stac_fractionally_sized_box.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_fractionally_sized_box/stac_fractionally_sized_box.g.dart @@ -10,8 +10,12 @@ _StacFractionallySizedBox _$StacFractionallySizedBoxFromJson( Map json) => _StacFractionallySizedBox( alignment: $enumDecodeNullable(_$StacAlignmentEnumMap, json['alignment']), - widthFactor: (json['widthFactor'] as num?)?.toDouble(), - heightFactor: (json['heightFactor'] as num?)?.toDouble(), + widthFactor: json['widthFactor'] == null + ? null + : StacDouble.fromJson(json['widthFactor']), + heightFactor: json['heightFactor'] == null + ? null + : StacDouble.fromJson(json['heightFactor']), child: json['child'] as Map?, ); diff --git a/packages/stac/lib/src/parsers/widgets/stac_fractionally_sized_box/stac_fractionally_sized_box_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_fractionally_sized_box/stac_fractionally_sized_box_parser.dart index d5688889..ff33f561 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_fractionally_sized_box/stac_fractionally_sized_box_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_fractionally_sized_box/stac_fractionally_sized_box_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; @@ -20,8 +21,8 @@ class StacFractionallySizedBoxParser Widget parse(BuildContext context, StacFractionallySizedBox model) { return FractionallySizedBox( alignment: model.alignment?.value ?? Alignment.center, - widthFactor: model.widthFactor, - heightFactor: model.heightFactor, + widthFactor: model.widthFactor?.parse, + heightFactor: model.heightFactor?.parse, child: Stac.fromJson(model.child, context), ); } diff --git a/packages/stac/lib/src/parsers/widgets/stac_gradient/stac_gradient.dart b/packages/stac/lib/src/parsers/widgets/stac_gradient/stac_gradient.dart index 871cc6bd..69ac67b7 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_gradient/stac_gradient.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_gradient/stac_gradient.dart @@ -3,6 +3,7 @@ import 'dart:math' as math; import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:stac/src/parsers/parsers.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/color_utils.dart'; part 'stac_gradient.freezed.dart'; @@ -14,17 +15,17 @@ enum StacGradientType { linear, radial, sweep } abstract class StacGradient with _$StacGradient { const factory StacGradient({ required List colors, - List? stops, + List? stops, @Default(StacAlignment.centerLeft) StacAlignment begin, @Default(StacAlignment.centerRight) StacAlignment end, @Default(StacAlignment.center) StacAlignment center, @Default(StacGradientType.linear) StacGradientType gradientType, StacAlignmentGeometry? focal, @Default(TileMode.clamp) TileMode tileMode, - @Default(0.0) double focalRadius, - @Default(0.5) double radius, - @Default(0.0) double startAngle, - @Default(math.pi * 2) double endAngle, + @Default(StacDouble.zero) StacDouble focalRadius, + @Default(StacDouble(0.5)) StacDouble radius, + @Default(StacDouble.zero) StacDouble startAngle, + @Default(StacDouble(math.pi * 2)) StacDouble endAngle, }) = _StacGradient; factory StacGradient.fromJson(Map json) => @@ -37,26 +38,26 @@ extension StacGradientParser on StacGradient { colors: colors.map((e) => e.toColor(context)!).toList(), begin: begin.value, end: end.value, - stops: stops, + stops: stops?.map((e) => e.parse).toList().toList(), tileMode: tileMode, ); Gradient radialGradient() => RadialGradient( colors: colors.map((e) => e.toColor(context)!).toList(), - stops: stops, + stops: stops?.map((e) => e.parse).toList().toList(), tileMode: tileMode, focal: focal?.parse, - focalRadius: focalRadius, - radius: radius, + focalRadius: focalRadius.parse, + radius: radius.parse, center: center.value, ); Gradient sweepGradient() => SweepGradient( colors: colors.map((e) => e.toColor(context)!).toList(), - stops: stops, + stops: stops?.map((e) => e.parse).toList().toList(), center: center.value, - startAngle: startAngle, - endAngle: endAngle, + startAngle: startAngle.parse, + endAngle: endAngle.parse, tileMode: tileMode, ); diff --git a/packages/stac/lib/src/parsers/widgets/stac_gradient/stac_gradient.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_gradient/stac_gradient.freezed.dart index d415c5ea..ac6ab222 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_gradient/stac_gradient.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_gradient/stac_gradient.freezed.dart @@ -16,17 +16,17 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacGradient { List get colors; - List? get stops; + List? get stops; StacAlignment get begin; StacAlignment get end; StacAlignment get center; StacGradientType get gradientType; StacAlignmentGeometry? get focal; TileMode get tileMode; - double get focalRadius; - double get radius; - double get startAngle; - double get endAngle; + StacDouble get focalRadius; + StacDouble get radius; + StacDouble get startAngle; + StacDouble get endAngle; /// Create a copy of StacGradient /// with the given fields replaced by the non-null parameter values. @@ -94,17 +94,17 @@ abstract mixin class $StacGradientCopyWith<$Res> { @useResult $Res call( {List colors, - List? stops, + List? stops, StacAlignment begin, StacAlignment end, StacAlignment center, StacGradientType gradientType, StacAlignmentGeometry? focal, TileMode tileMode, - double focalRadius, - double radius, - double startAngle, - double endAngle}); + StacDouble focalRadius, + StacDouble radius, + StacDouble startAngle, + StacDouble endAngle}); $StacAlignmentGeometryCopyWith<$Res>? get focal; } @@ -142,7 +142,7 @@ class _$StacGradientCopyWithImpl<$Res> implements $StacGradientCopyWith<$Res> { stops: freezed == stops ? _self.stops : stops // ignore: cast_nullable_to_non_nullable - as List?, + as List?, begin: null == begin ? _self.begin : begin // ignore: cast_nullable_to_non_nullable @@ -170,19 +170,19 @@ class _$StacGradientCopyWithImpl<$Res> implements $StacGradientCopyWith<$Res> { focalRadius: null == focalRadius ? _self.focalRadius : focalRadius // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, radius: null == radius ? _self.radius : radius // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, startAngle: null == startAngle ? _self.startAngle : startAngle // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, endAngle: null == endAngle ? _self.endAngle : endAngle // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, )); } @@ -206,17 +206,17 @@ class _$StacGradientCopyWithImpl<$Res> implements $StacGradientCopyWith<$Res> { class _StacGradient implements StacGradient { const _StacGradient( {required final List colors, - final List? stops, + final List? stops, this.begin = StacAlignment.centerLeft, this.end = StacAlignment.centerRight, this.center = StacAlignment.center, this.gradientType = StacGradientType.linear, this.focal, this.tileMode = TileMode.clamp, - this.focalRadius = 0.0, - this.radius = 0.5, - this.startAngle = 0.0, - this.endAngle = math.pi * 2}) + this.focalRadius = StacDouble.zero, + this.radius = const StacDouble(0.5), + this.startAngle = StacDouble.zero, + this.endAngle = const StacDouble(math.pi * 2)}) : _colors = colors, _stops = stops; factory _StacGradient.fromJson(Map json) => @@ -230,9 +230,9 @@ class _StacGradient implements StacGradient { return EqualUnmodifiableListView(_colors); } - final List? _stops; + final List? _stops; @override - List? get stops { + List? get stops { final value = _stops; if (value == null) return null; if (_stops is EqualUnmodifiableListView) return _stops; @@ -259,16 +259,16 @@ class _StacGradient implements StacGradient { final TileMode tileMode; @override @JsonKey() - final double focalRadius; + final StacDouble focalRadius; @override @JsonKey() - final double radius; + final StacDouble radius; @override @JsonKey() - final double startAngle; + final StacDouble startAngle; @override @JsonKey() - final double endAngle; + final StacDouble endAngle; /// Create a copy of StacGradient /// with the given fields replaced by the non-null parameter values. @@ -342,17 +342,17 @@ abstract mixin class _$StacGradientCopyWith<$Res> @useResult $Res call( {List colors, - List? stops, + List? stops, StacAlignment begin, StacAlignment end, StacAlignment center, StacGradientType gradientType, StacAlignmentGeometry? focal, TileMode tileMode, - double focalRadius, - double radius, - double startAngle, - double endAngle}); + StacDouble focalRadius, + StacDouble radius, + StacDouble startAngle, + StacDouble endAngle}); @override $StacAlignmentGeometryCopyWith<$Res>? get focal; @@ -392,7 +392,7 @@ class __$StacGradientCopyWithImpl<$Res> stops: freezed == stops ? _self._stops : stops // ignore: cast_nullable_to_non_nullable - as List?, + as List?, begin: null == begin ? _self.begin : begin // ignore: cast_nullable_to_non_nullable @@ -420,19 +420,19 @@ class __$StacGradientCopyWithImpl<$Res> focalRadius: null == focalRadius ? _self.focalRadius : focalRadius // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, radius: null == radius ? _self.radius : radius // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, startAngle: null == startAngle ? _self.startAngle : startAngle // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, endAngle: null == endAngle ? _self.endAngle : endAngle // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, )); } diff --git a/packages/stac/lib/src/parsers/widgets/stac_gradient/stac_gradient.g.dart b/packages/stac/lib/src/parsers/widgets/stac_gradient/stac_gradient.g.dart index aa11457a..352b1966 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_gradient/stac_gradient.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_gradient/stac_gradient.g.dart @@ -10,9 +10,8 @@ _StacGradient _$StacGradientFromJson(Map json) => _StacGradient( colors: (json['colors'] as List).map((e) => e as String).toList(), - stops: (json['stops'] as List?) - ?.map((e) => (e as num).toDouble()) - .toList(), + stops: + (json['stops'] as List?)?.map(StacDouble.fromJson).toList(), begin: $enumDecodeNullable(_$StacAlignmentEnumMap, json['begin']) ?? StacAlignment.centerLeft, end: $enumDecodeNullable(_$StacAlignmentEnumMap, json['end']) ?? @@ -28,10 +27,18 @@ _StacGradient _$StacGradientFromJson(Map json) => json['focal'] as Map), tileMode: $enumDecodeNullable(_$TileModeEnumMap, json['tileMode']) ?? TileMode.clamp, - focalRadius: (json['focalRadius'] as num?)?.toDouble() ?? 0.0, - radius: (json['radius'] as num?)?.toDouble() ?? 0.5, - startAngle: (json['startAngle'] as num?)?.toDouble() ?? 0.0, - endAngle: (json['endAngle'] as num?)?.toDouble() ?? math.pi * 2, + focalRadius: json['focalRadius'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['focalRadius']), + radius: json['radius'] == null + ? const StacDouble(0.5) + : StacDouble.fromJson(json['radius']), + startAngle: json['startAngle'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['startAngle']), + endAngle: json['endAngle'] == null + ? const StacDouble(math.pi * 2) + : StacDouble.fromJson(json['endAngle']), ); Map _$StacGradientToJson(_StacGradient instance) => diff --git a/packages/stac/lib/src/parsers/widgets/stac_grid_view/stac_grid_view.dart b/packages/stac/lib/src/parsers/widgets/stac_grid_view/stac_grid_view.dart index fa42bc13..92d2a4fe 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_grid_view/stac_grid_view.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_grid_view/stac_grid_view.dart @@ -1,6 +1,7 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/stac.dart'; export 'stac_grid_view_parser.dart'; @@ -18,14 +19,14 @@ abstract class StacGridView with _$StacGridView { @Default(false) bool shrinkWrap, StacEdgeInsets? padding, int? crossAxisCount, - @Default(0.0) double mainAxisSpacing, - @Default(0.0) double crossAxisSpacing, - @Default(1.0) double childAspectRatio, - double? mainAxisExtent, + @Default(StacDouble.zero) StacDouble mainAxisSpacing, + @Default(StacDouble.zero) StacDouble crossAxisSpacing, + @Default(StacDouble(1.0)) StacDouble childAspectRatio, + StacDouble? mainAxisExtent, @Default(true) bool addAutomaticKeepAlives, @Default(true) bool addRepaintBoundaries, @Default(true) bool addSemanticIndexes, - double? cacheExtent, + StacDouble? cacheExtent, @Default([]) List> children, int? semanticChildCount, @Default(DragStartBehavior.start) DragStartBehavior dragStartBehavior, diff --git a/packages/stac/lib/src/parsers/widgets/stac_grid_view/stac_grid_view.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_grid_view/stac_grid_view.freezed.dart index 5c3dee9c..fd2c5857 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_grid_view/stac_grid_view.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_grid_view/stac_grid_view.freezed.dart @@ -22,14 +22,14 @@ mixin _$StacGridView { bool get shrinkWrap; StacEdgeInsets? get padding; int? get crossAxisCount; - double get mainAxisSpacing; - double get crossAxisSpacing; - double get childAspectRatio; - double? get mainAxisExtent; + StacDouble get mainAxisSpacing; + StacDouble get crossAxisSpacing; + StacDouble get childAspectRatio; + StacDouble? get mainAxisExtent; bool get addAutomaticKeepAlives; bool get addRepaintBoundaries; bool get addSemanticIndexes; - double? get cacheExtent; + StacDouble? get cacheExtent; List> get children; int? get semanticChildCount; DragStartBehavior get dragStartBehavior; @@ -140,14 +140,14 @@ abstract mixin class $StacGridViewCopyWith<$Res> { bool shrinkWrap, StacEdgeInsets? padding, int? crossAxisCount, - double mainAxisSpacing, - double crossAxisSpacing, - double childAspectRatio, - double? mainAxisExtent, + StacDouble mainAxisSpacing, + StacDouble crossAxisSpacing, + StacDouble childAspectRatio, + StacDouble? mainAxisExtent, bool addAutomaticKeepAlives, bool addRepaintBoundaries, bool addSemanticIndexes, - double? cacheExtent, + StacDouble? cacheExtent, List> children, int? semanticChildCount, DragStartBehavior dragStartBehavior, @@ -224,19 +224,19 @@ class _$StacGridViewCopyWithImpl<$Res> implements $StacGridViewCopyWith<$Res> { mainAxisSpacing: null == mainAxisSpacing ? _self.mainAxisSpacing : mainAxisSpacing // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, crossAxisSpacing: null == crossAxisSpacing ? _self.crossAxisSpacing : crossAxisSpacing // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, childAspectRatio: null == childAspectRatio ? _self.childAspectRatio : childAspectRatio // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, mainAxisExtent: freezed == mainAxisExtent ? _self.mainAxisExtent : mainAxisExtent // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, addAutomaticKeepAlives: null == addAutomaticKeepAlives ? _self.addAutomaticKeepAlives : addAutomaticKeepAlives // ignore: cast_nullable_to_non_nullable @@ -252,7 +252,7 @@ class _$StacGridViewCopyWithImpl<$Res> implements $StacGridViewCopyWith<$Res> { cacheExtent: freezed == cacheExtent ? _self.cacheExtent : cacheExtent // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, children: null == children ? _self.children : children // ignore: cast_nullable_to_non_nullable @@ -306,9 +306,9 @@ class _StacGridView implements StacGridView { this.shrinkWrap = false, this.padding, this.crossAxisCount, - this.mainAxisSpacing = 0.0, - this.crossAxisSpacing = 0.0, - this.childAspectRatio = 1.0, + this.mainAxisSpacing = StacDouble.zero, + this.crossAxisSpacing = StacDouble.zero, + this.childAspectRatio = const StacDouble(1.0), this.mainAxisExtent, this.addAutomaticKeepAlives = true, this.addRepaintBoundaries = true, @@ -344,15 +344,15 @@ class _StacGridView implements StacGridView { final int? crossAxisCount; @override @JsonKey() - final double mainAxisSpacing; + final StacDouble mainAxisSpacing; @override @JsonKey() - final double crossAxisSpacing; + final StacDouble crossAxisSpacing; @override @JsonKey() - final double childAspectRatio; + final StacDouble childAspectRatio; @override - final double? mainAxisExtent; + final StacDouble? mainAxisExtent; @override @JsonKey() final bool addAutomaticKeepAlives; @@ -363,7 +363,7 @@ class _StacGridView implements StacGridView { @JsonKey() final bool addSemanticIndexes; @override - final double? cacheExtent; + final StacDouble? cacheExtent; final List> _children; @override @JsonKey() @@ -496,14 +496,14 @@ abstract mixin class _$StacGridViewCopyWith<$Res> bool shrinkWrap, StacEdgeInsets? padding, int? crossAxisCount, - double mainAxisSpacing, - double crossAxisSpacing, - double childAspectRatio, - double? mainAxisExtent, + StacDouble mainAxisSpacing, + StacDouble crossAxisSpacing, + StacDouble childAspectRatio, + StacDouble? mainAxisExtent, bool addAutomaticKeepAlives, bool addRepaintBoundaries, bool addSemanticIndexes, - double? cacheExtent, + StacDouble? cacheExtent, List> children, int? semanticChildCount, DragStartBehavior dragStartBehavior, @@ -582,19 +582,19 @@ class __$StacGridViewCopyWithImpl<$Res> mainAxisSpacing: null == mainAxisSpacing ? _self.mainAxisSpacing : mainAxisSpacing // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, crossAxisSpacing: null == crossAxisSpacing ? _self.crossAxisSpacing : crossAxisSpacing // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, childAspectRatio: null == childAspectRatio ? _self.childAspectRatio : childAspectRatio // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, mainAxisExtent: freezed == mainAxisExtent ? _self.mainAxisExtent : mainAxisExtent // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, addAutomaticKeepAlives: null == addAutomaticKeepAlives ? _self.addAutomaticKeepAlives : addAutomaticKeepAlives // ignore: cast_nullable_to_non_nullable @@ -610,7 +610,7 @@ class __$StacGridViewCopyWithImpl<$Res> cacheExtent: freezed == cacheExtent ? _self.cacheExtent : cacheExtent // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, children: null == children ? _self._children : children // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_grid_view/stac_grid_view.g.dart b/packages/stac/lib/src/parsers/widgets/stac_grid_view/stac_grid_view.g.dart index 3db11d79..0aed418f 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_grid_view/stac_grid_view.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_grid_view/stac_grid_view.g.dart @@ -19,14 +19,24 @@ _StacGridView _$StacGridViewFromJson(Map json) => ? null : StacEdgeInsets.fromJson(json['padding']), crossAxisCount: (json['crossAxisCount'] as num?)?.toInt(), - mainAxisSpacing: (json['mainAxisSpacing'] as num?)?.toDouble() ?? 0.0, - crossAxisSpacing: (json['crossAxisSpacing'] as num?)?.toDouble() ?? 0.0, - childAspectRatio: (json['childAspectRatio'] as num?)?.toDouble() ?? 1.0, - mainAxisExtent: (json['mainAxisExtent'] as num?)?.toDouble(), + mainAxisSpacing: json['mainAxisSpacing'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['mainAxisSpacing']), + crossAxisSpacing: json['crossAxisSpacing'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['crossAxisSpacing']), + childAspectRatio: json['childAspectRatio'] == null + ? const StacDouble(1.0) + : StacDouble.fromJson(json['childAspectRatio']), + mainAxisExtent: json['mainAxisExtent'] == null + ? null + : StacDouble.fromJson(json['mainAxisExtent']), addAutomaticKeepAlives: json['addAutomaticKeepAlives'] as bool? ?? true, addRepaintBoundaries: json['addRepaintBoundaries'] as bool? ?? true, addSemanticIndexes: json['addSemanticIndexes'] as bool? ?? true, - cacheExtent: (json['cacheExtent'] as num?)?.toDouble(), + cacheExtent: json['cacheExtent'] == null + ? null + : StacDouble.fromJson(json['cacheExtent']), children: (json['children'] as List?) ?.map((e) => e as Map) .toList() ?? diff --git a/packages/stac/lib/src/parsers/widgets/stac_grid_view/stac_grid_view_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_grid_view/stac_grid_view_parser.dart index fb49c171..fc3c26f6 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_grid_view/stac_grid_view_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_grid_view/stac_grid_view_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; import 'package:stac/src/parsers/widgets/stac_grid_view/stac_grid_view.dart'; import 'package:stac/src/utils/widget_type.dart'; @@ -26,14 +27,14 @@ class StacGridViewParser extends StacParser { padding: model.padding.parse, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: model.crossAxisCount ?? 0, - mainAxisSpacing: model.mainAxisSpacing, - crossAxisSpacing: model.crossAxisSpacing, - childAspectRatio: model.childAspectRatio, + mainAxisSpacing: model.mainAxisSpacing.parse, + crossAxisSpacing: model.crossAxisSpacing.parse, + childAspectRatio: model.childAspectRatio.parse, ), addAutomaticKeepAlives: model.addAutomaticKeepAlives, addRepaintBoundaries: model.addRepaintBoundaries, addSemanticIndexes: model.addSemanticIndexes, - cacheExtent: model.cacheExtent, + cacheExtent: model.cacheExtent?.parse, itemBuilder: (context, index) => Stac.fromJson(model.children[index], context), itemCount: model.children.length, diff --git a/packages/stac/lib/src/parsers/widgets/stac_icon/stac_icon.dart b/packages/stac/lib/src/parsers/widgets/stac_icon/stac_icon.dart index 30b9c760..bcb1ee00 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_icon/stac_icon.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_icon/stac_icon.dart @@ -2,6 +2,7 @@ import 'dart:ui'; import 'package:flutter/cupertino.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/icon_utils.dart'; export 'stac_icon_parser.dart'; @@ -14,7 +15,7 @@ abstract class StacIcon with _$StacIcon { const factory StacIcon({ required String icon, @Default(IconType.material) IconType iconType, - double? size, + StacDouble? size, String? color, String? semanticLabel, TextDirection? textDirection, diff --git a/packages/stac/lib/src/parsers/widgets/stac_icon/stac_icon.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_icon/stac_icon.freezed.dart index 2be605ef..d7a1dad2 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_icon/stac_icon.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_icon/stac_icon.freezed.dart @@ -17,7 +17,7 @@ T _$identity(T value) => value; mixin _$StacIcon { String get icon; IconType get iconType; - double? get size; + StacDouble? get size; String? get color; String? get semanticLabel; TextDirection? get textDirection; @@ -67,7 +67,7 @@ abstract mixin class $StacIconCopyWith<$Res> { $Res call( {String icon, IconType iconType, - double? size, + StacDouble? size, String? color, String? semanticLabel, TextDirection? textDirection}); @@ -104,7 +104,7 @@ class _$StacIconCopyWithImpl<$Res> implements $StacIconCopyWith<$Res> { size: freezed == size ? _self.size : size // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, color: freezed == color ? _self.color : color // ignore: cast_nullable_to_non_nullable @@ -140,7 +140,7 @@ class _StacIcon implements StacIcon { @JsonKey() final IconType iconType; @override - final double? size; + final StacDouble? size; @override final String? color; @override @@ -200,7 +200,7 @@ abstract mixin class _$StacIconCopyWith<$Res> $Res call( {String icon, IconType iconType, - double? size, + StacDouble? size, String? color, String? semanticLabel, TextDirection? textDirection}); @@ -237,7 +237,7 @@ class __$StacIconCopyWithImpl<$Res> implements _$StacIconCopyWith<$Res> { size: freezed == size ? _self.size : size // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, color: freezed == color ? _self.color : color // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_icon/stac_icon.g.dart b/packages/stac/lib/src/parsers/widgets/stac_icon/stac_icon.g.dart index d537fcf1..28eb1bc4 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_icon/stac_icon.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_icon/stac_icon.g.dart @@ -10,7 +10,7 @@ _StacIcon _$StacIconFromJson(Map json) => _StacIcon( icon: json['icon'] as String, iconType: $enumDecodeNullable(_$IconTypeEnumMap, json['iconType']) ?? IconType.material, - size: (json['size'] as num?)?.toDouble(), + size: json['size'] == null ? null : StacDouble.fromJson(json['size']), color: json['color'] as String?, semanticLabel: json['semanticLabel'] as String?, textDirection: diff --git a/packages/stac/lib/src/parsers/widgets/stac_icon/stac_icon_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_icon/stac_icon_parser.dart index 3eca3cac..724b2bbc 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_icon/stac_icon_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_icon/stac_icon_parser.dart @@ -1,4 +1,5 @@ import 'package:flutter/cupertino.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/color_utils.dart'; import 'package:stac/src/utils/icon_utils.dart'; import 'package:stac/src/utils/log.dart'; @@ -30,7 +31,7 @@ class StacIconParser extends StacParser { if (iconData != null) { return Icon( iconData, - size: model.size, + size: model.size?.parse, color: model.color.toColor(context), semanticLabel: model.semanticLabel, textDirection: model.textDirection, diff --git a/packages/stac/lib/src/parsers/widgets/stac_icon_button/stac_icon_button.dart b/packages/stac/lib/src/parsers/widgets/stac_icon_button/stac_icon_button.dart index dde58ddf..882b83a2 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_icon_button/stac_icon_button.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_icon_button/stac_icon_button.dart @@ -2,6 +2,7 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:stac/src/parsers/theme/stac_button_style/stac_button_style.dart'; import 'package:stac/src/parsers/widgets/stac_alignment/stac_alignment.dart'; import 'package:stac/src/parsers/widgets/stac_box_constraints/stac_box_constraints.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; export 'stac_icon_button_parser.dart'; @@ -12,10 +13,10 @@ part 'stac_icon_button.g.dart'; @freezed abstract class StacIconButton with _$StacIconButton { const factory StacIconButton({ - double? iconSize, + StacDouble? iconSize, StacEdgeInsets? padding, StacAlignment? alignment, - double? splashRadius, + StacDouble? splashRadius, String? color, String? focusColor, String? hoverColor, diff --git a/packages/stac/lib/src/parsers/widgets/stac_icon_button/stac_icon_button.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_icon_button/stac_icon_button.freezed.dart index 8b7cf54e..e5f8efa2 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_icon_button/stac_icon_button.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_icon_button/stac_icon_button.freezed.dart @@ -15,10 +15,10 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacIconButton { - double? get iconSize; + StacDouble? get iconSize; StacEdgeInsets? get padding; StacAlignment? get alignment; - double? get splashRadius; + StacDouble? get splashRadius; String? get color; String? get focusColor; String? get hoverColor; @@ -123,10 +123,10 @@ abstract mixin class $StacIconButtonCopyWith<$Res> { _$StacIconButtonCopyWithImpl; @useResult $Res call( - {double? iconSize, + {StacDouble? iconSize, StacEdgeInsets? padding, StacAlignment? alignment, - double? splashRadius, + StacDouble? splashRadius, String? color, String? focusColor, String? hoverColor, @@ -185,7 +185,7 @@ class _$StacIconButtonCopyWithImpl<$Res> iconSize: freezed == iconSize ? _self.iconSize : iconSize // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, padding: freezed == padding ? _self.padding : padding // ignore: cast_nullable_to_non_nullable @@ -197,7 +197,7 @@ class _$StacIconButtonCopyWithImpl<$Res> splashRadius: freezed == splashRadius ? _self.splashRadius : splashRadius // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, color: freezed == color ? _self.color : color // ignore: cast_nullable_to_non_nullable @@ -334,13 +334,13 @@ class _StacIconButton implements StacIconButton { _$StacIconButtonFromJson(json); @override - final double? iconSize; + final StacDouble? iconSize; @override final StacEdgeInsets? padding; @override final StacAlignment? alignment; @override - final double? splashRadius; + final StacDouble? splashRadius; @override final String? color; @override @@ -491,10 +491,10 @@ abstract mixin class _$StacIconButtonCopyWith<$Res> @override @useResult $Res call( - {double? iconSize, + {StacDouble? iconSize, StacEdgeInsets? padding, StacAlignment? alignment, - double? splashRadius, + StacDouble? splashRadius, String? color, String? focusColor, String? hoverColor, @@ -556,7 +556,7 @@ class __$StacIconButtonCopyWithImpl<$Res> iconSize: freezed == iconSize ? _self.iconSize : iconSize // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, padding: freezed == padding ? _self.padding : padding // ignore: cast_nullable_to_non_nullable @@ -568,7 +568,7 @@ class __$StacIconButtonCopyWithImpl<$Res> splashRadius: freezed == splashRadius ? _self.splashRadius : splashRadius // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, color: freezed == color ? _self.color : color // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_icon_button/stac_icon_button.g.dart b/packages/stac/lib/src/parsers/widgets/stac_icon_button/stac_icon_button.g.dart index ffd6f72a..e85af1a1 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_icon_button/stac_icon_button.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_icon_button/stac_icon_button.g.dart @@ -8,12 +8,16 @@ part of 'stac_icon_button.dart'; _StacIconButton _$StacIconButtonFromJson(Map json) => _StacIconButton( - iconSize: (json['iconSize'] as num?)?.toDouble(), + iconSize: json['iconSize'] == null + ? null + : StacDouble.fromJson(json['iconSize']), padding: json['padding'] == null ? null : StacEdgeInsets.fromJson(json['padding']), alignment: $enumDecodeNullable(_$StacAlignmentEnumMap, json['alignment']), - splashRadius: (json['splashRadius'] as num?)?.toDouble(), + splashRadius: json['splashRadius'] == null + ? null + : StacDouble.fromJson(json['splashRadius']), color: json['color'] as String?, focusColor: json['focusColor'] as String?, hoverColor: json['hoverColor'] as String?, diff --git a/packages/stac/lib/src/parsers/widgets/stac_icon_button/stac_icon_button_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_icon_button/stac_icon_button_parser.dart index 97fa6e19..ea9646b9 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_icon_button/stac_icon_button_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_icon_button/stac_icon_button_parser.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; import 'package:stac/src/parsers/theme/stac_button_style/stac_button_style.dart'; import 'package:stac/src/parsers/widgets/stac_box_constraints/stac_box_constraints.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; import 'package:stac/src/utils/color_utils.dart'; import 'package:stac/src/utils/widget_type.dart'; @@ -22,10 +23,10 @@ class StacIconButtonParser extends StacParser { @override Widget parse(BuildContext context, StacIconButton model) { return IconButton( - iconSize: model.iconSize, + iconSize: model.iconSize?.parse, padding: model.padding?.parse, alignment: model.alignment?.value, - splashRadius: model.splashRadius, + splashRadius: model.splashRadius?.parse, color: model.color.toColor(context), focusColor: model.focusColor.toColor(context), hoverColor: model.hoverColor.toColor(context), diff --git a/packages/stac/lib/src/parsers/widgets/stac_image/stac_image.dart b/packages/stac/lib/src/parsers/widgets/stac_image/stac_image.dart index c15db0c7..d1a88c69 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_image/stac_image.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_image/stac_image.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:stac/src/parsers/widgets/stac_alignment/stac_alignment.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; export 'stac_image_parser.dart'; @@ -16,8 +17,8 @@ abstract class StacImage with _$StacImage { @Default(StacAlignment.center) StacAlignment alignment, @Default(StacImageType.network) StacImageType imageType, String? color, - double? width, - double? height, + StacDouble? width, + StacDouble? height, BoxFit? fit, }) = _StacImage; diff --git a/packages/stac/lib/src/parsers/widgets/stac_image/stac_image.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_image/stac_image.freezed.dart index 79b08c00..e90687e4 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_image/stac_image.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_image/stac_image.freezed.dart @@ -19,8 +19,8 @@ mixin _$StacImage { StacAlignment get alignment; StacImageType get imageType; String? get color; - double? get width; - double? get height; + StacDouble? get width; + StacDouble? get height; BoxFit? get fit; /// Create a copy of StacImage @@ -70,8 +70,8 @@ abstract mixin class $StacImageCopyWith<$Res> { StacAlignment alignment, StacImageType imageType, String? color, - double? width, - double? height, + StacDouble? width, + StacDouble? height, BoxFit? fit}); } @@ -115,11 +115,11 @@ class _$StacImageCopyWithImpl<$Res> implements $StacImageCopyWith<$Res> { width: freezed == width ? _self.width : width // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, height: freezed == height ? _self.height : height // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, fit: freezed == fit ? _self.fit : fit // ignore: cast_nullable_to_non_nullable @@ -153,9 +153,9 @@ class _StacImage implements StacImage { @override final String? color; @override - final double? width; + final StacDouble? width; @override - final double? height; + final StacDouble? height; @override final BoxFit? fit; @@ -214,8 +214,8 @@ abstract mixin class _$StacImageCopyWith<$Res> StacAlignment alignment, StacImageType imageType, String? color, - double? width, - double? height, + StacDouble? width, + StacDouble? height, BoxFit? fit}); } @@ -259,11 +259,11 @@ class __$StacImageCopyWithImpl<$Res> implements _$StacImageCopyWith<$Res> { width: freezed == width ? _self.width : width // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, height: freezed == height ? _self.height : height // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, fit: freezed == fit ? _self.fit : fit // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_image/stac_image.g.dart b/packages/stac/lib/src/parsers/widgets/stac_image/stac_image.g.dart index 64752db6..a437e8f2 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_image/stac_image.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_image/stac_image.g.dart @@ -15,8 +15,9 @@ _StacImage _$StacImageFromJson(Map json) => _StacImage( $enumDecodeNullable(_$StacImageTypeEnumMap, json['imageType']) ?? StacImageType.network, color: json['color'] as String?, - width: (json['width'] as num?)?.toDouble(), - height: (json['height'] as num?)?.toDouble(), + width: json['width'] == null ? null : StacDouble.fromJson(json['width']), + height: + json['height'] == null ? null : StacDouble.fromJson(json['height']), fit: $enumDecodeNullable(_$BoxFitEnumMap, json['fit']), ); diff --git a/packages/stac/lib/src/parsers/widgets/stac_image/stac_image_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_image/stac_image_parser.dart index 443e0765..dbc2ab4a 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_image/stac_image_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_image/stac_image_parser.dart @@ -2,6 +2,7 @@ import 'dart:io'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/cupertino.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/color_utils.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; @@ -34,8 +35,8 @@ class StacImageParser extends StacParser { imageUrl: model.src, alignment: model.alignment.value, color: model.color?.toColor(context), - width: model.width, - height: model.height, + width: model.width?.parse, + height: model.height?.parse, fit: model.fit, errorWidget: (context, error, stackTrace) { return const SizedBox(); @@ -46,8 +47,8 @@ class StacImageParser extends StacParser { File(model.src), alignment: model.alignment.value, color: model.color?.toColor(context), - width: model.width, - height: model.height, + width: model.width?.parse, + height: model.height?.parse, fit: model.fit, errorBuilder: (context, error, stackTrace) { return const SizedBox(); @@ -58,8 +59,8 @@ class StacImageParser extends StacParser { model.src, alignment: model.alignment.value, color: model.color?.toColor(context), - width: model.width, - height: model.height, + width: model.width?.parse, + height: model.height?.parse, fit: model.fit, errorBuilder: (context, error, stackTrace) { return const SizedBox(); diff --git a/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.dart b/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.dart index 8be95272..7bdc918d 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.dart @@ -1,4 +1,5 @@ import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_mouse_cursor/stac_mouse_cursor.dart'; import 'package:stac/stac.dart'; @@ -28,7 +29,7 @@ abstract class StacInkWell with _$StacInkWell { String? overlayColor, String? splashColor, Map? splashFactory, - double? radius, + StacDouble? radius, StacBorderRadius? borderRadius, StacBorder? customBorder, @Default(true) bool enableFeedback, diff --git a/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.freezed.dart index 82c4631b..e28e6f05 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.freezed.dart @@ -35,7 +35,7 @@ mixin _$StacInkWell { String? get overlayColor; String? get splashColor; Map? get splashFactory; - double? get radius; + StacDouble? get radius; StacBorderRadius? get borderRadius; StacBorder? get customBorder; bool get enableFeedback; @@ -189,7 +189,7 @@ abstract mixin class $StacInkWellCopyWith<$Res> { String? overlayColor, String? splashColor, Map? splashFactory, - double? radius, + StacDouble? radius, StacBorderRadius? borderRadius, StacBorder? customBorder, bool enableFeedback, @@ -334,7 +334,7 @@ class _$StacInkWellCopyWithImpl<$Res> implements $StacInkWellCopyWith<$Res> { radius: freezed == radius ? _self.radius : radius // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, borderRadius: freezed == borderRadius ? _self.borderRadius : borderRadius // ignore: cast_nullable_to_non_nullable @@ -632,7 +632,7 @@ class _StacInkWell implements StacInkWell { } @override - final double? radius; + final StacDouble? radius; @override final StacBorderRadius? borderRadius; @override @@ -833,7 +833,7 @@ abstract mixin class _$StacInkWellCopyWith<$Res> String? overlayColor, String? splashColor, Map? splashFactory, - double? radius, + StacDouble? radius, StacBorderRadius? borderRadius, StacBorder? customBorder, bool enableFeedback, @@ -981,7 +981,7 @@ class __$StacInkWellCopyWithImpl<$Res> implements _$StacInkWellCopyWith<$Res> { radius: freezed == radius ? _self.radius : radius // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, borderRadius: freezed == borderRadius ? _self.borderRadius : borderRadius // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.g.dart b/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.g.dart index 1c9348a1..3139a64f 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.g.dart @@ -29,7 +29,8 @@ _StacInkWell _$StacInkWellFromJson(Map json) => _StacInkWell( overlayColor: json['overlayColor'] as String?, splashColor: json['splashColor'] as String?, splashFactory: json['splashFactory'] as Map?, - radius: (json['radius'] as num?)?.toDouble(), + radius: + json['radius'] == null ? null : StacDouble.fromJson(json['radius']), borderRadius: json['borderRadius'] == null ? null : StacBorderRadius.fromJson(json['borderRadius']), diff --git a/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell_parser.dart index e93964fa..b45b8340 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell_parser.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_inkwell/stac_inkwell.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac/stac.dart'; @@ -17,6 +18,7 @@ class StacInkwellParser extends StacParser { @override Widget parse(BuildContext context, StacInkWell model) { return InkWell( + child: Stac.fromJson(model.child, context), onTap: model.onTap == null ? null : () => Stac.onCallFromJson(model.onTap, context), @@ -60,7 +62,7 @@ class StacInkwellParser extends StacParser { overlayColor: WidgetStateProperty.all(model.overlayColor?.toColor(context)), splashColor: model.splashColor.toColor(context), - radius: model.radius, + radius: model.radius?.parse, borderRadius: model.borderRadius.parse, customBorder: model.customBorder?.parse(context), enableFeedback: model.enableFeedback, @@ -69,7 +71,11 @@ class StacInkwellParser extends StacParser { onFocusChange: (_) => Stac.onCallFromJson(model.onFocusChange, context), autofocus: model.autofocus, hoverDuration: model.hoverDuration?.parse, - child: Stac.fromJson(model.child, context), + + ///TODO : need to add support for + ///focusNode + ///splashFactory + ///statesController ); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_input_border/stac_input_border.dart b/packages/stac/lib/src/parsers/widgets/stac_input_border/stac_input_border.dart index 41dc20c9..470e6981 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_input_border/stac_input_border.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_input_border/stac_input_border.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:stac/src/framework/ui/stac_outline_input_border.dart'; import 'package:stac/src/parsers/widgets/stac_border_radius/stac_border_radius.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_gradient/stac_gradient.dart'; import 'package:stac/src/utils/color_utils.dart'; @@ -16,7 +17,7 @@ abstract class StacInputBorder with _$StacInputBorder { @Default(StacInputBorderType.underlineInputBorder) StacInputBorderType type, StacBorderRadius? borderRadius, @Default(4.0) double gapPadding, - @Default(0.0) double width, + @Default(StacDouble.zero) StacDouble width, String? color, StacGradient? gradient, }) = _StacInputBorder; @@ -34,13 +35,13 @@ extension StacInputBorderParser on StacInputBorder { return UnderlineInputBorder( borderSide: BorderSide( color: color?.toColor(context) ?? Colors.black, - width: width, + width: width.parse, ), borderRadius: borderRadius.parse, ); case StacInputBorderType.outlineInputBorder: return StacOutlineInputBorder( - width: width, + width: width.parse, borderRadius: borderRadius.parse, gapPadding: gapPadding, color: color?.toColor(context) ?? Colors.black, diff --git a/packages/stac/lib/src/parsers/widgets/stac_input_border/stac_input_border.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_input_border/stac_input_border.freezed.dart index 548f0451..9fc63f39 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_input_border/stac_input_border.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_input_border/stac_input_border.freezed.dart @@ -18,7 +18,7 @@ mixin _$StacInputBorder { StacInputBorderType get type; StacBorderRadius? get borderRadius; double get gapPadding; - double get width; + StacDouble get width; String? get color; StacGradient? get gradient; @@ -70,7 +70,7 @@ abstract mixin class $StacInputBorderCopyWith<$Res> { {StacInputBorderType type, StacBorderRadius? borderRadius, double gapPadding, - double width, + StacDouble width, String? color, StacGradient? gradient}); @@ -114,7 +114,7 @@ class _$StacInputBorderCopyWithImpl<$Res> width: null == width ? _self.width : width // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, color: freezed == color ? _self.color : color // ignore: cast_nullable_to_non_nullable @@ -162,7 +162,7 @@ class _StacInputBorder implements StacInputBorder { {this.type = StacInputBorderType.underlineInputBorder, this.borderRadius, this.gapPadding = 4.0, - this.width = 0.0, + this.width = StacDouble.zero, this.color, this.gradient}); factory _StacInputBorder.fromJson(Map json) => @@ -178,7 +178,7 @@ class _StacInputBorder implements StacInputBorder { final double gapPadding; @override @JsonKey() - final double width; + final StacDouble width; @override final String? color; @override @@ -238,7 +238,7 @@ abstract mixin class _$StacInputBorderCopyWith<$Res> {StacInputBorderType type, StacBorderRadius? borderRadius, double gapPadding, - double width, + StacDouble width, String? color, StacGradient? gradient}); @@ -284,7 +284,7 @@ class __$StacInputBorderCopyWithImpl<$Res> width: null == width ? _self.width : width // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, color: freezed == color ? _self.color : color // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_input_border/stac_input_border.g.dart b/packages/stac/lib/src/parsers/widgets/stac_input_border/stac_input_border.g.dart index 366466e1..a1a2a685 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_input_border/stac_input_border.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_input_border/stac_input_border.g.dart @@ -14,7 +14,9 @@ _StacInputBorder _$StacInputBorderFromJson(Map json) => ? null : StacBorderRadius.fromJson(json['borderRadius']), gapPadding: (json['gapPadding'] as num?)?.toDouble() ?? 4.0, - width: (json['width'] as num?)?.toDouble() ?? 0.0, + width: json['width'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['width']), color: json['color'] as String?, gradient: json['gradient'] == null ? null diff --git a/packages/stac/lib/src/parsers/widgets/stac_limited_box/stac_limited_box.dart b/packages/stac/lib/src/parsers/widgets/stac_limited_box/stac_limited_box.dart index 21230e96..93dfbd01 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_limited_box/stac_limited_box.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_limited_box/stac_limited_box.dart @@ -1,4 +1,5 @@ import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; export 'package:stac/src/parsers/widgets/stac_limited_box/stac_limited_box_parser.dart'; @@ -8,8 +9,8 @@ part 'stac_limited_box.g.dart'; @freezed abstract class StacLimitedBox with _$StacLimitedBox { const factory StacLimitedBox({ - @Default(double.infinity) double maxHeight, - @Default(double.infinity) double maxWidth, + @Default(StacDouble.infinity) StacDouble maxHeight, + @Default(StacDouble.infinity) StacDouble maxWidth, Map? child, }) = _StacLimitedBox; diff --git a/packages/stac/lib/src/parsers/widgets/stac_limited_box/stac_limited_box.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_limited_box/stac_limited_box.freezed.dart index 894b884e..cc889c3d 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_limited_box/stac_limited_box.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_limited_box/stac_limited_box.freezed.dart @@ -15,8 +15,8 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacLimitedBox { - double get maxHeight; - double get maxWidth; + StacDouble get maxHeight; + StacDouble get maxWidth; Map? get child; /// Create a copy of StacLimitedBox @@ -59,7 +59,8 @@ abstract mixin class $StacLimitedBoxCopyWith<$Res> { StacLimitedBox value, $Res Function(StacLimitedBox) _then) = _$StacLimitedBoxCopyWithImpl; @useResult - $Res call({double maxHeight, double maxWidth, Map? child}); + $Res call( + {StacDouble maxHeight, StacDouble maxWidth, Map? child}); } /// @nodoc @@ -83,11 +84,11 @@ class _$StacLimitedBoxCopyWithImpl<$Res> maxHeight: null == maxHeight ? _self.maxHeight : maxHeight // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, maxWidth: null == maxWidth ? _self.maxWidth : maxWidth // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, child: freezed == child ? _self.child : child // ignore: cast_nullable_to_non_nullable @@ -100,8 +101,8 @@ class _$StacLimitedBoxCopyWithImpl<$Res> @JsonSerializable() class _StacLimitedBox implements StacLimitedBox { const _StacLimitedBox( - {this.maxHeight = double.infinity, - this.maxWidth = double.infinity, + {this.maxHeight = StacDouble.infinity, + this.maxWidth = StacDouble.infinity, final Map? child}) : _child = child; factory _StacLimitedBox.fromJson(Map json) => @@ -109,10 +110,10 @@ class _StacLimitedBox implements StacLimitedBox { @override @JsonKey() - final double maxHeight; + final StacDouble maxHeight; @override @JsonKey() - final double maxWidth; + final StacDouble maxWidth; final Map? _child; @override Map? get child { @@ -169,7 +170,8 @@ abstract mixin class _$StacLimitedBoxCopyWith<$Res> __$StacLimitedBoxCopyWithImpl; @override @useResult - $Res call({double maxHeight, double maxWidth, Map? child}); + $Res call( + {StacDouble maxHeight, StacDouble maxWidth, Map? child}); } /// @nodoc @@ -193,11 +195,11 @@ class __$StacLimitedBoxCopyWithImpl<$Res> maxHeight: null == maxHeight ? _self.maxHeight : maxHeight // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, maxWidth: null == maxWidth ? _self.maxWidth : maxWidth // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, child: freezed == child ? _self._child : child // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_limited_box/stac_limited_box.g.dart b/packages/stac/lib/src/parsers/widgets/stac_limited_box/stac_limited_box.g.dart index 910a4e39..7a7ff9dc 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_limited_box/stac_limited_box.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_limited_box/stac_limited_box.g.dart @@ -8,8 +8,12 @@ part of 'stac_limited_box.dart'; _StacLimitedBox _$StacLimitedBoxFromJson(Map json) => _StacLimitedBox( - maxHeight: (json['maxHeight'] as num?)?.toDouble() ?? double.infinity, - maxWidth: (json['maxWidth'] as num?)?.toDouble() ?? double.infinity, + maxHeight: json['maxHeight'] == null + ? StacDouble.infinity + : StacDouble.fromJson(json['maxHeight']), + maxWidth: json['maxWidth'] == null + ? StacDouble.infinity + : StacDouble.fromJson(json['maxWidth']), child: json['child'] as Map?, ); diff --git a/packages/stac/lib/src/parsers/widgets/stac_limited_box/stac_limited_box_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_limited_box/stac_limited_box_parser.dart index a8efd691..a7735d37 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_limited_box/stac_limited_box_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_limited_box/stac_limited_box_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_limited_box/stac_limited_box.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; @@ -17,8 +18,8 @@ class StacLimitedBoxParser extends StacParser { @override Widget parse(BuildContext context, StacLimitedBox model) { return LimitedBox( - maxHeight: model.maxHeight, - maxWidth: model.maxWidth, + maxHeight: model.maxHeight.parse, + maxWidth: model.maxWidth.parse, child: Stac.fromJson(model.child, context), ); } diff --git a/packages/stac/lib/src/parsers/widgets/stac_linear_progress_indicator/stac_linear_progress_indicator.dart b/packages/stac/lib/src/parsers/widgets/stac_linear_progress_indicator/stac_linear_progress_indicator.dart index 0e945be3..c32327a9 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_linear_progress_indicator/stac_linear_progress_indicator.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_linear_progress_indicator/stac_linear_progress_indicator.dart @@ -1,5 +1,6 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:stac/src/parsers/parsers.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; export 'stac_linear_progress_indicator_parser.dart'; @@ -9,10 +10,10 @@ part 'stac_linear_progress_indicator.g.dart'; @freezed abstract class StacLinearProgressIndicator with _$StacLinearProgressIndicator { const factory StacLinearProgressIndicator({ - double? value, + StacDouble? value, String? backgroundColor, String? color, - double? minHeight, + StacDouble? minHeight, String? semanticsLabel, String? semanticsValue, @Default(StacBorderRadius()) StacBorderRadius borderRadius, diff --git a/packages/stac/lib/src/parsers/widgets/stac_linear_progress_indicator/stac_linear_progress_indicator.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_linear_progress_indicator/stac_linear_progress_indicator.freezed.dart index 3d374c9d..cd2c9e19 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_linear_progress_indicator/stac_linear_progress_indicator.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_linear_progress_indicator/stac_linear_progress_indicator.freezed.dart @@ -15,10 +15,10 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacLinearProgressIndicator { - double? get value; + StacDouble? get value; String? get backgroundColor; String? get color; - double? get minHeight; + StacDouble? get minHeight; String? get semanticsLabel; String? get semanticsValue; StacBorderRadius get borderRadius; @@ -73,10 +73,10 @@ abstract mixin class $StacLinearProgressIndicatorCopyWith<$Res> { _$StacLinearProgressIndicatorCopyWithImpl; @useResult $Res call( - {double? value, + {StacDouble? value, String? backgroundColor, String? color, - double? minHeight, + StacDouble? minHeight, String? semanticsLabel, String? semanticsValue, StacBorderRadius borderRadius}); @@ -109,7 +109,7 @@ class _$StacLinearProgressIndicatorCopyWithImpl<$Res> value: freezed == value ? _self.value : value // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, backgroundColor: freezed == backgroundColor ? _self.backgroundColor : backgroundColor // ignore: cast_nullable_to_non_nullable @@ -121,7 +121,7 @@ class _$StacLinearProgressIndicatorCopyWithImpl<$Res> minHeight: freezed == minHeight ? _self.minHeight : minHeight // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, semanticsLabel: freezed == semanticsLabel ? _self.semanticsLabel : semanticsLabel // ignore: cast_nullable_to_non_nullable @@ -163,13 +163,13 @@ class _StacLinearProgressIndicator implements StacLinearProgressIndicator { _$StacLinearProgressIndicatorFromJson(json); @override - final double? value; + final StacDouble? value; @override final String? backgroundColor; @override final String? color; @override - final double? minHeight; + final StacDouble? minHeight; @override final String? semanticsLabel; @override @@ -234,10 +234,10 @@ abstract mixin class _$StacLinearProgressIndicatorCopyWith<$Res> @override @useResult $Res call( - {double? value, + {StacDouble? value, String? backgroundColor, String? color, - double? minHeight, + StacDouble? minHeight, String? semanticsLabel, String? semanticsValue, StacBorderRadius borderRadius}); @@ -271,7 +271,7 @@ class __$StacLinearProgressIndicatorCopyWithImpl<$Res> value: freezed == value ? _self.value : value // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, backgroundColor: freezed == backgroundColor ? _self.backgroundColor : backgroundColor // ignore: cast_nullable_to_non_nullable @@ -283,7 +283,7 @@ class __$StacLinearProgressIndicatorCopyWithImpl<$Res> minHeight: freezed == minHeight ? _self.minHeight : minHeight // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, semanticsLabel: freezed == semanticsLabel ? _self.semanticsLabel : semanticsLabel // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_linear_progress_indicator/stac_linear_progress_indicator.g.dart b/packages/stac/lib/src/parsers/widgets/stac_linear_progress_indicator/stac_linear_progress_indicator.g.dart index 7e15f46e..7de071a2 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_linear_progress_indicator/stac_linear_progress_indicator.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_linear_progress_indicator/stac_linear_progress_indicator.g.dart @@ -9,10 +9,12 @@ part of 'stac_linear_progress_indicator.dart'; _StacLinearProgressIndicator _$StacLinearProgressIndicatorFromJson( Map json) => _StacLinearProgressIndicator( - value: (json['value'] as num?)?.toDouble(), + value: json['value'] == null ? null : StacDouble.fromJson(json['value']), backgroundColor: json['backgroundColor'] as String?, color: json['color'] as String?, - minHeight: (json['minHeight'] as num?)?.toDouble(), + minHeight: json['minHeight'] == null + ? null + : StacDouble.fromJson(json['minHeight']), semanticsLabel: json['semanticsLabel'] as String?, semanticsValue: json['semanticsValue'] as String?, borderRadius: json['borderRadius'] == null diff --git a/packages/stac/lib/src/parsers/widgets/stac_linear_progress_indicator/stac_linear_progress_indicator_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_linear_progress_indicator/stac_linear_progress_indicator_parser.dart index 8566e771..5ed37b50 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_linear_progress_indicator/stac_linear_progress_indicator_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_linear_progress_indicator/stac_linear_progress_indicator_parser.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac/stac.dart'; @@ -16,10 +17,10 @@ class StacLinearProgressIndicatorParser @override Widget parse(BuildContext context, StacLinearProgressIndicator model) { return LinearProgressIndicator( - value: model.value, + value: model.value?.parse, backgroundColor: model.backgroundColor.toColor(context), color: model.color.toColor(context), - minHeight: model.minHeight, + minHeight: model.minHeight?.parse, semanticsLabel: model.semanticsLabel, semanticsValue: model.semanticsValue, borderRadius: model.borderRadius.parse, diff --git a/packages/stac/lib/src/parsers/widgets/stac_list_tile/stac_list_tile.dart b/packages/stac/lib/src/parsers/widgets/stac_list_tile/stac_list_tile.dart index 128d99cf..f164f49a 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_list_tile/stac_list_tile.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_list_tile/stac_list_tile.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; export 'stac_list_tile_parser.dart'; @@ -31,9 +32,9 @@ abstract class StacListTile with _$StacListTile { String? tileColor, String? selectedTileColor, bool? enableFeedback, - double? horizontalTitleGap, - double? minVerticalPadding, - double? minLeadingWidth, + StacDouble? horizontalTitleGap, + StacDouble? minVerticalPadding, + StacDouble? minLeadingWidth, }) = _StacListTile; factory StacListTile.fromJson(Map json) => diff --git a/packages/stac/lib/src/parsers/widgets/stac_list_tile/stac_list_tile.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_list_tile/stac_list_tile.freezed.dart index f45c0c45..4f8192f0 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_list_tile/stac_list_tile.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_list_tile/stac_list_tile.freezed.dart @@ -36,9 +36,9 @@ mixin _$StacListTile { String? get tileColor; String? get selectedTileColor; bool? get enableFeedback; - double? get horizontalTitleGap; - double? get minVerticalPadding; - double? get minLeadingWidth; + StacDouble? get horizontalTitleGap; + StacDouble? get minVerticalPadding; + StacDouble? get minLeadingWidth; /// Create a copy of StacListTile /// with the given fields replaced by the non-null parameter values. @@ -162,9 +162,9 @@ abstract mixin class $StacListTileCopyWith<$Res> { String? tileColor, String? selectedTileColor, bool? enableFeedback, - double? horizontalTitleGap, - double? minVerticalPadding, - double? minLeadingWidth}); + StacDouble? horizontalTitleGap, + StacDouble? minVerticalPadding, + StacDouble? minLeadingWidth}); $StacEdgeInsetsCopyWith<$Res>? get contentPadding; } @@ -294,15 +294,15 @@ class _$StacListTileCopyWithImpl<$Res> implements $StacListTileCopyWith<$Res> { horizontalTitleGap: freezed == horizontalTitleGap ? _self.horizontalTitleGap : horizontalTitleGap // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, minVerticalPadding: freezed == minVerticalPadding ? _self.minVerticalPadding : minVerticalPadding // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, minLeadingWidth: freezed == minLeadingWidth ? _self.minLeadingWidth : minLeadingWidth // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, )); } @@ -453,11 +453,11 @@ class _StacListTile implements StacListTile { @override final bool? enableFeedback; @override - final double? horizontalTitleGap; + final StacDouble? horizontalTitleGap; @override - final double? minVerticalPadding; + final StacDouble? minVerticalPadding; @override - final double? minLeadingWidth; + final StacDouble? minLeadingWidth; /// Create a copy of StacListTile /// with the given fields replaced by the non-null parameter values. @@ -587,9 +587,9 @@ abstract mixin class _$StacListTileCopyWith<$Res> String? tileColor, String? selectedTileColor, bool? enableFeedback, - double? horizontalTitleGap, - double? minVerticalPadding, - double? minLeadingWidth}); + StacDouble? horizontalTitleGap, + StacDouble? minVerticalPadding, + StacDouble? minLeadingWidth}); @override $StacEdgeInsetsCopyWith<$Res>? get contentPadding; @@ -721,15 +721,15 @@ class __$StacListTileCopyWithImpl<$Res> horizontalTitleGap: freezed == horizontalTitleGap ? _self.horizontalTitleGap : horizontalTitleGap // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, minVerticalPadding: freezed == minVerticalPadding ? _self.minVerticalPadding : minVerticalPadding // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, minLeadingWidth: freezed == minLeadingWidth ? _self.minLeadingWidth : minLeadingWidth // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, )); } diff --git a/packages/stac/lib/src/parsers/widgets/stac_list_tile/stac_list_tile.g.dart b/packages/stac/lib/src/parsers/widgets/stac_list_tile/stac_list_tile.g.dart index ec8020b9..2fe5a2b0 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_list_tile/stac_list_tile.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_list_tile/stac_list_tile.g.dart @@ -31,9 +31,15 @@ _StacListTile _$StacListTileFromJson(Map json) => tileColor: json['tileColor'] as String?, selectedTileColor: json['selectedTileColor'] as String?, enableFeedback: json['enableFeedback'] as bool?, - horizontalTitleGap: (json['horizontalTitleGap'] as num?)?.toDouble(), - minVerticalPadding: (json['minVerticalPadding'] as num?)?.toDouble(), - minLeadingWidth: (json['minLeadingWidth'] as num?)?.toDouble(), + horizontalTitleGap: json['horizontalTitleGap'] == null + ? null + : StacDouble.fromJson(json['horizontalTitleGap']), + minVerticalPadding: json['minVerticalPadding'] == null + ? null + : StacDouble.fromJson(json['minVerticalPadding']), + minLeadingWidth: json['minLeadingWidth'] == null + ? null + : StacDouble.fromJson(json['minLeadingWidth']), ); Map _$StacListTileToJson(_StacListTile instance) => diff --git a/packages/stac/lib/src/parsers/widgets/stac_list_tile/stac_list_tile_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_list_tile/stac_list_tile_parser.dart index bfb675d8..e74f2435 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_list_tile/stac_list_tile_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_list_tile/stac_list_tile_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; import 'package:stac/src/parsers/widgets/stac_list_tile/stac_list_tile.dart'; import 'package:stac/src/utils/color_utils.dart'; @@ -40,9 +41,9 @@ class StacListTileParser extends StacParser { tileColor: model.tileColor?.toColor(context), selectedTileColor: model.selectedTileColor?.toColor(context), enableFeedback: model.enableFeedback, - horizontalTitleGap: model.horizontalTitleGap, - minVerticalPadding: model.minVerticalPadding, - minLeadingWidth: model.minLeadingWidth, + horizontalTitleGap: model.horizontalTitleGap?.parse, + minVerticalPadding: model.minVerticalPadding?.parse, + minLeadingWidth: model.minLeadingWidth?.parse, ); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_list_view/stac_list_view.dart b/packages/stac/lib/src/parsers/widgets/stac_list_view/stac_list_view.dart index 3bfa7982..001f1ae2 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_list_view/stac_list_view.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_list_view/stac_list_view.dart @@ -1,6 +1,7 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; import 'package:stac/src/utils/stac_scroll_physics.dart'; @@ -21,7 +22,7 @@ abstract class StacListView with _$StacListView { @Default(true) bool addAutomaticKeepAlives, @Default(true) bool addRepaintBoundaries, @Default(true) bool addSemanticIndexes, - double? cacheExtent, + StacDouble? cacheExtent, @Default([]) List> children, Map? separator, int? semanticChildCount, diff --git a/packages/stac/lib/src/parsers/widgets/stac_list_view/stac_list_view.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_list_view/stac_list_view.freezed.dart index b784175b..8e8ce425 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_list_view/stac_list_view.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_list_view/stac_list_view.freezed.dart @@ -24,7 +24,7 @@ mixin _$StacListView { bool get addAutomaticKeepAlives; bool get addRepaintBoundaries; bool get addSemanticIndexes; - double? get cacheExtent; + StacDouble? get cacheExtent; List> get children; Map? get separator; int? get semanticChildCount; @@ -124,7 +124,7 @@ abstract mixin class $StacListViewCopyWith<$Res> { bool addAutomaticKeepAlives, bool addRepaintBoundaries, bool addSemanticIndexes, - double? cacheExtent, + StacDouble? cacheExtent, List> children, Map? separator, int? semanticChildCount, @@ -206,7 +206,7 @@ class _$StacListViewCopyWithImpl<$Res> implements $StacListViewCopyWith<$Res> { cacheExtent: freezed == cacheExtent ? _self.cacheExtent : cacheExtent // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, children: null == children ? _self.children : children // ignore: cast_nullable_to_non_nullable @@ -304,7 +304,7 @@ class _StacListView implements StacListView { @JsonKey() final bool addSemanticIndexes; @override - final double? cacheExtent; + final StacDouble? cacheExtent; final List> _children; @override @JsonKey() @@ -436,7 +436,7 @@ abstract mixin class _$StacListViewCopyWith<$Res> bool addAutomaticKeepAlives, bool addRepaintBoundaries, bool addSemanticIndexes, - double? cacheExtent, + StacDouble? cacheExtent, List> children, Map? separator, int? semanticChildCount, @@ -520,7 +520,7 @@ class __$StacListViewCopyWithImpl<$Res> cacheExtent: freezed == cacheExtent ? _self.cacheExtent : cacheExtent // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, children: null == children ? _self._children : children // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_list_view/stac_list_view.g.dart b/packages/stac/lib/src/parsers/widgets/stac_list_view/stac_list_view.g.dart index 0d32ff46..70554699 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_list_view/stac_list_view.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_list_view/stac_list_view.g.dart @@ -21,7 +21,9 @@ _StacListView _$StacListViewFromJson(Map json) => addAutomaticKeepAlives: json['addAutomaticKeepAlives'] as bool? ?? true, addRepaintBoundaries: json['addRepaintBoundaries'] as bool? ?? true, addSemanticIndexes: json['addSemanticIndexes'] as bool? ?? true, - cacheExtent: (json['cacheExtent'] as num?)?.toDouble(), + cacheExtent: json['cacheExtent'] == null + ? null + : StacDouble.fromJson(json['cacheExtent']), children: (json['children'] as List?) ?.map((e) => e as Map) .toList() ?? diff --git a/packages/stac/lib/src/parsers/widgets/stac_list_view/stac_list_view_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_list_view/stac_list_view_parser.dart index 758c008b..4d741e2c 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_list_view/stac_list_view_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_list_view/stac_list_view_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; import 'package:stac/src/parsers/widgets/stac_list_view/stac_list_view.dart'; import 'package:stac/src/utils/widget_type.dart'; @@ -30,7 +31,7 @@ class StacListViewParser extends StacParser { addAutomaticKeepAlives: model.addAutomaticKeepAlives, addRepaintBoundaries: model.addRepaintBoundaries, addSemanticIndexes: model.addSemanticIndexes, - cacheExtent: model.cacheExtent, + cacheExtent: model.cacheExtent?.parse, dragStartBehavior: model.dragStartBehavior, keyboardDismissBehavior: model.keyboardDismissBehavior, restorationId: model.restorationId, diff --git a/packages/stac/lib/src/parsers/widgets/stac_offset/stac_offset.dart b/packages/stac/lib/src/parsers/widgets/stac_offset/stac_offset.dart index 57e8b86e..127665e3 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_offset/stac_offset.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_offset/stac_offset.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; part 'stac_offset.freezed.dart'; part 'stac_offset.g.dart'; @@ -7,8 +8,8 @@ part 'stac_offset.g.dart'; @freezed abstract class StacOffset with _$StacOffset { const factory StacOffset({ - required double dx, - required double dy, + required StacDouble dx, + required StacDouble dy, }) = _StacOffset; factory StacOffset.fromJson(Map json) => @@ -17,6 +18,6 @@ abstract class StacOffset with _$StacOffset { extension StacOffsetParser on StacOffset { Offset get parse { - return Offset(dx, dy); + return Offset(dx.parse, dy.parse); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_offset/stac_offset.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_offset/stac_offset.freezed.dart index 606abc53..f7adda35 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_offset/stac_offset.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_offset/stac_offset.freezed.dart @@ -15,8 +15,8 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacOffset { - double get dx; - double get dy; + StacDouble get dx; + StacDouble get dy; /// Create a copy of StacOffset /// with the given fields replaced by the non-null parameter values. @@ -53,7 +53,7 @@ abstract mixin class $StacOffsetCopyWith<$Res> { StacOffset value, $Res Function(StacOffset) _then) = _$StacOffsetCopyWithImpl; @useResult - $Res call({double dx, double dy}); + $Res call({StacDouble dx, StacDouble dy}); } /// @nodoc @@ -75,11 +75,11 @@ class _$StacOffsetCopyWithImpl<$Res> implements $StacOffsetCopyWith<$Res> { dx: null == dx ? _self.dx : dx // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, dy: null == dy ? _self.dy : dy // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, )); } } @@ -92,9 +92,9 @@ class _StacOffset implements StacOffset { _$StacOffsetFromJson(json); @override - final double dx; + final StacDouble dx; @override - final double dy; + final StacDouble dy; /// Create a copy of StacOffset /// with the given fields replaced by the non-null parameter values. @@ -138,7 +138,7 @@ abstract mixin class _$StacOffsetCopyWith<$Res> __$StacOffsetCopyWithImpl; @override @useResult - $Res call({double dx, double dy}); + $Res call({StacDouble dx, StacDouble dy}); } /// @nodoc @@ -160,11 +160,11 @@ class __$StacOffsetCopyWithImpl<$Res> implements _$StacOffsetCopyWith<$Res> { dx: null == dx ? _self.dx : dx // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, dy: null == dy ? _self.dy : dy // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, )); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_offset/stac_offset.g.dart b/packages/stac/lib/src/parsers/widgets/stac_offset/stac_offset.g.dart index 655b015c..c1b8f825 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_offset/stac_offset.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_offset/stac_offset.g.dart @@ -7,8 +7,8 @@ part of 'stac_offset.dart'; // ************************************************************************** _StacOffset _$StacOffsetFromJson(Map json) => _StacOffset( - dx: (json['dx'] as num).toDouble(), - dy: (json['dy'] as num).toDouble(), + dx: StacDouble.fromJson(json['dx']), + dy: StacDouble.fromJson(json['dy']), ); Map _$StacOffsetToJson(_StacOffset instance) => diff --git a/packages/stac/lib/src/parsers/widgets/stac_opacity/stac_opacity.dart b/packages/stac/lib/src/parsers/widgets/stac_opacity/stac_opacity.dart index 7247b8fb..a1bfa4b5 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_opacity/stac_opacity.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_opacity/stac_opacity.dart @@ -1,4 +1,5 @@ import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; export 'package:stac/src/parsers/widgets/stac_opacity/stac_opacity_parser.dart'; @@ -8,7 +9,7 @@ part 'stac_opacity.g.dart'; @freezed abstract class StacOpacity with _$StacOpacity { const factory StacOpacity({ - required double opacity, + required StacDouble opacity, required Map child, }) = _StacOpacity; diff --git a/packages/stac/lib/src/parsers/widgets/stac_opacity/stac_opacity.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_opacity/stac_opacity.freezed.dart index d24aaea2..3bd733c7 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_opacity/stac_opacity.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_opacity/stac_opacity.freezed.dart @@ -15,7 +15,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacOpacity { - double get opacity; + StacDouble get opacity; Map get child; /// Create a copy of StacOpacity @@ -54,7 +54,7 @@ abstract mixin class $StacOpacityCopyWith<$Res> { StacOpacity value, $Res Function(StacOpacity) _then) = _$StacOpacityCopyWithImpl; @useResult - $Res call({double opacity, Map child}); + $Res call({StacDouble opacity, Map child}); } /// @nodoc @@ -76,7 +76,7 @@ class _$StacOpacityCopyWithImpl<$Res> implements $StacOpacityCopyWith<$Res> { opacity: null == opacity ? _self.opacity : opacity // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, child: null == child ? _self.child : child // ignore: cast_nullable_to_non_nullable @@ -95,7 +95,7 @@ class _StacOpacity implements StacOpacity { _$StacOpacityFromJson(json); @override - final double opacity; + final StacDouble opacity; final Map _child; @override Map get child { @@ -147,7 +147,7 @@ abstract mixin class _$StacOpacityCopyWith<$Res> __$StacOpacityCopyWithImpl; @override @useResult - $Res call({double opacity, Map child}); + $Res call({StacDouble opacity, Map child}); } /// @nodoc @@ -169,7 +169,7 @@ class __$StacOpacityCopyWithImpl<$Res> implements _$StacOpacityCopyWith<$Res> { opacity: null == opacity ? _self.opacity : opacity // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, child: null == child ? _self._child : child // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_opacity/stac_opacity.g.dart b/packages/stac/lib/src/parsers/widgets/stac_opacity/stac_opacity.g.dart index 9db24d2c..ebc3db32 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_opacity/stac_opacity.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_opacity/stac_opacity.g.dart @@ -7,7 +7,7 @@ part of 'stac_opacity.dart'; // ************************************************************************** _StacOpacity _$StacOpacityFromJson(Map json) => _StacOpacity( - opacity: (json['opacity'] as num).toDouble(), + opacity: StacDouble.fromJson(json['opacity']), child: json['child'] as Map, ); diff --git a/packages/stac/lib/src/parsers/widgets/stac_opacity/stac_opacity_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_opacity/stac_opacity_parser.dart index 96b299ad..4bc8d693 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_opacity/stac_opacity_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_opacity/stac_opacity_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_opacity/stac_opacity.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; @@ -16,7 +17,7 @@ class StacOpacityParser extends StacParser { @override Widget parse(BuildContext context, StacOpacity model) { return Opacity( - opacity: model.opacity, + opacity: model.opacity.parse, child: Stac.fromJson(model.child, context), ); } diff --git a/packages/stac/lib/src/parsers/widgets/stac_page_view/stac_page_view.dart b/packages/stac/lib/src/parsers/widgets/stac_page_view/stac_page_view.dart index 736df788..d26645e8 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_page_view/stac_page_view.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_page_view/stac_page_view.dart @@ -1,6 +1,7 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/stac.dart'; export 'stac_page_view_parser.dart'; @@ -23,7 +24,7 @@ abstract class StacPageView with _$StacPageView { @Default(true) bool padEnds, @Default(0) int initialPage, @Default(true) keepPage, - @Default(1.0) double viewportFraction, + @Default(StacDouble(1.0)) StacDouble viewportFraction, @Default([]) List> children, }) = _StacPageView; diff --git a/packages/stac/lib/src/parsers/widgets/stac_page_view/stac_page_view.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_page_view/stac_page_view.freezed.dart index 9e54492b..5185921c 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_page_view/stac_page_view.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_page_view/stac_page_view.freezed.dart @@ -27,7 +27,7 @@ mixin _$StacPageView { bool get padEnds; int get initialPage; dynamic get keepPage; - double get viewportFraction; + StacDouble get viewportFraction; List> get children; /// Create a copy of StacPageView @@ -115,7 +115,7 @@ abstract mixin class $StacPageViewCopyWith<$Res> { bool padEnds, int initialPage, dynamic keepPage, - double viewportFraction, + StacDouble viewportFraction, List> children}); } @@ -198,7 +198,7 @@ class _$StacPageViewCopyWithImpl<$Res> implements $StacPageViewCopyWith<$Res> { viewportFraction: null == viewportFraction ? _self.viewportFraction : viewportFraction // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, children: null == children ? _self.children : children // ignore: cast_nullable_to_non_nullable @@ -223,7 +223,7 @@ class _StacPageView implements StacPageView { this.padEnds = true, this.initialPage = 0, this.keepPage = true, - this.viewportFraction = 1.0, + this.viewportFraction = const StacDouble(1.0), final List> children = const []}) : _onPageChanged = onPageChanged, _children = children; @@ -273,7 +273,7 @@ class _StacPageView implements StacPageView { final dynamic keepPage; @override @JsonKey() - final double viewportFraction; + final StacDouble viewportFraction; final List> _children; @override @JsonKey() @@ -374,7 +374,7 @@ abstract mixin class _$StacPageViewCopyWith<$Res> bool padEnds, int initialPage, dynamic keepPage, - double viewportFraction, + StacDouble viewportFraction, List> children}); } @@ -458,7 +458,7 @@ class __$StacPageViewCopyWithImpl<$Res> viewportFraction: null == viewportFraction ? _self.viewportFraction : viewportFraction // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, children: null == children ? _self._children : children // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_page_view/stac_page_view.g.dart b/packages/stac/lib/src/parsers/widgets/stac_page_view/stac_page_view.g.dart index 3edad707..c8a394b8 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_page_view/stac_page_view.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_page_view/stac_page_view.g.dart @@ -25,7 +25,9 @@ _StacPageView _$StacPageViewFromJson(Map json) => padEnds: json['padEnds'] as bool? ?? true, initialPage: (json['initialPage'] as num?)?.toInt() ?? 0, keepPage: json['keepPage'] ?? true, - viewportFraction: (json['viewportFraction'] as num?)?.toDouble() ?? 1.0, + viewportFraction: json['viewportFraction'] == null + ? const StacDouble(1.0) + : StacDouble.fromJson(json['viewportFraction']), children: (json['children'] as List?) ?.map((e) => e as Map) .toList() ?? diff --git a/packages/stac/lib/src/parsers/widgets/stac_page_view/stac_page_view_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_page_view/stac_page_view_parser.dart index 327b0271..2f1de70a 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_page_view/stac_page_view_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_page_view/stac_page_view_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_page_view/stac_page_view.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; @@ -40,7 +41,7 @@ class _StacPageViewWidgetState extends State<_StacPageViewWidget> { _pageController = PageController( initialPage: widget.model.initialPage, - viewportFraction: widget.model.viewportFraction, + viewportFraction: widget.model.viewportFraction.parse, keepPage: widget.model.keepPage, ); } diff --git a/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder.dart b/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder.dart index d707b78b..49fa4889 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder.dart @@ -1,4 +1,5 @@ import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; export 'package:stac/src/parsers/widgets/stac_placeholder/stac_placeholder_parser.dart'; @@ -8,9 +9,9 @@ part 'stac_placeholder.g.dart'; @freezed abstract class StacPlaceholder with _$StacPlaceholder { const factory StacPlaceholder({ - @Default(2.0) double fallbackWidth, - @Default(400.0) double fallbackHeight, - @Default(400.0) double strokeWidth, + @Default(StacDouble(2.0)) StacDouble fallbackWidth, + @Default(StacDouble(400.0)) StacDouble fallbackHeight, + @Default(StacDouble(400.0)) StacDouble strokeWidth, @Default('#455A64') String color, Map? child, }) = _StacPlaceholder; diff --git a/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder.freezed.dart index fe3fab79..9d7ee0aa 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder.freezed.dart @@ -15,9 +15,9 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacPlaceholder { - double get fallbackWidth; - double get fallbackHeight; - double get strokeWidth; + StacDouble get fallbackWidth; + StacDouble get fallbackHeight; + StacDouble get strokeWidth; String get color; Map? get child; @@ -65,9 +65,9 @@ abstract mixin class $StacPlaceholderCopyWith<$Res> { _$StacPlaceholderCopyWithImpl; @useResult $Res call( - {double fallbackWidth, - double fallbackHeight, - double strokeWidth, + {StacDouble fallbackWidth, + StacDouble fallbackHeight, + StacDouble strokeWidth, String color, Map? child}); } @@ -95,15 +95,15 @@ class _$StacPlaceholderCopyWithImpl<$Res> fallbackWidth: null == fallbackWidth ? _self.fallbackWidth : fallbackWidth // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, fallbackHeight: null == fallbackHeight ? _self.fallbackHeight : fallbackHeight // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, strokeWidth: null == strokeWidth ? _self.strokeWidth : strokeWidth // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, color: null == color ? _self.color : color // ignore: cast_nullable_to_non_nullable @@ -120,9 +120,9 @@ class _$StacPlaceholderCopyWithImpl<$Res> @JsonSerializable() class _StacPlaceholder implements StacPlaceholder { const _StacPlaceholder( - {this.fallbackWidth = 2.0, - this.fallbackHeight = 400.0, - this.strokeWidth = 400.0, + {this.fallbackWidth = const StacDouble(2.0), + this.fallbackHeight = const StacDouble(400.0), + this.strokeWidth = const StacDouble(400.0), this.color = '#455A64', final Map? child}) : _child = child; @@ -131,13 +131,13 @@ class _StacPlaceholder implements StacPlaceholder { @override @JsonKey() - final double fallbackWidth; + final StacDouble fallbackWidth; @override @JsonKey() - final double fallbackHeight; + final StacDouble fallbackHeight; @override @JsonKey() - final double strokeWidth; + final StacDouble strokeWidth; @override @JsonKey() final String color; @@ -201,9 +201,9 @@ abstract mixin class _$StacPlaceholderCopyWith<$Res> @override @useResult $Res call( - {double fallbackWidth, - double fallbackHeight, - double strokeWidth, + {StacDouble fallbackWidth, + StacDouble fallbackHeight, + StacDouble strokeWidth, String color, Map? child}); } @@ -231,15 +231,15 @@ class __$StacPlaceholderCopyWithImpl<$Res> fallbackWidth: null == fallbackWidth ? _self.fallbackWidth : fallbackWidth // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, fallbackHeight: null == fallbackHeight ? _self.fallbackHeight : fallbackHeight // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, strokeWidth: null == strokeWidth ? _self.strokeWidth : strokeWidth // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, color: null == color ? _self.color : color // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder.g.dart b/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder.g.dart index 38e6dff7..f4f02114 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder.g.dart @@ -8,9 +8,15 @@ part of 'stac_placeholder.dart'; _StacPlaceholder _$StacPlaceholderFromJson(Map json) => _StacPlaceholder( - fallbackWidth: (json['fallbackWidth'] as num?)?.toDouble() ?? 2.0, - fallbackHeight: (json['fallbackHeight'] as num?)?.toDouble() ?? 400.0, - strokeWidth: (json['strokeWidth'] as num?)?.toDouble() ?? 400.0, + fallbackWidth: json['fallbackWidth'] == null + ? const StacDouble(2.0) + : StacDouble.fromJson(json['fallbackWidth']), + fallbackHeight: json['fallbackHeight'] == null + ? const StacDouble(400.0) + : StacDouble.fromJson(json['fallbackHeight']), + strokeWidth: json['strokeWidth'] == null + ? const StacDouble(400.0) + : StacDouble.fromJson(json['strokeWidth']), color: json['color'] as String? ?? '#455A64', child: json['child'] as Map?, ); diff --git a/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder_parser.dart index 1bc426e9..c512fea9 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_placeholder/stac_placeholder.dart'; import 'package:stac/src/utils/utils.dart'; import 'package:stac/src/utils/widget_type.dart'; @@ -18,9 +19,9 @@ class StacPlaceholderParser extends StacParser { @override Widget parse(BuildContext context, StacPlaceholder model) { return Placeholder( - fallbackWidth: model.fallbackWidth, - fallbackHeight: model.fallbackHeight, - strokeWidth: model.strokeWidth, + fallbackWidth: model.fallbackWidth.parse, + fallbackHeight: model.fallbackHeight.parse, + strokeWidth: model.strokeWidth.parse, color: model.color.toColor(context) ?? Color(0xFF455A64), child: Stac.fromJson(model.child, context), ); diff --git a/packages/stac/lib/src/parsers/widgets/stac_positioned/stac_positioned.dart b/packages/stac/lib/src/parsers/widgets/stac_positioned/stac_positioned.dart index bfca0ac4..8f25813b 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_positioned/stac_positioned.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_positioned/stac_positioned.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_rect/stac_rect.dart'; export 'stac_positioned_parser.dart'; @@ -18,14 +19,14 @@ enum StacPositionedType { directional, fill, fromRect } abstract class StacPositioned with _$StacPositioned { const factory StacPositioned({ StacPositionedType? positionedType, - double? left, - double? top, - double? right, - double? bottom, - double? width, - double? height, - double? start, - double? end, + StacDouble? left, + StacDouble? top, + StacDouble? right, + StacDouble? bottom, + StacDouble? width, + StacDouble? height, + StacDouble? start, + StacDouble? end, @Default(TextDirection.ltr) TextDirection textDirection, StacRect? rect, Map? child, diff --git a/packages/stac/lib/src/parsers/widgets/stac_positioned/stac_positioned.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_positioned/stac_positioned.freezed.dart index eb092450..46eac155 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_positioned/stac_positioned.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_positioned/stac_positioned.freezed.dart @@ -16,14 +16,14 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacPositioned { StacPositionedType? get positionedType; - double? get left; - double? get top; - double? get right; - double? get bottom; - double? get width; - double? get height; - double? get start; - double? get end; + StacDouble? get left; + StacDouble? get top; + StacDouble? get right; + StacDouble? get bottom; + StacDouble? get width; + StacDouble? get height; + StacDouble? get start; + StacDouble? get end; TextDirection get textDirection; StacRect? get rect; Map? get child; @@ -91,14 +91,14 @@ abstract mixin class $StacPositionedCopyWith<$Res> { @useResult $Res call( {StacPositionedType? positionedType, - double? left, - double? top, - double? right, - double? bottom, - double? width, - double? height, - double? start, - double? end, + StacDouble? left, + StacDouble? top, + StacDouble? right, + StacDouble? bottom, + StacDouble? width, + StacDouble? height, + StacDouble? start, + StacDouble? end, TextDirection textDirection, StacRect? rect, Map? child}); @@ -140,35 +140,35 @@ class _$StacPositionedCopyWithImpl<$Res> left: freezed == left ? _self.left : left // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, top: freezed == top ? _self.top : top // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, right: freezed == right ? _self.right : right // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, bottom: freezed == bottom ? _self.bottom : bottom // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, width: freezed == width ? _self.width : width // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, height: freezed == height ? _self.height : height // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, start: freezed == start ? _self.start : start // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, end: freezed == end ? _self.end : end // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, textDirection: null == textDirection ? _self.textDirection : textDirection // ignore: cast_nullable_to_non_nullable @@ -222,21 +222,21 @@ class _StacPositioned implements StacPositioned { @override final StacPositionedType? positionedType; @override - final double? left; + final StacDouble? left; @override - final double? top; + final StacDouble? top; @override - final double? right; + final StacDouble? right; @override - final double? bottom; + final StacDouble? bottom; @override - final double? width; + final StacDouble? width; @override - final double? height; + final StacDouble? height; @override - final double? start; + final StacDouble? start; @override - final double? end; + final StacDouble? end; @override @JsonKey() final TextDirection textDirection; @@ -321,14 +321,14 @@ abstract mixin class _$StacPositionedCopyWith<$Res> @useResult $Res call( {StacPositionedType? positionedType, - double? left, - double? top, - double? right, - double? bottom, - double? width, - double? height, - double? start, - double? end, + StacDouble? left, + StacDouble? top, + StacDouble? right, + StacDouble? bottom, + StacDouble? width, + StacDouble? height, + StacDouble? start, + StacDouble? end, TextDirection textDirection, StacRect? rect, Map? child}); @@ -371,35 +371,35 @@ class __$StacPositionedCopyWithImpl<$Res> left: freezed == left ? _self.left : left // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, top: freezed == top ? _self.top : top // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, right: freezed == right ? _self.right : right // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, bottom: freezed == bottom ? _self.bottom : bottom // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, width: freezed == width ? _self.width : width // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, height: freezed == height ? _self.height : height // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, start: freezed == start ? _self.start : start // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, end: freezed == end ? _self.end : end // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, textDirection: null == textDirection ? _self.textDirection : textDirection // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_positioned/stac_positioned.g.dart b/packages/stac/lib/src/parsers/widgets/stac_positioned/stac_positioned.g.dart index 5a1b1959..770df654 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_positioned/stac_positioned.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_positioned/stac_positioned.g.dart @@ -10,14 +10,16 @@ _StacPositioned _$StacPositionedFromJson(Map json) => _StacPositioned( positionedType: $enumDecodeNullable( _$StacPositionedTypeEnumMap, json['positionedType']), - left: (json['left'] as num?)?.toDouble(), - top: (json['top'] as num?)?.toDouble(), - right: (json['right'] as num?)?.toDouble(), - bottom: (json['bottom'] as num?)?.toDouble(), - width: (json['width'] as num?)?.toDouble(), - height: (json['height'] as num?)?.toDouble(), - start: (json['start'] as num?)?.toDouble(), - end: (json['end'] as num?)?.toDouble(), + left: json['left'] == null ? null : StacDouble.fromJson(json['left']), + top: json['top'] == null ? null : StacDouble.fromJson(json['top']), + right: json['right'] == null ? null : StacDouble.fromJson(json['right']), + bottom: + json['bottom'] == null ? null : StacDouble.fromJson(json['bottom']), + width: json['width'] == null ? null : StacDouble.fromJson(json['width']), + height: + json['height'] == null ? null : StacDouble.fromJson(json['height']), + start: json['start'] == null ? null : StacDouble.fromJson(json['start']), + end: json['end'] == null ? null : StacDouble.fromJson(json['end']), textDirection: $enumDecodeNullable(_$TextDirectionEnumMap, json['textDirection']) ?? TextDirection.ltr, diff --git a/packages/stac/lib/src/parsers/widgets/stac_positioned/stac_positioned_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_positioned/stac_positioned_parser.dart index 2197c3e9..41b8f964 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_positioned/stac_positioned_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_positioned/stac_positioned_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_positioned/stac_positioned.dart'; import 'package:stac/src/parsers/widgets/stac_rect/stac_rect.dart'; import 'package:stac/src/utils/widget_type.dart'; @@ -21,19 +22,19 @@ class StacPositionedParser extends StacParser { case StacPositionedType.directional: return Positioned.directional( textDirection: model.textDirection, - top: model.top, - bottom: model.bottom, - height: model.height, - width: model.width, - start: model.start, - end: model.end, + top: model.top?.parse, + bottom: model.bottom?.parse, + height: model.height?.parse, + width: model.width?.parse, + start: model.start?.parse, + end: model.end?.parse, child: Stac.fromJson(model.child, context) ?? const SizedBox()); case StacPositionedType.fill: return Positioned.fill( - left: model.left, - top: model.top, - right: model.right, - bottom: model.bottom, + left: model.left?.parse, + top: model.top?.parse, + right: model.right?.parse, + bottom: model.bottom?.parse, child: Stac.fromJson(model.child, context) ?? const SizedBox()); case StacPositionedType.fromRect: return Positioned.fromRect( @@ -41,12 +42,12 @@ class StacPositionedParser extends StacParser { child: Stac.fromJson(model.child, context) ?? const SizedBox()); default: return Positioned( - left: model.left, - top: model.top, - right: model.right, - bottom: model.bottom, - height: model.height, - width: model.width, + left: model.left?.parse, + top: model.top?.parse, + right: model.right?.parse, + bottom: model.bottom?.parse, + height: model.height?.parse, + width: model.width?.parse, child: Stac.fromJson(model.child, context) ?? const SizedBox()); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_radio/stac_radio.dart b/packages/stac/lib/src/parsers/widgets/stac_radio/stac_radio.dart index 58f5ca1b..f48f713d 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_radio/stac_radio.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_radio/stac_radio.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_mouse_cursor/stac_mouse_cursor.dart'; import 'package:stac/src/parsers/widgets/stac_visual_density/stac_visual_density.dart'; @@ -24,7 +25,7 @@ abstract class StacRadio with _$StacRadio { String? focusColor, String? hoverColor, String? overlayColor, - double? splashRadius, + StacDouble? splashRadius, MaterialTapTargetSize? materialTapTargetSize, StacVisualDensity? visualDensity, @Default(false) bool autofocus, diff --git a/packages/stac/lib/src/parsers/widgets/stac_radio/stac_radio.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_radio/stac_radio.freezed.dart index 376a39f8..f22a0f74 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_radio/stac_radio.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_radio/stac_radio.freezed.dart @@ -26,7 +26,7 @@ mixin _$StacRadio { String? get focusColor; String? get hoverColor; String? get overlayColor; - double? get splashRadius; + StacDouble? get splashRadius; MaterialTapTargetSize? get materialTapTargetSize; StacVisualDensity? get visualDensity; bool get autofocus; @@ -129,7 +129,7 @@ abstract mixin class $StacRadioCopyWith<$Res> { String? focusColor, String? hoverColor, String? overlayColor, - double? splashRadius, + StacDouble? splashRadius, MaterialTapTargetSize? materialTapTargetSize, StacVisualDensity? visualDensity, bool autofocus, @@ -217,7 +217,7 @@ class _$StacRadioCopyWithImpl<$Res> implements $StacRadioCopyWith<$Res> { splashRadius: freezed == splashRadius ? _self.splashRadius : splashRadius // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, materialTapTargetSize: freezed == materialTapTargetSize ? _self.materialTapTargetSize : materialTapTargetSize // ignore: cast_nullable_to_non_nullable @@ -314,7 +314,7 @@ class _StacRadio implements StacRadio { @override final String? overlayColor; @override - final double? splashRadius; + final StacDouble? splashRadius; @override final MaterialTapTargetSize? materialTapTargetSize; @override @@ -434,7 +434,7 @@ abstract mixin class _$StacRadioCopyWith<$Res> String? focusColor, String? hoverColor, String? overlayColor, - double? splashRadius, + StacDouble? splashRadius, MaterialTapTargetSize? materialTapTargetSize, StacVisualDensity? visualDensity, bool autofocus, @@ -523,7 +523,7 @@ class __$StacRadioCopyWithImpl<$Res> implements _$StacRadioCopyWith<$Res> { splashRadius: freezed == splashRadius ? _self.splashRadius : splashRadius // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, materialTapTargetSize: freezed == materialTapTargetSize ? _self.materialTapTargetSize : materialTapTargetSize // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_radio/stac_radio.g.dart b/packages/stac/lib/src/parsers/widgets/stac_radio/stac_radio.g.dart index dc3c783a..88e1c7c3 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_radio/stac_radio.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_radio/stac_radio.g.dart @@ -21,7 +21,9 @@ _StacRadio _$StacRadioFromJson(Map json) => _StacRadio( focusColor: json['focusColor'] as String?, hoverColor: json['hoverColor'] as String?, overlayColor: json['overlayColor'] as String?, - splashRadius: (json['splashRadius'] as num?)?.toDouble(), + splashRadius: json['splashRadius'] == null + ? null + : StacDouble.fromJson(json['splashRadius']), materialTapTargetSize: $enumDecodeNullable( _$MaterialTapTargetSizeEnumMap, json['materialTapTargetSize']), visualDensity: json['visualDensity'] == null diff --git a/packages/stac/lib/src/parsers/widgets/stac_radio/stac_radio_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_radio/stac_radio_parser.dart index bf6b3548..8358877a 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_radio/stac_radio_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_radio/stac_radio_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_radio_group/stac_radio_group_scope.dart'; import 'package:stac/src/parsers/widgets/stac_visual_density/stac_visual_density.dart'; import 'package:stac/src/utils/widget_type.dart'; @@ -104,7 +105,7 @@ class _RadioWidget extends StatelessWidget { overlayColor: WidgetStateProperty.all( model.overlayColor?.toColor(context), ), - splashRadius: model.splashRadius, + splashRadius: model.splashRadius?.parse, materialTapTargetSize: model.materialTapTargetSize, visualDensity: model.visualDensity?.parse, focusNode: focusNode, @@ -138,7 +139,7 @@ class _RadioWidget extends StatelessWidget { overlayColor: WidgetStateProperty.all( model.overlayColor?.toColor(context), ), - splashRadius: model.splashRadius, + splashRadius: model.splashRadius?.parse, materialTapTargetSize: model.materialTapTargetSize, visualDensity: model.visualDensity?.parse, focusNode: focusNode, diff --git a/packages/stac/lib/src/parsers/widgets/stac_rect/stac_rect.dart b/packages/stac/lib/src/parsers/widgets/stac_rect/stac_rect.dart index 7b815ad5..da82c166 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_rect/stac_rect.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_rect/stac_rect.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_offset/stac_offset.dart'; part 'stac_rect.freezed.dart'; @@ -14,13 +15,13 @@ abstract class StacRect with _$StacRect { StacOffset? center, StacOffset? a, StacOffset? b, - double? width, - double? height, - double? left, - double? top, - double? right, - double? bottom, - double? radius, + StacDouble? width, + StacDouble? height, + StacDouble? left, + StacDouble? top, + StacDouble? right, + StacDouble? bottom, + StacDouble? radius, }) = _StacRect; factory StacRect.fromJson(Map json) => @@ -31,24 +32,24 @@ extension StacRectParser on StacRect { Rect? get parse { Rect fromCenter() => Rect.fromCenter( center: center?.parse ?? Offset.zero, - width: width ?? 0.0, - height: height ?? 0.0, + width: width?.parse ?? 0.0, + height: height?.parse ?? 0.0, ); Rect fromCircle() => Rect.fromCircle( center: center?.parse ?? Offset.zero, - radius: radius ?? 0.0, + radius: radius?.parse ?? 0.0, ); Rect fromLTRB() => Rect.fromLTRB( - left ?? 0.0, - top ?? 0.0, - right ?? 0.0, - bottom ?? 0.0, + left?.parse ?? 0.0, + top?.parse ?? 0.0, + right?.parse ?? 0.0, + bottom?.parse ?? 0.0, ); Rect fromLTWH() => Rect.fromLTWH( - left ?? 0.0, - top ?? 0.0, - width ?? 0.0, - height ?? 0.0, + left?.parse ?? 0.0, + top?.parse ?? 0.0, + width?.parse ?? 0.0, + height?.parse ?? 0.0, ); Rect fromPoints() => Rect.fromPoints( a?.parse ?? Offset.zero, diff --git a/packages/stac/lib/src/parsers/widgets/stac_rect/stac_rect.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_rect/stac_rect.freezed.dart index d29696eb..eabee5f6 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_rect/stac_rect.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_rect/stac_rect.freezed.dart @@ -19,13 +19,13 @@ mixin _$StacRect { StacOffset? get center; StacOffset? get a; StacOffset? get b; - double? get width; - double? get height; - double? get left; - double? get top; - double? get right; - double? get bottom; - double? get radius; + StacDouble? get width; + StacDouble? get height; + StacDouble? get left; + StacDouble? get top; + StacDouble? get right; + StacDouble? get bottom; + StacDouble? get radius; /// Create a copy of StacRect /// with the given fields replaced by the non-null parameter values. @@ -77,13 +77,13 @@ abstract mixin class $StacRectCopyWith<$Res> { StacOffset? center, StacOffset? a, StacOffset? b, - double? width, - double? height, - double? left, - double? top, - double? right, - double? bottom, - double? radius}); + StacDouble? width, + StacDouble? height, + StacDouble? left, + StacDouble? top, + StacDouble? right, + StacDouble? bottom, + StacDouble? radius}); $StacOffsetCopyWith<$Res>? get center; $StacOffsetCopyWith<$Res>? get a; @@ -134,31 +134,31 @@ class _$StacRectCopyWithImpl<$Res> implements $StacRectCopyWith<$Res> { width: freezed == width ? _self.width : width // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, height: freezed == height ? _self.height : height // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, left: freezed == left ? _self.left : left // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, top: freezed == top ? _self.top : top // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, right: freezed == right ? _self.right : right // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, bottom: freezed == bottom ? _self.bottom : bottom // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, radius: freezed == radius ? _self.radius : radius // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, )); } @@ -232,19 +232,19 @@ class _StacRect implements StacRect { @override final StacOffset? b; @override - final double? width; + final StacDouble? width; @override - final double? height; + final StacDouble? height; @override - final double? left; + final StacDouble? left; @override - final double? top; + final StacDouble? top; @override - final double? right; + final StacDouble? right; @override - final double? bottom; + final StacDouble? bottom; @override - final double? radius; + final StacDouble? radius; /// Create a copy of StacRect /// with the given fields replaced by the non-null parameter values. @@ -303,13 +303,13 @@ abstract mixin class _$StacRectCopyWith<$Res> StacOffset? center, StacOffset? a, StacOffset? b, - double? width, - double? height, - double? left, - double? top, - double? right, - double? bottom, - double? radius}); + StacDouble? width, + StacDouble? height, + StacDouble? left, + StacDouble? top, + StacDouble? right, + StacDouble? bottom, + StacDouble? radius}); @override $StacOffsetCopyWith<$Res>? get center; @@ -363,31 +363,31 @@ class __$StacRectCopyWithImpl<$Res> implements _$StacRectCopyWith<$Res> { width: freezed == width ? _self.width : width // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, height: freezed == height ? _self.height : height // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, left: freezed == left ? _self.left : left // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, top: freezed == top ? _self.top : top // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, right: freezed == right ? _self.right : right // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, bottom: freezed == bottom ? _self.bottom : bottom // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, radius: freezed == radius ? _self.radius : radius // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, )); } diff --git a/packages/stac/lib/src/parsers/widgets/stac_rect/stac_rect.g.dart b/packages/stac/lib/src/parsers/widgets/stac_rect/stac_rect.g.dart index ed95482b..79116204 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_rect/stac_rect.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_rect/stac_rect.g.dart @@ -17,13 +17,16 @@ _StacRect _$StacRectFromJson(Map json) => _StacRect( b: json['b'] == null ? null : StacOffset.fromJson(json['b'] as Map), - width: (json['width'] as num?)?.toDouble(), - height: (json['height'] as num?)?.toDouble(), - left: (json['left'] as num?)?.toDouble(), - top: (json['top'] as num?)?.toDouble(), - right: (json['right'] as num?)?.toDouble(), - bottom: (json['bottom'] as num?)?.toDouble(), - radius: (json['radius'] as num?)?.toDouble(), + width: json['width'] == null ? null : StacDouble.fromJson(json['width']), + height: + json['height'] == null ? null : StacDouble.fromJson(json['height']), + left: json['left'] == null ? null : StacDouble.fromJson(json['left']), + top: json['top'] == null ? null : StacDouble.fromJson(json['top']), + right: json['right'] == null ? null : StacDouble.fromJson(json['right']), + bottom: + json['bottom'] == null ? null : StacDouble.fromJson(json['bottom']), + radius: + json['radius'] == null ? null : StacDouble.fromJson(json['radius']), ); Map _$StacRectToJson(_StacRect instance) => { diff --git a/packages/stac/lib/src/parsers/widgets/stac_refresh_indicator/stac_refresh_indicator.dart b/packages/stac/lib/src/parsers/widgets/stac_refresh_indicator/stac_refresh_indicator.dart index 8968ae85..180a654b 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_refresh_indicator/stac_refresh_indicator.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_refresh_indicator/stac_refresh_indicator.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; export 'stac_refresh_indicator_parser.dart'; @@ -10,14 +11,15 @@ part 'stac_refresh_indicator.g.dart'; abstract class StacRefreshIndicator with _$StacRefreshIndicator { const factory StacRefreshIndicator({ Map? child, - @Default(40) double displacement, - @Default(0) double edgeOffset, + @Default(StacDouble(40)) StacDouble displacement, + @Default(StacDouble.zero) StacDouble edgeOffset, Map? onRefresh, String? color, String? backgroundColor, String? semanticsLabel, String? semanticsValue, - @Default(RefreshProgressIndicator.defaultStrokeWidth) double strokeWidth, + @Default(StacDouble(RefreshProgressIndicator.defaultStrokeWidth)) + StacDouble strokeWidth, @Default(RefreshIndicatorTriggerMode.onEdge) RefreshIndicatorTriggerMode triggerMode, }) = _StacRefreshIndicator; diff --git a/packages/stac/lib/src/parsers/widgets/stac_refresh_indicator/stac_refresh_indicator.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_refresh_indicator/stac_refresh_indicator.freezed.dart index 4cd629f6..ad04ada9 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_refresh_indicator/stac_refresh_indicator.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_refresh_indicator/stac_refresh_indicator.freezed.dart @@ -16,14 +16,14 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacRefreshIndicator { Map? get child; - double get displacement; - double get edgeOffset; + StacDouble get displacement; + StacDouble get edgeOffset; Map? get onRefresh; String? get color; String? get backgroundColor; String? get semanticsLabel; String? get semanticsValue; - double get strokeWidth; + StacDouble get strokeWidth; RefreshIndicatorTriggerMode get triggerMode; /// Create a copy of StacRefreshIndicator @@ -90,14 +90,14 @@ abstract mixin class $StacRefreshIndicatorCopyWith<$Res> { @useResult $Res call( {Map? child, - double displacement, - double edgeOffset, + StacDouble displacement, + StacDouble edgeOffset, Map? onRefresh, String? color, String? backgroundColor, String? semanticsLabel, String? semanticsValue, - double strokeWidth, + StacDouble strokeWidth, RefreshIndicatorTriggerMode triggerMode}); } @@ -133,11 +133,11 @@ class _$StacRefreshIndicatorCopyWithImpl<$Res> displacement: null == displacement ? _self.displacement : displacement // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, edgeOffset: null == edgeOffset ? _self.edgeOffset : edgeOffset // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, onRefresh: freezed == onRefresh ? _self.onRefresh : onRefresh // ignore: cast_nullable_to_non_nullable @@ -161,7 +161,7 @@ class _$StacRefreshIndicatorCopyWithImpl<$Res> strokeWidth: null == strokeWidth ? _self.strokeWidth : strokeWidth // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, triggerMode: null == triggerMode ? _self.triggerMode : triggerMode // ignore: cast_nullable_to_non_nullable @@ -175,14 +175,15 @@ class _$StacRefreshIndicatorCopyWithImpl<$Res> class _StacRefreshIndicator implements StacRefreshIndicator { const _StacRefreshIndicator( {final Map? child, - this.displacement = 40, - this.edgeOffset = 0, + this.displacement = const StacDouble(40), + this.edgeOffset = StacDouble.zero, final Map? onRefresh, this.color, this.backgroundColor, this.semanticsLabel, this.semanticsValue, - this.strokeWidth = RefreshProgressIndicator.defaultStrokeWidth, + this.strokeWidth = + const StacDouble(RefreshProgressIndicator.defaultStrokeWidth), this.triggerMode = RefreshIndicatorTriggerMode.onEdge}) : _child = child, _onRefresh = onRefresh; @@ -201,10 +202,10 @@ class _StacRefreshIndicator implements StacRefreshIndicator { @override @JsonKey() - final double displacement; + final StacDouble displacement; @override @JsonKey() - final double edgeOffset; + final StacDouble edgeOffset; final Map? _onRefresh; @override Map? get onRefresh { @@ -225,7 +226,7 @@ class _StacRefreshIndicator implements StacRefreshIndicator { final String? semanticsValue; @override @JsonKey() - final double strokeWidth; + final StacDouble strokeWidth; @override @JsonKey() final RefreshIndicatorTriggerMode triggerMode; @@ -302,14 +303,14 @@ abstract mixin class _$StacRefreshIndicatorCopyWith<$Res> @useResult $Res call( {Map? child, - double displacement, - double edgeOffset, + StacDouble displacement, + StacDouble edgeOffset, Map? onRefresh, String? color, String? backgroundColor, String? semanticsLabel, String? semanticsValue, - double strokeWidth, + StacDouble strokeWidth, RefreshIndicatorTriggerMode triggerMode}); } @@ -345,11 +346,11 @@ class __$StacRefreshIndicatorCopyWithImpl<$Res> displacement: null == displacement ? _self.displacement : displacement // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, edgeOffset: null == edgeOffset ? _self.edgeOffset : edgeOffset // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, onRefresh: freezed == onRefresh ? _self._onRefresh : onRefresh // ignore: cast_nullable_to_non_nullable @@ -373,7 +374,7 @@ class __$StacRefreshIndicatorCopyWithImpl<$Res> strokeWidth: null == strokeWidth ? _self.strokeWidth : strokeWidth // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, triggerMode: null == triggerMode ? _self.triggerMode : triggerMode // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_refresh_indicator/stac_refresh_indicator.g.dart b/packages/stac/lib/src/parsers/widgets/stac_refresh_indicator/stac_refresh_indicator.g.dart index e1d2f157..435c7239 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_refresh_indicator/stac_refresh_indicator.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_refresh_indicator/stac_refresh_indicator.g.dart @@ -10,15 +10,20 @@ _StacRefreshIndicator _$StacRefreshIndicatorFromJson( Map json) => _StacRefreshIndicator( child: json['child'] as Map?, - displacement: (json['displacement'] as num?)?.toDouble() ?? 40, - edgeOffset: (json['edgeOffset'] as num?)?.toDouble() ?? 0, + displacement: json['displacement'] == null + ? const StacDouble(40) + : StacDouble.fromJson(json['displacement']), + edgeOffset: json['edgeOffset'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['edgeOffset']), onRefresh: json['onRefresh'] as Map?, color: json['color'] as String?, backgroundColor: json['backgroundColor'] as String?, semanticsLabel: json['semanticsLabel'] as String?, semanticsValue: json['semanticsValue'] as String?, - strokeWidth: (json['strokeWidth'] as num?)?.toDouble() ?? - RefreshProgressIndicator.defaultStrokeWidth, + strokeWidth: json['strokeWidth'] == null + ? const StacDouble(RefreshProgressIndicator.defaultStrokeWidth) + : StacDouble.fromJson(json['strokeWidth']), triggerMode: $enumDecodeNullable( _$RefreshIndicatorTriggerModeEnumMap, json['triggerMode']) ?? RefreshIndicatorTriggerMode.onEdge, diff --git a/packages/stac/lib/src/parsers/widgets/stac_refresh_indicator/stac_refresh_indicator_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_refresh_indicator/stac_refresh_indicator_parser.dart index b0266197..7bcbe429 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_refresh_indicator/stac_refresh_indicator_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_refresh_indicator/stac_refresh_indicator_parser.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_refresh_indicator/stac_refresh_indicator.dart'; import 'package:stac/src/utils/color_utils.dart'; import 'package:stac/src/utils/widget_type.dart'; @@ -45,8 +46,8 @@ class _RefreshIndicatorWidgetState extends State<_RefreshIndicatorWidget> { @override Widget build(BuildContext context) { return RefreshIndicator( - displacement: widget.model.displacement, - edgeOffset: widget.model.edgeOffset, + displacement: widget.model.displacement.parse, + edgeOffset: widget.model.edgeOffset.parse, onRefresh: () async { Response result = await Stac.onCallFromJson(widget.model.onRefresh, context); @@ -69,7 +70,7 @@ class _RefreshIndicatorWidgetState extends State<_RefreshIndicatorWidget> { backgroundColor: widget.model.backgroundColor.toColor(context), semanticsLabel: widget.model.semanticsLabel, semanticsValue: widget.model.semanticsValue, - strokeWidth: widget.model.strokeWidth, + strokeWidth: widget.model.strokeWidth.parse, triggerMode: widget.model.triggerMode, child: Stac.fromJson(childWidgetJson, context) ?? const SizedBox(), ); diff --git a/packages/stac/lib/src/parsers/widgets/stac_row/stac_row.dart b/packages/stac/lib/src/parsers/widgets/stac_row/stac_row.dart index b57f5840..dfa9fb28 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_row/stac_row.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_row/stac_row.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; export 'package:stac/src/parsers/widgets/stac_row/stac_row_parser.dart'; @@ -14,7 +15,7 @@ abstract class StacRow with _$StacRow { @Default(MainAxisSize.max) MainAxisSize mainAxisSize, TextDirection? textDirection, @Default(VerticalDirection.down) VerticalDirection verticalDirection, - @Default(0) double spacing, + @Default(StacDouble.zero) StacDouble spacing, @Default([]) List> children, }) = _StacRow; diff --git a/packages/stac/lib/src/parsers/widgets/stac_row/stac_row.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_row/stac_row.freezed.dart index 7db45976..e6731908 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_row/stac_row.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_row/stac_row.freezed.dart @@ -20,7 +20,7 @@ mixin _$StacRow { MainAxisSize get mainAxisSize; TextDirection? get textDirection; VerticalDirection get verticalDirection; - double get spacing; + StacDouble get spacing; List> get children; /// Create a copy of StacRow @@ -81,7 +81,7 @@ abstract mixin class $StacRowCopyWith<$Res> { MainAxisSize mainAxisSize, TextDirection? textDirection, VerticalDirection verticalDirection, - double spacing, + StacDouble spacing, List> children}); } @@ -129,7 +129,7 @@ class _$StacRowCopyWithImpl<$Res> implements $StacRowCopyWith<$Res> { spacing: null == spacing ? _self.spacing : spacing // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, children: null == children ? _self.children : children // ignore: cast_nullable_to_non_nullable @@ -147,7 +147,7 @@ class _StacRow implements StacRow { this.mainAxisSize = MainAxisSize.max, this.textDirection, this.verticalDirection = VerticalDirection.down, - this.spacing = 0, + this.spacing = StacDouble.zero, final List> children = const []}) : _children = children; factory _StacRow.fromJson(Map json) => @@ -169,7 +169,7 @@ class _StacRow implements StacRow { final VerticalDirection verticalDirection; @override @JsonKey() - final double spacing; + final StacDouble spacing; final List> _children; @override @JsonKey() @@ -243,7 +243,7 @@ abstract mixin class _$StacRowCopyWith<$Res> implements $StacRowCopyWith<$Res> { MainAxisSize mainAxisSize, TextDirection? textDirection, VerticalDirection verticalDirection, - double spacing, + StacDouble spacing, List> children}); } @@ -291,7 +291,7 @@ class __$StacRowCopyWithImpl<$Res> implements _$StacRowCopyWith<$Res> { spacing: null == spacing ? _self.spacing : spacing // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, children: null == children ? _self._children : children // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_row/stac_row.g.dart b/packages/stac/lib/src/parsers/widgets/stac_row/stac_row.g.dart index 0eb1fee0..e7cfb9e3 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_row/stac_row.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_row/stac_row.g.dart @@ -21,7 +21,9 @@ _StacRow _$StacRowFromJson(Map json) => _StacRow( verticalDirection: $enumDecodeNullable( _$VerticalDirectionEnumMap, json['verticalDirection']) ?? VerticalDirection.down, - spacing: (json['spacing'] as num?)?.toDouble() ?? 0, + spacing: json['spacing'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['spacing']), children: (json['children'] as List?) ?.map((e) => e as Map) .toList() ?? diff --git a/packages/stac/lib/src/parsers/widgets/stac_row/stac_row_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_row/stac_row_parser.dart index 1c553a03..23fb35e2 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_row/stac_row_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_row/stac_row_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_row/stac_row.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; @@ -21,7 +22,7 @@ class StacRowParser extends StacParser { mainAxisSize: model.mainAxisSize, textDirection: model.textDirection, verticalDirection: model.verticalDirection, - spacing: model.spacing, + spacing: model.spacing.parse, children: model.children .map((value) => Stac.fromJson(value, context) ?? const SizedBox()) .toList(), diff --git a/packages/stac/lib/src/parsers/widgets/stac_scaffold/stac_scaffold.dart b/packages/stac/lib/src/parsers/widgets/stac_scaffold/stac_scaffold.dart index ee451941..fe3afb03 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_scaffold/stac_scaffold.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_scaffold/stac_scaffold.dart @@ -1,5 +1,6 @@ import 'package:flutter/gestures.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/button_utils.dart'; export 'stac_scaffold_parser.dart'; @@ -26,7 +27,7 @@ abstract class StacScaffold with _$StacScaffold { @Default(false) bool extendBody, @Default(false) bool extendBodyBehindAppBar, String? drawerScrimColor, - double? drawerEdgeDragWidth, + StacDouble? drawerEdgeDragWidth, @Default(true) bool drawerEnableOpenDragGesture, @Default(true) bool endDrawerEnableOpenDragGesture, String? restorationId, diff --git a/packages/stac/lib/src/parsers/widgets/stac_scaffold/stac_scaffold.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_scaffold/stac_scaffold.freezed.dart index 8bba3523..e1ca44a4 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_scaffold/stac_scaffold.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_scaffold/stac_scaffold.freezed.dart @@ -31,7 +31,7 @@ mixin _$StacScaffold { bool get extendBody; bool get extendBodyBehindAppBar; String? get drawerScrimColor; - double? get drawerEdgeDragWidth; + StacDouble? get drawerEdgeDragWidth; bool get drawerEnableOpenDragGesture; bool get endDrawerEnableOpenDragGesture; String? get restorationId; @@ -150,7 +150,7 @@ abstract mixin class $StacScaffoldCopyWith<$Res> { bool extendBody, bool extendBodyBehindAppBar, String? drawerScrimColor, - double? drawerEdgeDragWidth, + StacDouble? drawerEdgeDragWidth, bool drawerEnableOpenDragGesture, bool endDrawerEnableOpenDragGesture, String? restorationId}); @@ -257,7 +257,7 @@ class _$StacScaffoldCopyWithImpl<$Res> implements $StacScaffoldCopyWith<$Res> { drawerEdgeDragWidth: freezed == drawerEdgeDragWidth ? _self.drawerEdgeDragWidth : drawerEdgeDragWidth // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, drawerEnableOpenDragGesture: null == drawerEnableOpenDragGesture ? _self.drawerEnableOpenDragGesture : drawerEnableOpenDragGesture // ignore: cast_nullable_to_non_nullable @@ -413,7 +413,7 @@ class _StacScaffold implements StacScaffold { @override final String? drawerScrimColor; @override - final double? drawerEdgeDragWidth; + final StacDouble? drawerEdgeDragWidth; @override @JsonKey() final bool drawerEnableOpenDragGesture; @@ -543,7 +543,7 @@ abstract mixin class _$StacScaffoldCopyWith<$Res> bool extendBody, bool extendBodyBehindAppBar, String? drawerScrimColor, - double? drawerEdgeDragWidth, + StacDouble? drawerEdgeDragWidth, bool drawerEnableOpenDragGesture, bool endDrawerEnableOpenDragGesture, String? restorationId}); @@ -651,7 +651,7 @@ class __$StacScaffoldCopyWithImpl<$Res> drawerEdgeDragWidth: freezed == drawerEdgeDragWidth ? _self.drawerEdgeDragWidth : drawerEdgeDragWidth // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, drawerEnableOpenDragGesture: null == drawerEnableOpenDragGesture ? _self.drawerEnableOpenDragGesture : drawerEnableOpenDragGesture // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_scaffold/stac_scaffold.g.dart b/packages/stac/lib/src/parsers/widgets/stac_scaffold/stac_scaffold.g.dart index 95aa42dd..54ada69d 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_scaffold/stac_scaffold.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_scaffold/stac_scaffold.g.dart @@ -32,7 +32,9 @@ _StacScaffold _$StacScaffoldFromJson(Map json) => extendBody: json['extendBody'] as bool? ?? false, extendBodyBehindAppBar: json['extendBodyBehindAppBar'] as bool? ?? false, drawerScrimColor: json['drawerScrimColor'] as String?, - drawerEdgeDragWidth: (json['drawerEdgeDragWidth'] as num?)?.toDouble(), + drawerEdgeDragWidth: json['drawerEdgeDragWidth'] == null + ? null + : StacDouble.fromJson(json['drawerEdgeDragWidth']), drawerEnableOpenDragGesture: json['drawerEnableOpenDragGesture'] as bool? ?? true, endDrawerEnableOpenDragGesture: diff --git a/packages/stac/lib/src/parsers/widgets/stac_scaffold/stac_scaffold_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_scaffold/stac_scaffold_parser.dart index 98f3d5bb..d3e86373 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_scaffold/stac_scaffold_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_scaffold/stac_scaffold_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_scaffold/stac_scaffold.dart'; import 'package:stac/src/utils/color_utils.dart'; import 'package:stac/src/utils/widget_type.dart'; @@ -36,7 +37,7 @@ class StacScaffoldParser extends StacParser { extendBody: model.extendBody, extendBodyBehindAppBar: model.extendBodyBehindAppBar, drawerScrimColor: model.drawerScrimColor.toColor(context), - drawerEdgeDragWidth: model.drawerEdgeDragWidth, + drawerEdgeDragWidth: model.drawerEdgeDragWidth?.parse, drawerEnableOpenDragGesture: model.drawerEnableOpenDragGesture, endDrawerEnableOpenDragGesture: model.endDrawerEnableOpenDragGesture, ); diff --git a/packages/stac/lib/src/parsers/widgets/stac_shadow/stac_shadow.dart b/packages/stac/lib/src/parsers/widgets/stac_shadow/stac_shadow.dart index 56ef7464..ee183345 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_shadow/stac_shadow.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_shadow/stac_shadow.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_offset/stac_offset.dart'; import 'package:stac/src/utils/color_utils.dart'; @@ -10,8 +11,9 @@ part 'stac_shadow.g.dart'; abstract class StacShadow with _$StacShadow { const factory StacShadow({ @Default('#000000') String color, - @Default(StacOffset(dx: 0, dy: 0)) StacOffset offset, - @Default(0.0) double blurRadius, + @Default(StacOffset(dx: StacDouble.zero, dy: StacDouble.zero)) + StacOffset offset, + @Default(StacDouble.zero) StacDouble blurRadius, }) = _StacShadow; factory StacShadow.fromJson(Map json) => @@ -23,7 +25,7 @@ extension StacShadowParser on StacShadow { return Shadow( color: color.toColor(context)!, offset: offset.parse, - blurRadius: blurRadius, + blurRadius: blurRadius.parse, ); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_shadow/stac_shadow.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_shadow/stac_shadow.freezed.dart index c371f8cd..311a6408 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_shadow/stac_shadow.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_shadow/stac_shadow.freezed.dart @@ -17,7 +17,7 @@ T _$identity(T value) => value; mixin _$StacShadow { String get color; StacOffset get offset; - double get blurRadius; + StacDouble get blurRadius; /// Create a copy of StacShadow /// with the given fields replaced by the non-null parameter values. @@ -56,7 +56,7 @@ abstract mixin class $StacShadowCopyWith<$Res> { StacShadow value, $Res Function(StacShadow) _then) = _$StacShadowCopyWithImpl; @useResult - $Res call({String color, StacOffset offset, double blurRadius}); + $Res call({String color, StacOffset offset, StacDouble blurRadius}); $StacOffsetCopyWith<$Res> get offset; } @@ -89,7 +89,7 @@ class _$StacShadowCopyWithImpl<$Res> implements $StacShadowCopyWith<$Res> { blurRadius: null == blurRadius ? _self.blurRadius : blurRadius // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, )); } @@ -109,8 +109,8 @@ class _$StacShadowCopyWithImpl<$Res> implements $StacShadowCopyWith<$Res> { class _StacShadow implements StacShadow { const _StacShadow( {this.color = '#000000', - this.offset = const StacOffset(dx: 0, dy: 0), - this.blurRadius = 0.0}); + this.offset = const StacOffset(dx: StacDouble.zero, dy: StacDouble.zero), + this.blurRadius = StacDouble.zero}); factory _StacShadow.fromJson(Map json) => _$StacShadowFromJson(json); @@ -122,7 +122,7 @@ class _StacShadow implements StacShadow { final StacOffset offset; @override @JsonKey() - final double blurRadius; + final StacDouble blurRadius; /// Create a copy of StacShadow /// with the given fields replaced by the non-null parameter values. @@ -168,7 +168,7 @@ abstract mixin class _$StacShadowCopyWith<$Res> __$StacShadowCopyWithImpl; @override @useResult - $Res call({String color, StacOffset offset, double blurRadius}); + $Res call({String color, StacOffset offset, StacDouble blurRadius}); @override $StacOffsetCopyWith<$Res> get offset; @@ -202,7 +202,7 @@ class __$StacShadowCopyWithImpl<$Res> implements _$StacShadowCopyWith<$Res> { blurRadius: null == blurRadius ? _self.blurRadius : blurRadius // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, )); } diff --git a/packages/stac/lib/src/parsers/widgets/stac_shadow/stac_shadow.g.dart b/packages/stac/lib/src/parsers/widgets/stac_shadow/stac_shadow.g.dart index 25f7765b..b1953283 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_shadow/stac_shadow.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_shadow/stac_shadow.g.dart @@ -9,9 +9,11 @@ part of 'stac_shadow.dart'; _StacShadow _$StacShadowFromJson(Map json) => _StacShadow( color: json['color'] as String? ?? '#000000', offset: json['offset'] == null - ? const StacOffset(dx: 0, dy: 0) + ? const StacOffset(dx: StacDouble.zero, dy: StacDouble.zero) : StacOffset.fromJson(json['offset'] as Map), - blurRadius: (json['blurRadius'] as num?)?.toDouble() ?? 0.0, + blurRadius: json['blurRadius'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['blurRadius']), ); Map _$StacShadowToJson(_StacShadow instance) => diff --git a/packages/stac/lib/src/parsers/widgets/stac_shape_border/stac_circle_border.dart b/packages/stac/lib/src/parsers/widgets/stac_shape_border/stac_circle_border.dart index b94ff3b0..37fa0d2a 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_shape_border/stac_circle_border.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_shape_border/stac_circle_border.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/stac.dart'; part 'stac_circle_border.freezed.dart'; @@ -9,7 +10,7 @@ part 'stac_circle_border.g.dart'; abstract class StacCircleBorder with _$StacCircleBorder { const factory StacCircleBorder({ @Default(StacBorderSide.none) StacBorderSide side, - @Default(0.0) double eccentricity, + @Default(StacDouble.zero) StacDouble eccentricity, }) = _StacCircleBorder; factory StacCircleBorder.fromJson(Map json) => @@ -20,7 +21,7 @@ extension StacCircleBorderParser on StacCircleBorder { ShapeBorder parse(BuildContext context) { return CircleBorder( side: side.parse(context), - eccentricity: eccentricity, + eccentricity: eccentricity.parse, ); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_shape_border/stac_circle_border.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_shape_border/stac_circle_border.freezed.dart index 4a9b2187..51e2feee 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_shape_border/stac_circle_border.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_shape_border/stac_circle_border.freezed.dart @@ -16,7 +16,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacCircleBorder { StacBorderSide get side; - double get eccentricity; + StacDouble get eccentricity; /// Create a copy of StacCircleBorder /// with the given fields replaced by the non-null parameter values. @@ -55,7 +55,7 @@ abstract mixin class $StacCircleBorderCopyWith<$Res> { StacCircleBorder value, $Res Function(StacCircleBorder) _then) = _$StacCircleBorderCopyWithImpl; @useResult - $Res call({StacBorderSide side, double eccentricity}); + $Res call({StacBorderSide side, StacDouble eccentricity}); $StacBorderSideCopyWith<$Res> get side; } @@ -84,7 +84,7 @@ class _$StacCircleBorderCopyWithImpl<$Res> eccentricity: null == eccentricity ? _self.eccentricity : eccentricity // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, )); } @@ -103,7 +103,7 @@ class _$StacCircleBorderCopyWithImpl<$Res> @JsonSerializable() class _StacCircleBorder implements StacCircleBorder { const _StacCircleBorder( - {this.side = StacBorderSide.none, this.eccentricity = 0.0}); + {this.side = StacBorderSide.none, this.eccentricity = StacDouble.zero}); factory _StacCircleBorder.fromJson(Map json) => _$StacCircleBorderFromJson(json); @@ -112,7 +112,7 @@ class _StacCircleBorder implements StacCircleBorder { final StacBorderSide side; @override @JsonKey() - final double eccentricity; + final StacDouble eccentricity; /// Create a copy of StacCircleBorder /// with the given fields replaced by the non-null parameter values. @@ -157,7 +157,7 @@ abstract mixin class _$StacCircleBorderCopyWith<$Res> __$StacCircleBorderCopyWithImpl; @override @useResult - $Res call({StacBorderSide side, double eccentricity}); + $Res call({StacBorderSide side, StacDouble eccentricity}); @override $StacBorderSideCopyWith<$Res> get side; @@ -187,7 +187,7 @@ class __$StacCircleBorderCopyWithImpl<$Res> eccentricity: null == eccentricity ? _self.eccentricity : eccentricity // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, )); } diff --git a/packages/stac/lib/src/parsers/widgets/stac_shape_border/stac_circle_border.g.dart b/packages/stac/lib/src/parsers/widgets/stac_shape_border/stac_circle_border.g.dart index 328b53a5..314035d1 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_shape_border/stac_circle_border.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_shape_border/stac_circle_border.g.dart @@ -11,7 +11,9 @@ _StacCircleBorder _$StacCircleBorderFromJson(Map json) => side: json['side'] == null ? StacBorderSide.none : StacBorderSide.fromJson(json['side'] as Map), - eccentricity: (json['eccentricity'] as num?)?.toDouble() ?? 0.0, + eccentricity: json['eccentricity'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['eccentricity']), ); Map _$StacCircleBorderToJson(_StacCircleBorder instance) => diff --git a/packages/stac/lib/src/parsers/widgets/stac_size/stac_size.dart b/packages/stac/lib/src/parsers/widgets/stac_size/stac_size.dart index f0425057..15a51e46 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_size/stac_size.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_size/stac_size.dart @@ -1,6 +1,7 @@ import 'dart:ui'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; part 'stac_size.freezed.dart'; part 'stac_size.g.dart'; @@ -8,8 +9,8 @@ part 'stac_size.g.dart'; @freezed abstract class StacSize with _$StacSize { const factory StacSize({ - required double width, - required double height, + required StacDouble width, + required StacDouble height, }) = _StacSize; factory StacSize.fromJson(Map json) => @@ -18,6 +19,6 @@ abstract class StacSize with _$StacSize { extension StacSizeParser on StacSize? { Size get parse { - return Size(this?.width ?? 0, this?.height ?? 0); + return Size(this?.width.parse ?? 0, this?.height.parse ?? 0); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_size/stac_size.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_size/stac_size.freezed.dart index 9adb735a..302f259f 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_size/stac_size.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_size/stac_size.freezed.dart @@ -15,8 +15,8 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacSize { - double get width; - double get height; + StacDouble get width; + StacDouble get height; /// Create a copy of StacSize /// with the given fields replaced by the non-null parameter values. @@ -52,7 +52,7 @@ abstract mixin class $StacSizeCopyWith<$Res> { factory $StacSizeCopyWith(StacSize value, $Res Function(StacSize) _then) = _$StacSizeCopyWithImpl; @useResult - $Res call({double width, double height}); + $Res call({StacDouble width, StacDouble height}); } /// @nodoc @@ -74,11 +74,11 @@ class _$StacSizeCopyWithImpl<$Res> implements $StacSizeCopyWith<$Res> { width: null == width ? _self.width : width // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, height: null == height ? _self.height : height // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, )); } } @@ -91,9 +91,9 @@ class _StacSize implements StacSize { _$StacSizeFromJson(json); @override - final double width; + final StacDouble width; @override - final double height; + final StacDouble height; /// Create a copy of StacSize /// with the given fields replaced by the non-null parameter values. @@ -136,7 +136,7 @@ abstract mixin class _$StacSizeCopyWith<$Res> __$StacSizeCopyWithImpl; @override @useResult - $Res call({double width, double height}); + $Res call({StacDouble width, StacDouble height}); } /// @nodoc @@ -158,11 +158,11 @@ class __$StacSizeCopyWithImpl<$Res> implements _$StacSizeCopyWith<$Res> { width: null == width ? _self.width : width // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, height: null == height ? _self.height : height // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, )); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_size/stac_size.g.dart b/packages/stac/lib/src/parsers/widgets/stac_size/stac_size.g.dart index 315de90f..9893c51e 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_size/stac_size.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_size/stac_size.g.dart @@ -7,8 +7,8 @@ part of 'stac_size.dart'; // ************************************************************************** _StacSize _$StacSizeFromJson(Map json) => _StacSize( - width: (json['width'] as num).toDouble(), - height: (json['height'] as num).toDouble(), + width: StacDouble.fromJson(json['width']), + height: StacDouble.fromJson(json['height']), ); Map _$StacSizeToJson(_StacSize instance) => { diff --git a/packages/stac/lib/src/parsers/widgets/stac_sized_box/stac_sized_box.dart b/packages/stac/lib/src/parsers/widgets/stac_sized_box/stac_sized_box.dart index 8d00fc6e..00ba1038 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_sized_box/stac_sized_box.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_sized_box/stac_sized_box.dart @@ -1,4 +1,5 @@ import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; export 'package:stac/src/parsers/widgets/stac_sized_box/stac_sized_box_parser.dart'; @@ -8,8 +9,8 @@ part 'stac_sized_box.g.dart'; @freezed abstract class StacSizedBox with _$StacSizedBox { const factory StacSizedBox({ - double? width, - double? height, + StacDouble? width, + StacDouble? height, Map? child, }) = _StacSizedBox; diff --git a/packages/stac/lib/src/parsers/widgets/stac_sized_box/stac_sized_box.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_sized_box/stac_sized_box.freezed.dart index 11120b41..70f05bdb 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_sized_box/stac_sized_box.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_sized_box/stac_sized_box.freezed.dart @@ -15,8 +15,8 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacSizedBox { - double? get width; - double? get height; + StacDouble? get width; + StacDouble? get height; Map? get child; /// Create a copy of StacSizedBox @@ -57,7 +57,8 @@ abstract mixin class $StacSizedBoxCopyWith<$Res> { StacSizedBox value, $Res Function(StacSizedBox) _then) = _$StacSizedBoxCopyWithImpl; @useResult - $Res call({double? width, double? height, Map? child}); + $Res call( + {StacDouble? width, StacDouble? height, Map? child}); } /// @nodoc @@ -80,11 +81,11 @@ class _$StacSizedBoxCopyWithImpl<$Res> implements $StacSizedBoxCopyWith<$Res> { width: freezed == width ? _self.width : width // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, height: freezed == height ? _self.height : height // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, child: freezed == child ? _self.child : child // ignore: cast_nullable_to_non_nullable @@ -103,9 +104,9 @@ class _StacSizedBox implements StacSizedBox { _$StacSizedBoxFromJson(json); @override - final double? width; + final StacDouble? width; @override - final double? height; + final StacDouble? height; final Map? _child; @override Map? get child { @@ -160,7 +161,8 @@ abstract mixin class _$StacSizedBoxCopyWith<$Res> __$StacSizedBoxCopyWithImpl; @override @useResult - $Res call({double? width, double? height, Map? child}); + $Res call( + {StacDouble? width, StacDouble? height, Map? child}); } /// @nodoc @@ -184,11 +186,11 @@ class __$StacSizedBoxCopyWithImpl<$Res> width: freezed == width ? _self.width : width // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, height: freezed == height ? _self.height : height // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, child: freezed == child ? _self._child : child // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_sized_box/stac_sized_box.g.dart b/packages/stac/lib/src/parsers/widgets/stac_sized_box/stac_sized_box.g.dart index cc8e485c..1f5750b5 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_sized_box/stac_sized_box.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_sized_box/stac_sized_box.g.dart @@ -8,8 +8,9 @@ part of 'stac_sized_box.dart'; _StacSizedBox _$StacSizedBoxFromJson(Map json) => _StacSizedBox( - width: (json['width'] as num?)?.toDouble(), - height: (json['height'] as num?)?.toDouble(), + width: json['width'] == null ? null : StacDouble.fromJson(json['width']), + height: + json['height'] == null ? null : StacDouble.fromJson(json['height']), child: json['child'] as Map?, ); diff --git a/packages/stac/lib/src/parsers/widgets/stac_sized_box/stac_sized_box_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_sized_box/stac_sized_box_parser.dart index a02dcd8b..330921e0 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_sized_box/stac_sized_box_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_sized_box/stac_sized_box_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_sized_box/stac_sized_box.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; @@ -17,8 +18,8 @@ class StacSizedBoxParser extends StacParser { @override Widget parse(BuildContext context, StacSizedBox model) { return SizedBox( - width: model.width, - height: model.height, + width: model.width?.parse, + height: model.height?.parse, child: Stac.fromJson(model.child, context), ); } diff --git a/packages/stac/lib/src/parsers/widgets/stac_slider/stac_slider.dart b/packages/stac/lib/src/parsers/widgets/stac_slider/stac_slider.dart index f9e6d095..419baff1 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_slider/stac_slider.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_slider/stac_slider.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_mouse_cursor/stac_mouse_cursor.dart'; export 'stac_slider_parser.dart'; @@ -14,13 +15,13 @@ abstract class StacSlider with _$StacSlider { const factory StacSlider({ String? id, @Default(StacSliderType.material) StacSliderType sliderType, - required double value, - double? secondaryTrackValue, + required StacDouble value, + StacDouble? secondaryTrackValue, Map? onChanged, Map? onChangeStart, Map? onChangeEnd, - @Default(0.0) double min, - @Default(1.0) double max, + @Default(StacDouble.zero) StacDouble min, + @Default(StacDouble(1.0)) StacDouble max, int? divisions, String? label, String? activeColor, diff --git a/packages/stac/lib/src/parsers/widgets/stac_slider/stac_slider.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_slider/stac_slider.freezed.dart index bcd419d5..a7253aae 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_slider/stac_slider.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_slider/stac_slider.freezed.dart @@ -17,13 +17,13 @@ T _$identity(T value) => value; mixin _$StacSlider { String? get id; StacSliderType get sliderType; - double get value; - double? get secondaryTrackValue; + StacDouble get value; + StacDouble? get secondaryTrackValue; Map? get onChanged; Map? get onChangeStart; Map? get onChangeEnd; - double get min; - double get max; + StacDouble get min; + StacDouble get max; int? get divisions; String? get label; String? get activeColor; @@ -124,13 +124,13 @@ abstract mixin class $StacSliderCopyWith<$Res> { $Res call( {String? id, StacSliderType sliderType, - double value, - double? secondaryTrackValue, + StacDouble value, + StacDouble? secondaryTrackValue, Map? onChanged, Map? onChangeStart, Map? onChangeEnd, - double min, - double max, + StacDouble min, + StacDouble max, int? divisions, String? label, String? activeColor, @@ -187,11 +187,11 @@ class _$StacSliderCopyWithImpl<$Res> implements $StacSliderCopyWith<$Res> { value: null == value ? _self.value : value // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, secondaryTrackValue: freezed == secondaryTrackValue ? _self.secondaryTrackValue : secondaryTrackValue // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, onChanged: freezed == onChanged ? _self.onChanged : onChanged // ignore: cast_nullable_to_non_nullable @@ -207,11 +207,11 @@ class _$StacSliderCopyWithImpl<$Res> implements $StacSliderCopyWith<$Res> { min: null == min ? _self.min : min // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, max: null == max ? _self.max : max // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, divisions: freezed == divisions ? _self.divisions : divisions // ignore: cast_nullable_to_non_nullable @@ -267,8 +267,8 @@ class _StacSlider implements StacSlider { final Map? onChanged, final Map? onChangeStart, final Map? onChangeEnd, - this.min = 0.0, - this.max = 1.0, + this.min = StacDouble.zero, + this.max = const StacDouble(1.0), this.divisions, this.label, this.activeColor, @@ -291,9 +291,9 @@ class _StacSlider implements StacSlider { @JsonKey() final StacSliderType sliderType; @override - final double value; + final StacDouble value; @override - final double? secondaryTrackValue; + final StacDouble? secondaryTrackValue; final Map? _onChanged; @override Map? get onChanged { @@ -326,10 +326,10 @@ class _StacSlider implements StacSlider { @override @JsonKey() - final double min; + final StacDouble min; @override @JsonKey() - final double max; + final StacDouble max; @override final int? divisions; @override @@ -449,13 +449,13 @@ abstract mixin class _$StacSliderCopyWith<$Res> $Res call( {String? id, StacSliderType sliderType, - double value, - double? secondaryTrackValue, + StacDouble value, + StacDouble? secondaryTrackValue, Map? onChanged, Map? onChangeStart, Map? onChangeEnd, - double min, - double max, + StacDouble min, + StacDouble max, int? divisions, String? label, String? activeColor, @@ -512,11 +512,11 @@ class __$StacSliderCopyWithImpl<$Res> implements _$StacSliderCopyWith<$Res> { value: null == value ? _self.value : value // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, secondaryTrackValue: freezed == secondaryTrackValue ? _self.secondaryTrackValue : secondaryTrackValue // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, onChanged: freezed == onChanged ? _self._onChanged : onChanged // ignore: cast_nullable_to_non_nullable @@ -532,11 +532,11 @@ class __$StacSliderCopyWithImpl<$Res> implements _$StacSliderCopyWith<$Res> { min: null == min ? _self.min : min // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, max: null == max ? _self.max : max // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, divisions: freezed == divisions ? _self.divisions : divisions // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_slider/stac_slider.g.dart b/packages/stac/lib/src/parsers/widgets/stac_slider/stac_slider.g.dart index e7b5d1bc..5f29380f 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_slider/stac_slider.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_slider/stac_slider.g.dart @@ -11,13 +11,19 @@ _StacSlider _$StacSliderFromJson(Map json) => _StacSlider( sliderType: $enumDecodeNullable(_$StacSliderTypeEnumMap, json['sliderType']) ?? StacSliderType.material, - value: (json['value'] as num).toDouble(), - secondaryTrackValue: (json['secondaryTrackValue'] as num?)?.toDouble(), + value: StacDouble.fromJson(json['value']), + secondaryTrackValue: json['secondaryTrackValue'] == null + ? null + : StacDouble.fromJson(json['secondaryTrackValue']), onChanged: json['onChanged'] as Map?, onChangeStart: json['onChangeStart'] as Map?, onChangeEnd: json['onChangeEnd'] as Map?, - min: (json['min'] as num?)?.toDouble() ?? 0.0, - max: (json['max'] as num?)?.toDouble() ?? 1.0, + min: json['min'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['min']), + max: json['max'] == null + ? const StacDouble(1.0) + : StacDouble.fromJson(json['max']), divisions: (json['divisions'] as num?)?.toInt(), label: json['label'] as String?, activeColor: json['activeColor'] as String?, diff --git a/packages/stac/lib/src/parsers/widgets/stac_slider/stac_slider_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_slider/stac_slider_parser.dart index f5c88245..bc29a3d4 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_slider/stac_slider_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_slider/stac_slider_parser.dart @@ -1,6 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_form/stac_form_scope.dart'; import 'package:stac/src/utils/color_utils.dart'; import 'package:stac/src/utils/widget_type.dart'; @@ -38,7 +39,7 @@ class __StacSliderState extends State<_StacSlider> { @override void initState() { - selectedValue = widget.model.value; + selectedValue = widget.model.value.parse; if (widget.model.id != null) { widget.formScope?.formData[widget.model.id!] = selectedValue; } @@ -90,12 +91,12 @@ class __StacSliderState extends State<_StacSlider> { ) { return Slider( value: value, - secondaryTrackValue: model.secondaryTrackValue, + secondaryTrackValue: model.secondaryTrackValue?.parse, onChanged: (value) => _onChanged(value), onChangeStart: (value) => _onChangeStart(value), onChangeEnd: (value) => _onChangeEnd(value), - min: model.min, - max: model.max, + min: model.min.parse, + max: model.max.parse, divisions: model.divisions, label: model.label, activeColor: model.activeColor?.toColor(context), @@ -119,12 +120,12 @@ class __StacSliderState extends State<_StacSlider> { ) { return Slider.adaptive( value: value, - secondaryTrackValue: model.secondaryTrackValue, + secondaryTrackValue: model.secondaryTrackValue?.parse, onChanged: (value) => _onChanged(value), onChangeStart: (value) => _onChangeStart(value), onChangeEnd: (value) => _onChangeEnd(value), - min: model.min, - max: model.max, + min: model.min.parse, + max: model.max.parse, divisions: model.divisions, label: model.label, activeColor: model.activeColor?.toColor(context), @@ -151,8 +152,8 @@ class __StacSliderState extends State<_StacSlider> { onChanged: (value) => _onChanged(value), onChangeStart: (value) => _onChangeStart(value), onChangeEnd: (value) => _onChangeEnd(value), - min: model.min, - max: model.max, + min: model.min.parse, + max: model.max.parse, divisions: model.divisions, activeColor: model.activeColor?.toColor(context), thumbColor: model.thumbColor?.toColor(context) ?? CupertinoColors.white, diff --git a/packages/stac/lib/src/parsers/widgets/stac_sliver_app_bar/stac_sliver_app_bar.dart b/packages/stac/lib/src/parsers/widgets/stac_sliver_app_bar/stac_sliver_app_bar.dart index de44b499..4452b796 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_sliver_app_bar/stac_sliver_app_bar.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_sliver_app_bar/stac_sliver_app_bar.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:stac/src/parsers/theme/stac_icon_theme_data/stac_icon_theme_data.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; import 'package:stac/src/parsers/widgets/stac_shape_border/stac_shape_border.dart'; import 'package:stac/src/parsers/widgets/stac_system_ui_olverlay_style/stac_system_ui_overlay_style.dart'; @@ -20,8 +21,8 @@ abstract class StacSliverAppBar with _$StacSliverAppBar { List>? actions, Map? flexibleSpace, Map? bottom, - double? elevation, - double? scrolledUnderElevation, + StacDouble? elevation, + StacDouble? scrolledUnderElevation, String? shadowColor, String? surfaceTintColor, @Default(false) bool forceElevated, @@ -32,18 +33,18 @@ abstract class StacSliverAppBar with _$StacSliverAppBar { @Default(true) bool primary, bool? centerTitle, @Default(false) bool excludeHeaderSemantics, - double? titleSpacing, - double? collapsedHeight, - double? expandedHeight, + StacDouble? titleSpacing, + StacDouble? collapsedHeight, + StacDouble? expandedHeight, @Default(false) bool floating, @Default(true) bool pinned, @Default(false) bool snap, @Default(false) bool stretch, - @Default(100.0) double stretchTriggerOffset, + @Default(StacDouble(100.0)) StacDouble stretchTriggerOffset, StacShapeBorder? shape, // StacAsyncCallback? onStretchTrigger, TODO: Implement StacAsyncCallback - @Default(64.0) double toolbarHeight, - double? leadingWidth, + @Default(StacDouble(64.0)) StacDouble toolbarHeight, + StacDouble? leadingWidth, StacTextStyle? toolbarTextStyle, StacTextStyle? titleTextStyle, StacSystemUIOverlayStyle? systemOverlayStyle, diff --git a/packages/stac/lib/src/parsers/widgets/stac_sliver_app_bar/stac_sliver_app_bar.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_sliver_app_bar/stac_sliver_app_bar.freezed.dart index fa748c1f..f12e0370 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_sliver_app_bar/stac_sliver_app_bar.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_sliver_app_bar/stac_sliver_app_bar.freezed.dart @@ -21,8 +21,8 @@ mixin _$StacSliverAppBar { List>? get actions; Map? get flexibleSpace; Map? get bottom; - double? get elevation; - double? get scrolledUnderElevation; + StacDouble? get elevation; + StacDouble? get scrolledUnderElevation; String? get shadowColor; String? get surfaceTintColor; bool get forceElevated; @@ -33,18 +33,18 @@ mixin _$StacSliverAppBar { bool get primary; bool? get centerTitle; bool get excludeHeaderSemantics; - double? get titleSpacing; - double? get collapsedHeight; - double? get expandedHeight; + StacDouble? get titleSpacing; + StacDouble? get collapsedHeight; + StacDouble? get expandedHeight; bool get floating; bool get pinned; bool get snap; bool get stretch; - double get stretchTriggerOffset; + StacDouble get stretchTriggerOffset; StacShapeBorder? get shape; // StacAsyncCallback? onStretchTrigger, TODO: Implement StacAsyncCallback - double get toolbarHeight; - double? get leadingWidth; + StacDouble get toolbarHeight; + StacDouble? get leadingWidth; StacTextStyle? get toolbarTextStyle; StacTextStyle? get titleTextStyle; StacSystemUIOverlayStyle? get systemOverlayStyle; @@ -193,8 +193,8 @@ abstract mixin class $StacSliverAppBarCopyWith<$Res> { List>? actions, Map? flexibleSpace, Map? bottom, - double? elevation, - double? scrolledUnderElevation, + StacDouble? elevation, + StacDouble? scrolledUnderElevation, String? shadowColor, String? surfaceTintColor, bool forceElevated, @@ -205,17 +205,17 @@ abstract mixin class $StacSliverAppBarCopyWith<$Res> { bool primary, bool? centerTitle, bool excludeHeaderSemantics, - double? titleSpacing, - double? collapsedHeight, - double? expandedHeight, + StacDouble? titleSpacing, + StacDouble? collapsedHeight, + StacDouble? expandedHeight, bool floating, bool pinned, bool snap, bool stretch, - double stretchTriggerOffset, + StacDouble stretchTriggerOffset, StacShapeBorder? shape, - double toolbarHeight, - double? leadingWidth, + StacDouble toolbarHeight, + StacDouble? leadingWidth, StacTextStyle? toolbarTextStyle, StacTextStyle? titleTextStyle, StacSystemUIOverlayStyle? systemOverlayStyle, @@ -309,11 +309,11 @@ class _$StacSliverAppBarCopyWithImpl<$Res> elevation: freezed == elevation ? _self.elevation : elevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, scrolledUnderElevation: freezed == scrolledUnderElevation ? _self.scrolledUnderElevation : scrolledUnderElevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, shadowColor: freezed == shadowColor ? _self.shadowColor : shadowColor // ignore: cast_nullable_to_non_nullable @@ -357,15 +357,15 @@ class _$StacSliverAppBarCopyWithImpl<$Res> titleSpacing: freezed == titleSpacing ? _self.titleSpacing : titleSpacing // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, collapsedHeight: freezed == collapsedHeight ? _self.collapsedHeight : collapsedHeight // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, expandedHeight: freezed == expandedHeight ? _self.expandedHeight : expandedHeight // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, floating: null == floating ? _self.floating : floating // ignore: cast_nullable_to_non_nullable @@ -385,7 +385,7 @@ class _$StacSliverAppBarCopyWithImpl<$Res> stretchTriggerOffset: null == stretchTriggerOffset ? _self.stretchTriggerOffset : stretchTriggerOffset // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, shape: freezed == shape ? _self.shape : shape // ignore: cast_nullable_to_non_nullable @@ -393,11 +393,11 @@ class _$StacSliverAppBarCopyWithImpl<$Res> toolbarHeight: null == toolbarHeight ? _self.toolbarHeight : toolbarHeight // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, leadingWidth: freezed == leadingWidth ? _self.leadingWidth : leadingWidth // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, toolbarTextStyle: freezed == toolbarTextStyle ? _self.toolbarTextStyle : toolbarTextStyle // ignore: cast_nullable_to_non_nullable @@ -554,9 +554,9 @@ class _StacSliverAppBar implements StacSliverAppBar { this.pinned = true, this.snap = false, this.stretch = false, - this.stretchTriggerOffset = 100.0, + this.stretchTriggerOffset = const StacDouble(100.0), this.shape, - this.toolbarHeight = 64.0, + this.toolbarHeight = const StacDouble(64.0), this.leadingWidth, this.toolbarTextStyle, this.titleTextStyle, @@ -626,9 +626,9 @@ class _StacSliverAppBar implements StacSliverAppBar { } @override - final double? elevation; + final StacDouble? elevation; @override - final double? scrolledUnderElevation; + final StacDouble? scrolledUnderElevation; @override final String? shadowColor; @override @@ -653,11 +653,11 @@ class _StacSliverAppBar implements StacSliverAppBar { @JsonKey() final bool excludeHeaderSemantics; @override - final double? titleSpacing; + final StacDouble? titleSpacing; @override - final double? collapsedHeight; + final StacDouble? collapsedHeight; @override - final double? expandedHeight; + final StacDouble? expandedHeight; @override @JsonKey() final bool floating; @@ -672,15 +672,15 @@ class _StacSliverAppBar implements StacSliverAppBar { final bool stretch; @override @JsonKey() - final double stretchTriggerOffset; + final StacDouble stretchTriggerOffset; @override final StacShapeBorder? shape; // StacAsyncCallback? onStretchTrigger, TODO: Implement StacAsyncCallback @override @JsonKey() - final double toolbarHeight; + final StacDouble toolbarHeight; @override - final double? leadingWidth; + final StacDouble? leadingWidth; @override final StacTextStyle? toolbarTextStyle; @override @@ -842,8 +842,8 @@ abstract mixin class _$StacSliverAppBarCopyWith<$Res> List>? actions, Map? flexibleSpace, Map? bottom, - double? elevation, - double? scrolledUnderElevation, + StacDouble? elevation, + StacDouble? scrolledUnderElevation, String? shadowColor, String? surfaceTintColor, bool forceElevated, @@ -854,17 +854,17 @@ abstract mixin class _$StacSliverAppBarCopyWith<$Res> bool primary, bool? centerTitle, bool excludeHeaderSemantics, - double? titleSpacing, - double? collapsedHeight, - double? expandedHeight, + StacDouble? titleSpacing, + StacDouble? collapsedHeight, + StacDouble? expandedHeight, bool floating, bool pinned, bool snap, bool stretch, - double stretchTriggerOffset, + StacDouble stretchTriggerOffset, StacShapeBorder? shape, - double toolbarHeight, - double? leadingWidth, + StacDouble toolbarHeight, + StacDouble? leadingWidth, StacTextStyle? toolbarTextStyle, StacTextStyle? titleTextStyle, StacSystemUIOverlayStyle? systemOverlayStyle, @@ -965,11 +965,11 @@ class __$StacSliverAppBarCopyWithImpl<$Res> elevation: freezed == elevation ? _self.elevation : elevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, scrolledUnderElevation: freezed == scrolledUnderElevation ? _self.scrolledUnderElevation : scrolledUnderElevation // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, shadowColor: freezed == shadowColor ? _self.shadowColor : shadowColor // ignore: cast_nullable_to_non_nullable @@ -1013,15 +1013,15 @@ class __$StacSliverAppBarCopyWithImpl<$Res> titleSpacing: freezed == titleSpacing ? _self.titleSpacing : titleSpacing // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, collapsedHeight: freezed == collapsedHeight ? _self.collapsedHeight : collapsedHeight // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, expandedHeight: freezed == expandedHeight ? _self.expandedHeight : expandedHeight // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, floating: null == floating ? _self.floating : floating // ignore: cast_nullable_to_non_nullable @@ -1041,7 +1041,7 @@ class __$StacSliverAppBarCopyWithImpl<$Res> stretchTriggerOffset: null == stretchTriggerOffset ? _self.stretchTriggerOffset : stretchTriggerOffset // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, shape: freezed == shape ? _self.shape : shape // ignore: cast_nullable_to_non_nullable @@ -1049,11 +1049,11 @@ class __$StacSliverAppBarCopyWithImpl<$Res> toolbarHeight: null == toolbarHeight ? _self.toolbarHeight : toolbarHeight // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, leadingWidth: freezed == leadingWidth ? _self.leadingWidth : leadingWidth // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, toolbarTextStyle: freezed == toolbarTextStyle ? _self.toolbarTextStyle : toolbarTextStyle // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_sliver_app_bar/stac_sliver_app_bar.g.dart b/packages/stac/lib/src/parsers/widgets/stac_sliver_app_bar/stac_sliver_app_bar.g.dart index 35227095..2fa73360 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_sliver_app_bar/stac_sliver_app_bar.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_sliver_app_bar/stac_sliver_app_bar.g.dart @@ -17,9 +17,12 @@ _StacSliverAppBar _$StacSliverAppBarFromJson(Map json) => .toList(), flexibleSpace: json['flexibleSpace'] as Map?, bottom: json['bottom'] as Map?, - elevation: (json['elevation'] as num?)?.toDouble(), - scrolledUnderElevation: - (json['scrolledUnderElevation'] as num?)?.toDouble(), + elevation: json['elevation'] == null + ? null + : StacDouble.fromJson(json['elevation']), + scrolledUnderElevation: json['scrolledUnderElevation'] == null + ? null + : StacDouble.fromJson(json['scrolledUnderElevation']), shadowColor: json['shadowColor'] as String?, surfaceTintColor: json['surfaceTintColor'] as String?, forceElevated: json['forceElevated'] as bool? ?? false, @@ -36,20 +39,31 @@ _StacSliverAppBar _$StacSliverAppBarFromJson(Map json) => primary: json['primary'] as bool? ?? true, centerTitle: json['centerTitle'] as bool?, excludeHeaderSemantics: json['excludeHeaderSemantics'] as bool? ?? false, - titleSpacing: (json['titleSpacing'] as num?)?.toDouble(), - collapsedHeight: (json['collapsedHeight'] as num?)?.toDouble(), - expandedHeight: (json['expandedHeight'] as num?)?.toDouble(), + titleSpacing: json['titleSpacing'] == null + ? null + : StacDouble.fromJson(json['titleSpacing']), + collapsedHeight: json['collapsedHeight'] == null + ? null + : StacDouble.fromJson(json['collapsedHeight']), + expandedHeight: json['expandedHeight'] == null + ? null + : StacDouble.fromJson(json['expandedHeight']), floating: json['floating'] as bool? ?? false, pinned: json['pinned'] as bool? ?? true, snap: json['snap'] as bool? ?? false, stretch: json['stretch'] as bool? ?? false, - stretchTriggerOffset: - (json['stretchTriggerOffset'] as num?)?.toDouble() ?? 100.0, + stretchTriggerOffset: json['stretchTriggerOffset'] == null + ? const StacDouble(100.0) + : StacDouble.fromJson(json['stretchTriggerOffset']), shape: json['shape'] == null ? null : StacShapeBorder.fromJson(json['shape'] as Map), - toolbarHeight: (json['toolbarHeight'] as num?)?.toDouble() ?? 64.0, - leadingWidth: (json['leadingWidth'] as num?)?.toDouble(), + toolbarHeight: json['toolbarHeight'] == null + ? const StacDouble(64.0) + : StacDouble.fromJson(json['toolbarHeight']), + leadingWidth: json['leadingWidth'] == null + ? null + : StacDouble.fromJson(json['leadingWidth']), toolbarTextStyle: json['toolbarTextStyle'] == null ? null : StacTextStyle.fromJson(json['toolbarTextStyle']), diff --git a/packages/stac/lib/src/parsers/widgets/stac_sliver_app_bar/stac_sliver_app_bar_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_sliver_app_bar/stac_sliver_app_bar_parser.dart index 82de4278..33b3b284 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_sliver_app_bar/stac_sliver_app_bar_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_sliver_app_bar/stac_sliver_app_bar_parser.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; import 'package:stac/src/parsers/theme/stac_icon_theme_data/stac_icon_theme_data.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; import 'package:stac/src/parsers/widgets/stac_shape_border/stac_shape_border.dart'; import 'package:stac/src/parsers/widgets/stac_system_ui_olverlay_style/stac_system_ui_overlay_style.dart'; @@ -32,8 +33,8 @@ class StacSliverAppBarParser extends StacParser { .toList(growable: false), flexibleSpace: Stac.fromJson(model.flexibleSpace, context), bottom: Stac.fromJson(model.bottom, context).toPreferredSizeWidget, - elevation: model.elevation, - scrolledUnderElevation: model.scrolledUnderElevation, + elevation: model.elevation?.parse, + scrolledUnderElevation: model.scrolledUnderElevation?.parse, shadowColor: model.shadowColor.toColor(context), surfaceTintColor: model.surfaceTintColor.toColor(context), forceElevated: model.forceElevated, @@ -44,17 +45,17 @@ class StacSliverAppBarParser extends StacParser { primary: model.primary, centerTitle: model.centerTitle, excludeHeaderSemantics: model.excludeHeaderSemantics, - titleSpacing: model.titleSpacing, - collapsedHeight: model.collapsedHeight, - expandedHeight: model.expandedHeight, + titleSpacing: model.titleSpacing?.parse, + collapsedHeight: model.collapsedHeight?.parse, + expandedHeight: model.expandedHeight?.parse, floating: model.floating, pinned: model.pinned, snap: model.snap, stretch: model.stretch, - stretchTriggerOffset: model.stretchTriggerOffset, + stretchTriggerOffset: model.stretchTriggerOffset.parse, shape: model.shape?.parse(context), - toolbarHeight: model.toolbarHeight, - leadingWidth: model.leadingWidth, + toolbarHeight: model.toolbarHeight.parse, + leadingWidth: model.leadingWidth?.parse, toolbarTextStyle: model.toolbarTextStyle?.parse(context), titleTextStyle: model.titleTextStyle?.parse(context), systemOverlayStyle: model.systemOverlayStyle?.parse(context), diff --git a/packages/stac/lib/src/parsers/widgets/stac_switch/stac_switch.dart b/packages/stac/lib/src/parsers/widgets/stac_switch/stac_switch.dart index d70b4ab8..e9c8c220 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_switch/stac_switch.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_switch/stac_switch.dart @@ -2,6 +2,7 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:stac/src/parsers/theme/stac_material_color/stac_material_color.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; export 'stac_switch_parser.dart'; @@ -25,14 +26,14 @@ abstract class StacSwitch with _$StacSwitch { String? inactiveTrackColor, String? onLabelColor, String? offLabelColor, - double? splashRadius, + StacDouble? splashRadius, @Default(DragStartBehavior.start) DragStartBehavior dragStartBehavior, StacMaterialColor? overlayColor, StacMaterialColor? thumbColor, StacMaterialColor? trackColor, MaterialTapTargetSize? materialTapTargetSize, StacMaterialColor? trackOutlineColor, - double? trackOutlineWidth, + StacDouble? trackOutlineWidth, Map? thumbIcon, String? inactiveThumbImage, String? activeThumbImage, diff --git a/packages/stac/lib/src/parsers/widgets/stac_switch/stac_switch.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_switch/stac_switch.freezed.dart index bad0b405..268f6a1a 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_switch/stac_switch.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_switch/stac_switch.freezed.dart @@ -27,14 +27,14 @@ mixin _$StacSwitch { String? get inactiveTrackColor; String? get onLabelColor; String? get offLabelColor; - double? get splashRadius; + StacDouble? get splashRadius; DragStartBehavior get dragStartBehavior; StacMaterialColor? get overlayColor; StacMaterialColor? get thumbColor; StacMaterialColor? get trackColor; MaterialTapTargetSize? get materialTapTargetSize; StacMaterialColor? get trackOutlineColor; - double? get trackOutlineWidth; + StacDouble? get trackOutlineWidth; Map? get thumbIcon; String? get inactiveThumbImage; String? get activeThumbImage; @@ -161,14 +161,14 @@ abstract mixin class $StacSwitchCopyWith<$Res> { String? inactiveTrackColor, String? onLabelColor, String? offLabelColor, - double? splashRadius, + StacDouble? splashRadius, DragStartBehavior dragStartBehavior, StacMaterialColor? overlayColor, StacMaterialColor? thumbColor, StacMaterialColor? trackColor, MaterialTapTargetSize? materialTapTargetSize, StacMaterialColor? trackOutlineColor, - double? trackOutlineWidth, + StacDouble? trackOutlineWidth, Map? thumbIcon, String? inactiveThumbImage, String? activeThumbImage, @@ -271,7 +271,7 @@ class _$StacSwitchCopyWithImpl<$Res> implements $StacSwitchCopyWith<$Res> { splashRadius: freezed == splashRadius ? _self.splashRadius : splashRadius // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, dragStartBehavior: null == dragStartBehavior ? _self.dragStartBehavior : dragStartBehavior // ignore: cast_nullable_to_non_nullable @@ -299,7 +299,7 @@ class _$StacSwitchCopyWithImpl<$Res> implements $StacSwitchCopyWith<$Res> { trackOutlineWidth: freezed == trackOutlineWidth ? _self.trackOutlineWidth : trackOutlineWidth // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, thumbIcon: freezed == thumbIcon ? _self.thumbIcon : thumbIcon // ignore: cast_nullable_to_non_nullable @@ -450,7 +450,7 @@ class _StacSwitch implements StacSwitch { @override final String? offLabelColor; @override - final double? splashRadius; + final StacDouble? splashRadius; @override @JsonKey() final DragStartBehavior dragStartBehavior; @@ -465,7 +465,7 @@ class _StacSwitch implements StacSwitch { @override final StacMaterialColor? trackOutlineColor; @override - final double? trackOutlineWidth; + final StacDouble? trackOutlineWidth; final Map? _thumbIcon; @override Map? get thumbIcon { @@ -614,14 +614,14 @@ abstract mixin class _$StacSwitchCopyWith<$Res> String? inactiveTrackColor, String? onLabelColor, String? offLabelColor, - double? splashRadius, + StacDouble? splashRadius, DragStartBehavior dragStartBehavior, StacMaterialColor? overlayColor, StacMaterialColor? thumbColor, StacMaterialColor? trackColor, MaterialTapTargetSize? materialTapTargetSize, StacMaterialColor? trackOutlineColor, - double? trackOutlineWidth, + StacDouble? trackOutlineWidth, Map? thumbIcon, String? inactiveThumbImage, String? activeThumbImage, @@ -728,7 +728,7 @@ class __$StacSwitchCopyWithImpl<$Res> implements _$StacSwitchCopyWith<$Res> { splashRadius: freezed == splashRadius ? _self.splashRadius : splashRadius // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, dragStartBehavior: null == dragStartBehavior ? _self.dragStartBehavior : dragStartBehavior // ignore: cast_nullable_to_non_nullable @@ -756,7 +756,7 @@ class __$StacSwitchCopyWithImpl<$Res> implements _$StacSwitchCopyWith<$Res> { trackOutlineWidth: freezed == trackOutlineWidth ? _self.trackOutlineWidth : trackOutlineWidth // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, thumbIcon: freezed == thumbIcon ? _self._thumbIcon : thumbIcon // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_switch/stac_switch.g.dart b/packages/stac/lib/src/parsers/widgets/stac_switch/stac_switch.g.dart index aca95e3b..a70e5117 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_switch/stac_switch.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_switch/stac_switch.g.dart @@ -21,7 +21,9 @@ _StacSwitch _$StacSwitchFromJson(Map json) => _StacSwitch( inactiveTrackColor: json['inactiveTrackColor'] as String?, onLabelColor: json['onLabelColor'] as String?, offLabelColor: json['offLabelColor'] as String?, - splashRadius: (json['splashRadius'] as num?)?.toDouble(), + splashRadius: json['splashRadius'] == null + ? null + : StacDouble.fromJson(json['splashRadius']), dragStartBehavior: $enumDecodeNullable( _$DragStartBehaviorEnumMap, json['dragStartBehavior']) ?? DragStartBehavior.start, @@ -43,7 +45,9 @@ _StacSwitch _$StacSwitchFromJson(Map json) => _StacSwitch( ? null : StacMaterialColor.fromJson( json['trackOutlineColor'] as Map), - trackOutlineWidth: (json['trackOutlineWidth'] as num?)?.toDouble(), + trackOutlineWidth: json['trackOutlineWidth'] == null + ? null + : StacDouble.fromJson(json['trackOutlineWidth']), thumbIcon: json['thumbIcon'] as Map?, inactiveThumbImage: json['inactiveThumbImage'] as String?, activeThumbImage: json['activeThumbImage'] as String?, diff --git a/packages/stac/lib/src/parsers/widgets/stac_switch/stac_switch_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_switch/stac_switch_parser.dart index 1a4895b6..617f0928 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_switch/stac_switch_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_switch/stac_switch_parser.dart @@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; import 'package:stac/src/parsers/theme/stac_material_color/stac_material_color.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/color_utils.dart'; import 'package:stac_framework/stac_framework.dart'; @@ -111,7 +112,8 @@ class _SwitchWidgetState extends State<_SwitchWidget> { trackOutlineColor: WidgetStateProperty.all( model.trackOutlineColor?.parse(context), ), - trackOutlineWidth: WidgetStateProperty.all(model.trackOutlineWidth), + trackOutlineWidth: + WidgetStateProperty.all(model.trackOutlineWidth?.parse), thumbIcon: WidgetStateProperty.all( Stac.fromJson(model.thumbIcon, context) as Icon?, ), @@ -121,7 +123,7 @@ class _SwitchWidgetState extends State<_SwitchWidget> { overlayColor: WidgetStateProperty.all( model.overlayColor?.parse(context), ), - splashRadius: model.splashRadius, + splashRadius: model.splashRadius?.parse, autofocus: model.autofocus, applyCupertinoTheme: model.applyCupertinoTheme, ); @@ -146,7 +148,8 @@ class _SwitchWidgetState extends State<_SwitchWidget> { trackOutlineColor: WidgetStateProperty.all( model.trackOutlineColor?.parse(context), ), - trackOutlineWidth: WidgetStateProperty.all(model.trackOutlineWidth), + trackOutlineWidth: + WidgetStateProperty.all(model.trackOutlineWidth?.parse), thumbIcon: WidgetStateProperty.all( Stac.fromJson(model.thumbIcon, context) as Icon?, ), @@ -157,7 +160,7 @@ class _SwitchWidgetState extends State<_SwitchWidget> { overlayColor: WidgetStateProperty.all( model.overlayColor?.parse(context), ), - splashRadius: model.splashRadius, + splashRadius: model.splashRadius?.parse, autofocus: model.autofocus, ); } diff --git a/packages/stac/lib/src/parsers/widgets/stac_tab/stac_tab.dart b/packages/stac/lib/src/parsers/widgets/stac_tab/stac_tab.dart index aa8f4a7f..2e1d8b46 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_tab/stac_tab.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_tab/stac_tab.dart @@ -1,4 +1,5 @@ import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; export 'stac_tab_parser.dart'; @@ -12,7 +13,7 @@ abstract class StacTab with _$StacTab { String? text, Map? icon, StacEdgeInsets? iconMargin, - double? height, + StacDouble? height, Map? child, }) = _StacTab; diff --git a/packages/stac/lib/src/parsers/widgets/stac_tab/stac_tab.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_tab/stac_tab.freezed.dart index f4b2c3fa..bb91bca0 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_tab/stac_tab.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_tab/stac_tab.freezed.dart @@ -18,7 +18,7 @@ mixin _$StacTab { String? get text; Map? get icon; StacEdgeInsets? get iconMargin; - double? get height; + StacDouble? get height; Map? get child; /// Create a copy of StacTab @@ -69,7 +69,7 @@ abstract mixin class $StacTabCopyWith<$Res> { {String? text, Map? icon, StacEdgeInsets? iconMargin, - double? height, + StacDouble? height, Map? child}); $StacEdgeInsetsCopyWith<$Res>? get iconMargin; @@ -109,7 +109,7 @@ class _$StacTabCopyWithImpl<$Res> implements $StacTabCopyWith<$Res> { height: freezed == height ? _self.height : height // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, child: freezed == child ? _self.child : child // ignore: cast_nullable_to_non_nullable @@ -161,7 +161,7 @@ class _StacTab implements StacTab { @override final StacEdgeInsets? iconMargin; @override - final double? height; + final StacDouble? height; final Map? _child; @override Map? get child { @@ -226,7 +226,7 @@ abstract mixin class _$StacTabCopyWith<$Res> implements $StacTabCopyWith<$Res> { {String? text, Map? icon, StacEdgeInsets? iconMargin, - double? height, + StacDouble? height, Map? child}); @override @@ -267,7 +267,7 @@ class __$StacTabCopyWithImpl<$Res> implements _$StacTabCopyWith<$Res> { height: freezed == height ? _self.height : height // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, child: freezed == child ? _self._child : child // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_tab/stac_tab.g.dart b/packages/stac/lib/src/parsers/widgets/stac_tab/stac_tab.g.dart index 9000e93e..71de33dd 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_tab/stac_tab.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_tab/stac_tab.g.dart @@ -12,7 +12,8 @@ _StacTab _$StacTabFromJson(Map json) => _StacTab( iconMargin: json['iconMargin'] == null ? null : StacEdgeInsets.fromJson(json['iconMargin']), - height: (json['height'] as num?)?.toDouble(), + height: + json['height'] == null ? null : StacDouble.fromJson(json['height']), child: json['child'] as Map?, ); diff --git a/packages/stac/lib/src/parsers/widgets/stac_tab/stac_tab_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_tab/stac_tab_parser.dart index 5f149eef..9828ff64 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_tab/stac_tab_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_tab/stac_tab_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; import 'package:stac/src/parsers/widgets/stac_tab/stac_tab.dart'; import 'package:stac/src/utils/widget_type.dart'; @@ -17,7 +18,7 @@ class StacTabParser extends StacParser { text: model.text, icon: Stac.fromJson(model.icon, context), iconMargin: model.iconMargin.parse, - height: model.height, + height: model.height?.parse, child: Stac.fromJson(model.child, context), ); } diff --git a/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.dart b/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.dart index 24751ce0..45bf570e 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.dart @@ -1,6 +1,7 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; import 'package:stac/src/parsers/widgets/stac_text_style/stac_text_style.dart'; import 'package:stac/src/utils/stac_scroll_physics.dart'; @@ -19,7 +20,7 @@ abstract class StacTabBar with _$StacTabBar { StacEdgeInsets? padding, String? indicatorColor, @Default(true) bool automaticIndicatorColorAdjustment, - @Default(2.0) double indicatorWeight, + @Default(StacDouble(2.0)) StacDouble indicatorWeight, StacEdgeInsets? indicatorPadding, TabBarIndicatorSize? indicatorSize, String? labelColor, diff --git a/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.freezed.dart index 6e499e80..655be4d2 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.freezed.dart @@ -21,7 +21,7 @@ mixin _$StacTabBar { StacEdgeInsets? get padding; String? get indicatorColor; bool get automaticIndicatorColorAdjustment; - double get indicatorWeight; + StacDouble get indicatorWeight; StacEdgeInsets? get indicatorPadding; TabBarIndicatorSize? get indicatorSize; String? get labelColor; @@ -128,7 +128,7 @@ abstract mixin class $StacTabBarCopyWith<$Res> { StacEdgeInsets? padding, String? indicatorColor, bool automaticIndicatorColorAdjustment, - double indicatorWeight, + StacDouble indicatorWeight, StacEdgeInsets? indicatorPadding, TabBarIndicatorSize? indicatorSize, String? labelColor, @@ -208,7 +208,7 @@ class _$StacTabBarCopyWithImpl<$Res> implements $StacTabBarCopyWith<$Res> { indicatorWeight: null == indicatorWeight ? _self.indicatorWeight : indicatorWeight // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, indicatorPadding: freezed == indicatorPadding ? _self.indicatorPadding : indicatorPadding // ignore: cast_nullable_to_non_nullable @@ -337,7 +337,7 @@ class _StacTabBar implements StacTabBar { this.padding, this.indicatorColor, this.automaticIndicatorColorAdjustment = true, - this.indicatorWeight = 2.0, + this.indicatorWeight = const StacDouble(2.0), this.indicatorPadding, this.indicatorSize, this.labelColor, @@ -376,7 +376,7 @@ class _StacTabBar implements StacTabBar { final bool automaticIndicatorColorAdjustment; @override @JsonKey() - final double indicatorWeight; + final StacDouble indicatorWeight; @override final StacEdgeInsets? indicatorPadding; @override @@ -502,7 +502,7 @@ abstract mixin class _$StacTabBarCopyWith<$Res> StacEdgeInsets? padding, String? indicatorColor, bool automaticIndicatorColorAdjustment, - double indicatorWeight, + StacDouble indicatorWeight, StacEdgeInsets? indicatorPadding, TabBarIndicatorSize? indicatorSize, String? labelColor, @@ -587,7 +587,7 @@ class __$StacTabBarCopyWithImpl<$Res> implements _$StacTabBarCopyWith<$Res> { indicatorWeight: null == indicatorWeight ? _self.indicatorWeight : indicatorWeight // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, indicatorPadding: freezed == indicatorPadding ? _self.indicatorPadding : indicatorPadding // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.g.dart b/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.g.dart index c3034818..2a6a347f 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar.g.dart @@ -18,7 +18,9 @@ _StacTabBar _$StacTabBarFromJson(Map json) => _StacTabBar( indicatorColor: json['indicatorColor'] as String?, automaticIndicatorColorAdjustment: json['automaticIndicatorColorAdjustment'] as bool? ?? true, - indicatorWeight: (json['indicatorWeight'] as num?)?.toDouble() ?? 2.0, + indicatorWeight: json['indicatorWeight'] == null + ? const StacDouble(2.0) + : StacDouble.fromJson(json['indicatorWeight']), indicatorPadding: json['indicatorPadding'] == null ? null : StacEdgeInsets.fromJson(json['indicatorPadding']), diff --git a/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar_parser.dart index 21847b27..df1cc8bf 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_tab_bar/stac_tab_bar_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; import 'package:stac/src/parsers/widgets/stac_tab_bar/stac_tab_bar.dart'; import 'package:stac/src/parsers/widgets/stac_text_style/stac_text_style.dart'; @@ -30,7 +31,7 @@ class StacTabBarParser extends StacParser { indicatorColor: model.indicatorColor?.toColor(context), automaticIndicatorColorAdjustment: model.automaticIndicatorColorAdjustment, - indicatorWeight: model.indicatorWeight, + indicatorWeight: model.indicatorWeight.parse, indicatorPadding: model.indicatorPadding.parse, indicatorSize: model.indicatorSize, labelColor: model.labelColor.toColor(context), diff --git a/packages/stac/lib/src/parsers/widgets/stac_tab_bar_view/stac_tab_bar_view.dart b/packages/stac/lib/src/parsers/widgets/stac_tab_bar_view/stac_tab_bar_view.dart index 8c6dd38d..a5880c9f 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_tab_bar_view/stac_tab_bar_view.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_tab_bar_view/stac_tab_bar_view.dart @@ -1,6 +1,7 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/stac_scroll_physics.dart'; export 'stac_tab_bar_view_parser.dart'; @@ -15,7 +16,7 @@ abstract class StacTabBarView with _$StacTabBarView { @Default(0) int initialIndex, @Default(DragStartBehavior.start) DragStartBehavior dragStartBehavior, StacScrollPhysics? physics, - @Default(1.0) double viewportFraction, + @Default(StacDouble(1.0)) StacDouble viewportFraction, @Default(Clip.hardEdge) Clip clipBehavior, }) = _StacTabBarView; diff --git a/packages/stac/lib/src/parsers/widgets/stac_tab_bar_view/stac_tab_bar_view.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_tab_bar_view/stac_tab_bar_view.freezed.dart index 01691378..c3e775e9 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_tab_bar_view/stac_tab_bar_view.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_tab_bar_view/stac_tab_bar_view.freezed.dart @@ -19,7 +19,7 @@ mixin _$StacTabBarView { int get initialIndex; DragStartBehavior get dragStartBehavior; StacScrollPhysics? get physics; - double get viewportFraction; + StacDouble get viewportFraction; Clip get clipBehavior; /// Create a copy of StacTabBarView @@ -78,7 +78,7 @@ abstract mixin class $StacTabBarViewCopyWith<$Res> { int initialIndex, DragStartBehavior dragStartBehavior, StacScrollPhysics? physics, - double viewportFraction, + StacDouble viewportFraction, Clip clipBehavior}); } @@ -122,7 +122,7 @@ class _$StacTabBarViewCopyWithImpl<$Res> viewportFraction: null == viewportFraction ? _self.viewportFraction : viewportFraction // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, clipBehavior: null == clipBehavior ? _self.clipBehavior : clipBehavior // ignore: cast_nullable_to_non_nullable @@ -139,7 +139,7 @@ class _StacTabBarView implements StacTabBarView { this.initialIndex = 0, this.dragStartBehavior = DragStartBehavior.start, this.physics, - this.viewportFraction = 1.0, + this.viewportFraction = const StacDouble(1.0), this.clipBehavior = Clip.hardEdge}) : _children = children; factory _StacTabBarView.fromJson(Map json) => @@ -163,7 +163,7 @@ class _StacTabBarView implements StacTabBarView { final StacScrollPhysics? physics; @override @JsonKey() - final double viewportFraction; + final StacDouble viewportFraction; @override @JsonKey() final Clip clipBehavior; @@ -230,7 +230,7 @@ abstract mixin class _$StacTabBarViewCopyWith<$Res> int initialIndex, DragStartBehavior dragStartBehavior, StacScrollPhysics? physics, - double viewportFraction, + StacDouble viewportFraction, Clip clipBehavior}); } @@ -274,7 +274,7 @@ class __$StacTabBarViewCopyWithImpl<$Res> viewportFraction: null == viewportFraction ? _self.viewportFraction : viewportFraction // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, clipBehavior: null == clipBehavior ? _self.clipBehavior : clipBehavior // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_tab_bar_view/stac_tab_bar_view.g.dart b/packages/stac/lib/src/parsers/widgets/stac_tab_bar_view/stac_tab_bar_view.g.dart index 903a65bb..fee6cff5 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_tab_bar_view/stac_tab_bar_view.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_tab_bar_view/stac_tab_bar_view.g.dart @@ -16,7 +16,9 @@ _StacTabBarView _$StacTabBarViewFromJson(Map json) => _$DragStartBehaviorEnumMap, json['dragStartBehavior']) ?? DragStartBehavior.start, physics: $enumDecodeNullable(_$StacScrollPhysicsEnumMap, json['physics']), - viewportFraction: (json['viewportFraction'] as num?)?.toDouble() ?? 1.0, + viewportFraction: json['viewportFraction'] == null + ? const StacDouble(1.0) + : StacDouble.fromJson(json['viewportFraction']), clipBehavior: $enumDecodeNullable(_$ClipEnumMap, json['clipBehavior']) ?? Clip.hardEdge, ); diff --git a/packages/stac/lib/src/parsers/widgets/stac_tab_bar_view/stac_tab_bar_view_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_tab_bar_view/stac_tab_bar_view_parser.dart index c379a9e4..44ec2c68 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_tab_bar_view/stac_tab_bar_view_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_tab_bar_view/stac_tab_bar_view_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; @@ -23,7 +24,7 @@ class StacTabBarViewParser extends StacParser { controller: controller, physics: model.physics?.parse, dragStartBehavior: model.dragStartBehavior, - viewportFraction: model.viewportFraction, + viewportFraction: model.viewportFraction.parse, clipBehavior: model.clipBehavior, children: model.children .map((child) => Stac.fromJson(child, context) ?? const SizedBox()) diff --git a/packages/stac/lib/src/parsers/widgets/stac_table/stac_table.dart b/packages/stac/lib/src/parsers/widgets/stac_table/stac_table.dart index 64e78165..1a4b90cf 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_table/stac_table.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_table/stac_table.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/stac.dart'; export 'stac_table_parser.dart'; @@ -46,7 +47,7 @@ abstract class StacTableRow with _$StacTableRow { abstract class StacTableBorder with _$StacTableBorder { const factory StacTableBorder({ @Default('#000000') String color, - @Default(1.0) double width, + @Default(StacDouble(1.0)) StacDouble width, @Default(BorderStyle.solid) BorderStyle style, @Default(StacBorderRadius()) StacBorderRadius borderRadius, }) = _StacTableBorder; @@ -60,7 +61,7 @@ abstract class StacTableColumnWidth with _$StacTableColumnWidth { const factory StacTableColumnWidth({ @Default(StacTableColumnWidthType.flexColumnWidth) StacTableColumnWidthType type, - double? value, + StacDouble? value, }) = _StacTableColumnWidth; factory StacTableColumnWidth.fromJson(Map json) => diff --git a/packages/stac/lib/src/parsers/widgets/stac_table/stac_table.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_table/stac_table.freezed.dart index ef045935..4a546778 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_table/stac_table.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_table/stac_table.freezed.dart @@ -584,7 +584,7 @@ class __$StacTableRowCopyWithImpl<$Res> /// @nodoc mixin _$StacTableBorder { String get color; - double get width; + StacDouble get width; BorderStyle get style; StacBorderRadius get borderRadius; @@ -630,7 +630,7 @@ abstract mixin class $StacTableBorderCopyWith<$Res> { @useResult $Res call( {String color, - double width, + StacDouble width, BorderStyle style, StacBorderRadius borderRadius}); @@ -663,7 +663,7 @@ class _$StacTableBorderCopyWithImpl<$Res> width: null == width ? _self.width : width // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, style: null == style ? _self.style : style // ignore: cast_nullable_to_non_nullable @@ -691,7 +691,7 @@ class _$StacTableBorderCopyWithImpl<$Res> class _StacTableBorder implements StacTableBorder { const _StacTableBorder( {this.color = '#000000', - this.width = 1.0, + this.width = const StacDouble(1.0), this.style = BorderStyle.solid, this.borderRadius = const StacBorderRadius()}); factory _StacTableBorder.fromJson(Map json) => @@ -702,7 +702,7 @@ class _StacTableBorder implements StacTableBorder { final String color; @override @JsonKey() - final double width; + final StacDouble width; @override @JsonKey() final BorderStyle style; @@ -758,7 +758,7 @@ abstract mixin class _$StacTableBorderCopyWith<$Res> @useResult $Res call( {String color, - double width, + StacDouble width, BorderStyle style, StacBorderRadius borderRadius}); @@ -792,7 +792,7 @@ class __$StacTableBorderCopyWithImpl<$Res> width: null == width ? _self.width : width // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, style: null == style ? _self.style : style // ignore: cast_nullable_to_non_nullable @@ -818,7 +818,7 @@ class __$StacTableBorderCopyWithImpl<$Res> /// @nodoc mixin _$StacTableColumnWidth { StacTableColumnWidthType get type; - double? get value; + StacDouble? get value; /// Create a copy of StacTableColumnWidth /// with the given fields replaced by the non-null parameter values. @@ -856,7 +856,7 @@ abstract mixin class $StacTableColumnWidthCopyWith<$Res> { $Res Function(StacTableColumnWidth) _then) = _$StacTableColumnWidthCopyWithImpl; @useResult - $Res call({StacTableColumnWidthType type, double? value}); + $Res call({StacTableColumnWidthType type, StacDouble? value}); } /// @nodoc @@ -883,7 +883,7 @@ class _$StacTableColumnWidthCopyWithImpl<$Res> value: freezed == value ? _self.value : value // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, )); } } @@ -900,7 +900,7 @@ class _StacTableColumnWidth implements StacTableColumnWidth { @JsonKey() final StacTableColumnWidthType type; @override - final double? value; + final StacDouble? value; /// Create a copy of StacTableColumnWidth /// with the given fields replaced by the non-null parameter values. @@ -945,7 +945,7 @@ abstract mixin class _$StacTableColumnWidthCopyWith<$Res> __$StacTableColumnWidthCopyWithImpl; @override @useResult - $Res call({StacTableColumnWidthType type, double? value}); + $Res call({StacTableColumnWidthType type, StacDouble? value}); } /// @nodoc @@ -972,7 +972,7 @@ class __$StacTableColumnWidthCopyWithImpl<$Res> value: freezed == value ? _self.value : value // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, )); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_table/stac_table.g.dart b/packages/stac/lib/src/parsers/widgets/stac_table/stac_table.g.dart index 98ffd079..fb9e6fcd 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_table/stac_table.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_table/stac_table.g.dart @@ -85,7 +85,9 @@ Map _$StacTableRowToJson(_StacTableRow instance) => _StacTableBorder _$StacTableBorderFromJson(Map json) => _StacTableBorder( color: json['color'] as String? ?? '#000000', - width: (json['width'] as num?)?.toDouble() ?? 1.0, + width: json['width'] == null + ? const StacDouble(1.0) + : StacDouble.fromJson(json['width']), style: $enumDecodeNullable(_$BorderStyleEnumMap, json['style']) ?? BorderStyle.solid, borderRadius: json['borderRadius'] == null @@ -112,7 +114,7 @@ _StacTableColumnWidth _$StacTableColumnWidthFromJson( type: $enumDecodeNullable( _$StacTableColumnWidthTypeEnumMap, json['type']) ?? StacTableColumnWidthType.flexColumnWidth, - value: (json['value'] as num?)?.toDouble(), + value: json['value'] == null ? null : StacDouble.fromJson(json['value']), ); Map _$StacTableColumnWidthToJson( diff --git a/packages/stac/lib/src/parsers/widgets/stac_table/stac_table_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_table/stac_table_parser.dart index f36faedb..b4b44797 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_table/stac_table_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_table/stac_table_parser.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac/stac.dart'; @@ -43,7 +44,7 @@ extension StacTableBorderParser on StacTableBorder { TableBorder parse(BuildContext context) { return TableBorder.all( color: color.toColor(context) ?? Colors.black, - width: width, + width: width.parse, style: style, borderRadius: borderRadius.parse, ); @@ -54,13 +55,13 @@ extension StacTableColumnWidthParser on StacTableColumnWidth { TableColumnWidth get parse { switch (type) { case StacTableColumnWidthType.fixedColumnWidth: - return FixedColumnWidth(value!); + return FixedColumnWidth(value!.parse); case StacTableColumnWidthType.flexColumnWidth: - return FlexColumnWidth(value!); + return FlexColumnWidth(value!.parse); case StacTableColumnWidthType.fractionColumnWidth: - return FractionColumnWidth(value!); + return FractionColumnWidth(value!.parse); case StacTableColumnWidthType.intrinsicColumnWidth: - return IntrinsicColumnWidth(flex: value!); + return IntrinsicColumnWidth(flex: value!.parse); } } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_text/stac_text.dart b/packages/stac/lib/src/parsers/widgets/stac_text/stac_text.dart index 8292d666..2950f10d 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_text/stac_text.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_text/stac_text.dart @@ -1,5 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_text_style/stac_text_style.dart'; export 'stac_text_parser.dart'; @@ -17,7 +18,7 @@ abstract class StacText with _$StacText { TextDirection? textDirection, bool? softWrap, TextOverflow? overflow, - double? textScaleFactor, + StacDouble? textScaleFactor, int? maxLines, String? semanticsLabel, TextWidthBasis? textWidthBasis, diff --git a/packages/stac/lib/src/parsers/widgets/stac_text/stac_text.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_text/stac_text.freezed.dart index e4b0b827..8c8b9341 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_text/stac_text.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_text/stac_text.freezed.dart @@ -22,7 +22,7 @@ mixin _$StacText { TextDirection? get textDirection; bool? get softWrap; TextOverflow? get overflow; - double? get textScaleFactor; + StacDouble? get textScaleFactor; int? get maxLines; String? get semanticsLabel; TextWidthBasis? get textWidthBasis; @@ -102,7 +102,7 @@ abstract mixin class $StacTextCopyWith<$Res> { TextDirection? textDirection, bool? softWrap, TextOverflow? overflow, - double? textScaleFactor, + StacDouble? textScaleFactor, int? maxLines, String? semanticsLabel, TextWidthBasis? textWidthBasis, @@ -168,7 +168,7 @@ class _$StacTextCopyWithImpl<$Res> implements $StacTextCopyWith<$Res> { textScaleFactor: freezed == textScaleFactor ? _self.textScaleFactor : textScaleFactor // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, maxLines: freezed == maxLines ? _self.maxLines : maxLines // ignore: cast_nullable_to_non_nullable @@ -245,7 +245,7 @@ class _StacText implements StacText { @override final TextOverflow? overflow; @override - final double? textScaleFactor; + final StacDouble? textScaleFactor; @override final int? maxLines; @override @@ -336,7 +336,7 @@ abstract mixin class _$StacTextCopyWith<$Res> TextDirection? textDirection, bool? softWrap, TextOverflow? overflow, - double? textScaleFactor, + StacDouble? textScaleFactor, int? maxLines, String? semanticsLabel, TextWidthBasis? textWidthBasis, @@ -403,7 +403,7 @@ class __$StacTextCopyWithImpl<$Res> implements _$StacTextCopyWith<$Res> { textScaleFactor: freezed == textScaleFactor ? _self.textScaleFactor : textScaleFactor // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, maxLines: freezed == maxLines ? _self.maxLines : maxLines // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_text/stac_text.g.dart b/packages/stac/lib/src/parsers/widgets/stac_text/stac_text.g.dart index f273981e..1e2765bf 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_text/stac_text.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_text/stac_text.g.dart @@ -19,7 +19,9 @@ _StacText _$StacTextFromJson(Map json) => _StacText( $enumDecodeNullable(_$TextDirectionEnumMap, json['textDirection']), softWrap: json['softWrap'] as bool?, overflow: $enumDecodeNullable(_$TextOverflowEnumMap, json['overflow']), - textScaleFactor: (json['textScaleFactor'] as num?)?.toDouble(), + textScaleFactor: json['textScaleFactor'] == null + ? null + : StacDouble.fromJson(json['textScaleFactor']), maxLines: (json['maxLines'] as num?)?.toInt(), semanticsLabel: json['semanticsLabel'] as String?, textWidthBasis: diff --git a/packages/stac/lib/src/parsers/widgets/stac_text/stac_text_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_text/stac_text_parser.dart index 03bee576..cc689bb5 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_text/stac_text_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_text/stac_text_parser.dart @@ -1,6 +1,7 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_text_style/stac_text_style.dart'; import 'package:stac/src/utils/color_utils.dart'; import 'package:stac/src/utils/widget_type.dart'; @@ -39,7 +40,7 @@ class StacTextParser extends StacParser { softWrap: model.softWrap, overflow: model.overflow, textScaler: model.textScaleFactor != null - ? TextScaler.linear(model.textScaleFactor!) + ? TextScaler.linear(model.textScaleFactor!.parse) : TextScaler.noScaling, maxLines: model.maxLines, semanticsLabel: model.semanticsLabel, diff --git a/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.dart b/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.dart index 241aa1e8..a16a2d5c 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_input_decoration/stac_input_decoration.dart'; import 'package:stac/src/parsers/widgets/stac_input_formatters/stac_input_formatter.dart'; import 'package:stac/src/parsers/widgets/stac_text_style/stac_text_style.dart'; @@ -33,8 +34,8 @@ abstract class StacTextField with _$StacTextField { @Default(false) bool obscureText, @Default(true) bool enableSuggestions, bool? enabled, - @Default(2) double cursorWidth, - double? cursorHeight, + @Default(StacDouble(2)) StacDouble cursorWidth, + StacDouble? cursorHeight, String? cursorColor, String? hintText, @Default([]) List inputFormatters, diff --git a/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.freezed.dart index e07ce021..733271bb 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.freezed.dart @@ -35,8 +35,8 @@ mixin _$StacTextField { bool get obscureText; bool get enableSuggestions; bool? get enabled; - double get cursorWidth; - double? get cursorHeight; + StacDouble get cursorWidth; + StacDouble? get cursorHeight; String? get cursorColor; String? get hintText; List get inputFormatters; @@ -170,8 +170,8 @@ abstract mixin class $StacTextFieldCopyWith<$Res> { bool obscureText, bool enableSuggestions, bool? enabled, - double cursorWidth, - double? cursorHeight, + StacDouble cursorWidth, + StacDouble? cursorHeight, String? cursorColor, String? hintText, List inputFormatters}); @@ -303,11 +303,11 @@ class _$StacTextFieldCopyWithImpl<$Res> cursorWidth: null == cursorWidth ? _self.cursorWidth : cursorWidth // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, cursorHeight: freezed == cursorHeight ? _self.cursorHeight : cursorHeight // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, cursorColor: freezed == cursorColor ? _self.cursorColor : cursorColor // ignore: cast_nullable_to_non_nullable @@ -376,7 +376,7 @@ class _StacTextField implements StacTextField { this.obscureText = false, this.enableSuggestions = true, this.enabled, - this.cursorWidth = 2, + this.cursorWidth = const StacDouble(2), this.cursorHeight, this.cursorColor, this.hintText, @@ -436,9 +436,9 @@ class _StacTextField implements StacTextField { final bool? enabled; @override @JsonKey() - final double cursorWidth; + final StacDouble cursorWidth; @override - final double? cursorHeight; + final StacDouble? cursorHeight; @override final String? cursorColor; @override @@ -587,8 +587,8 @@ abstract mixin class _$StacTextFieldCopyWith<$Res> bool obscureText, bool enableSuggestions, bool? enabled, - double cursorWidth, - double? cursorHeight, + StacDouble cursorWidth, + StacDouble? cursorHeight, String? cursorColor, String? hintText, List inputFormatters}); @@ -722,11 +722,11 @@ class __$StacTextFieldCopyWithImpl<$Res> cursorWidth: null == cursorWidth ? _self.cursorWidth : cursorWidth // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, cursorHeight: freezed == cursorHeight ? _self.cursorHeight : cursorHeight // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, cursorColor: freezed == cursorColor ? _self.cursorColor : cursorColor // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.g.dart b/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.g.dart index e76bfd3d..3d656d33 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.g.dart @@ -39,8 +39,12 @@ _StacTextField _$StacTextFieldFromJson(Map json) => obscureText: json['obscureText'] as bool? ?? false, enableSuggestions: json['enableSuggestions'] as bool? ?? true, enabled: json['enabled'] as bool?, - cursorWidth: (json['cursorWidth'] as num?)?.toDouble() ?? 2, - cursorHeight: (json['cursorHeight'] as num?)?.toDouble(), + cursorWidth: json['cursorWidth'] == null + ? const StacDouble(2) + : StacDouble.fromJson(json['cursorWidth']), + cursorHeight: json['cursorHeight'] == null + ? null + : StacDouble.fromJson(json['cursorHeight']), cursorColor: json['cursorColor'] as String?, hintText: json['hintText'] as String?, inputFormatters: (json['inputFormatters'] as List?) diff --git a/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field_parser.dart index 8592936f..ccfc0595 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field_parser.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_input_decoration/stac_input_decoration.dart'; import 'package:stac/src/parsers/widgets/stac_input_formatters/stac_input_formatter.dart'; import 'package:stac/src/parsers/widgets/stac_text_field/stac_text_field.dart'; @@ -47,8 +48,8 @@ class StacTextFieldParser extends StacParser { enableSuggestions: model.enableSuggestions, enabled: model.enabled, expands: model.expands, - cursorWidth: model.cursorWidth, - cursorHeight: model.cursorHeight, + cursorWidth: model.cursorWidth.parse, + cursorHeight: model.cursorHeight?.parse, cursorColor: model.cursorColor?.toColor(context), style: model.style?.parse(context), decoration: model.decoration?.parse(context), diff --git a/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.dart b/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.dart index ab446820..78330d18 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; import 'package:stac/src/parsers/widgets/stac_form_field_validator/stac_form_validator.dart'; import 'package:stac/src/parsers/widgets/stac_input_decoration/stac_input_decoration.dart'; @@ -41,14 +42,18 @@ abstract class StacTextFormField with _$StacTextFormField { MaxLengthEnforcement? maxLengthEnforcement, @Default(false) bool expands, Brightness? keyboardAppearance, - @Default(StacEdgeInsets(bottom: 20, top: 20, left: 20, right: 20)) + @Default(StacEdgeInsets( + bottom: StacDouble(20), + top: StacDouble(20), + left: StacDouble(20), + right: StacDouble(20))) StacEdgeInsets scrollPadding, String? restorationId, @Default(true) bool enableIMEPersonalizedLearning, @Default(true) bool enableSuggestions, bool? enabled, - @Default(2) double cursorWidth, - double? cursorHeight, + @Default(StacDouble(2)) StacDouble cursorWidth, + StacDouble? cursorHeight, String? cursorColor, String? hintText, AutovalidateMode? autovalidateMode, diff --git a/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.freezed.dart index 94496f95..f3b63df7 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.freezed.dart @@ -45,8 +45,8 @@ mixin _$StacTextFormField { bool get enableIMEPersonalizedLearning; bool get enableSuggestions; bool? get enabled; - double get cursorWidth; - double? get cursorHeight; + StacDouble get cursorWidth; + StacDouble? get cursorHeight; String? get cursorColor; String? get hintText; AutovalidateMode? get autovalidateMode; @@ -229,8 +229,8 @@ abstract mixin class $StacTextFormFieldCopyWith<$Res> { bool enableIMEPersonalizedLearning, bool enableSuggestions, bool? enabled, - double cursorWidth, - double? cursorHeight, + StacDouble cursorWidth, + StacDouble? cursorHeight, String? cursorColor, String? hintText, AutovalidateMode? autovalidateMode, @@ -417,11 +417,11 @@ class _$StacTextFormFieldCopyWithImpl<$Res> cursorWidth: null == cursorWidth ? _self.cursorWidth : cursorWidth // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, cursorHeight: freezed == cursorHeight ? _self.cursorHeight : cursorHeight // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, cursorColor: freezed == cursorColor ? _self.cursorColor : cursorColor // ignore: cast_nullable_to_non_nullable @@ -513,13 +513,16 @@ class _StacTextFormField implements StacTextFormField { this.maxLengthEnforcement, this.expands = false, this.keyboardAppearance, - this.scrollPadding = - const StacEdgeInsets(bottom: 20, top: 20, left: 20, right: 20), + this.scrollPadding = const StacEdgeInsets( + bottom: StacDouble(20), + top: StacDouble(20), + left: StacDouble(20), + right: StacDouble(20)), this.restorationId, this.enableIMEPersonalizedLearning = true, this.enableSuggestions = true, this.enabled, - this.cursorWidth = 2, + this.cursorWidth = const StacDouble(2), this.cursorHeight, this.cursorColor, this.hintText, @@ -603,9 +606,9 @@ class _StacTextFormField implements StacTextFormField { final bool? enabled; @override @JsonKey() - final double cursorWidth; + final StacDouble cursorWidth; @override - final double? cursorHeight; + final StacDouble? cursorHeight; @override final String? cursorColor; @override @@ -812,8 +815,8 @@ abstract mixin class _$StacTextFormFieldCopyWith<$Res> bool enableIMEPersonalizedLearning, bool enableSuggestions, bool? enabled, - double cursorWidth, - double? cursorHeight, + StacDouble cursorWidth, + StacDouble? cursorHeight, String? cursorColor, String? hintText, AutovalidateMode? autovalidateMode, @@ -1003,11 +1006,11 @@ class __$StacTextFormFieldCopyWithImpl<$Res> cursorWidth: null == cursorWidth ? _self.cursorWidth : cursorWidth // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, cursorHeight: freezed == cursorHeight ? _self.cursorHeight : cursorHeight // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, cursorColor: freezed == cursorColor ? _self.cursorColor : cursorColor // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.g.dart b/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.g.dart index c1f40411..85b1f98e 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.g.dart @@ -49,15 +49,23 @@ _StacTextFormField _$StacTextFormFieldFromJson(Map json) => keyboardAppearance: $enumDecodeNullable(_$BrightnessEnumMap, json['keyboardAppearance']), scrollPadding: json['scrollPadding'] == null - ? const StacEdgeInsets(bottom: 20, top: 20, left: 20, right: 20) + ? const StacEdgeInsets( + bottom: StacDouble(20), + top: StacDouble(20), + left: StacDouble(20), + right: StacDouble(20)) : StacEdgeInsets.fromJson(json['scrollPadding']), restorationId: json['restorationId'] as String?, enableIMEPersonalizedLearning: json['enableIMEPersonalizedLearning'] as bool? ?? true, enableSuggestions: json['enableSuggestions'] as bool? ?? true, enabled: json['enabled'] as bool?, - cursorWidth: (json['cursorWidth'] as num?)?.toDouble() ?? 2, - cursorHeight: (json['cursorHeight'] as num?)?.toDouble(), + cursorWidth: json['cursorWidth'] == null + ? const StacDouble(2) + : StacDouble.fromJson(json['cursorWidth']), + cursorHeight: json['cursorHeight'] == null + ? null + : StacDouble.fromJson(json['cursorHeight']), cursorColor: json['cursorColor'] as String?, hintText: json['hintText'] as String?, autovalidateMode: $enumDecodeNullable( diff --git a/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field_parser.dart index 4edf8dfb..ae71e35c 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:stac/src/parsers/parsers.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/color_utils.dart'; import 'package:stac/src/utils/input_validations.dart'; import 'package:stac/src/utils/log.dart'; @@ -85,8 +86,8 @@ class _TextFormFieldWidgetState extends State<_TextFormFieldWidget> { enableIMEPersonalizedLearning: widget.model.enableIMEPersonalizedLearning, enableSuggestions: widget.model.enableSuggestions, enabled: widget.model.enabled, - cursorWidth: widget.model.cursorWidth, - cursorHeight: widget.model.cursorHeight, + cursorWidth: widget.model.cursorWidth.parse, + cursorHeight: widget.model.cursorHeight?.parse, cursorColor: widget.model.cursorColor?.toColor(context), style: widget.model.style?.parse(context), decoration: widget.model.decoration.parse(context), diff --git a/packages/stac/lib/src/parsers/widgets/stac_text_style/stac_text_style.dart b/packages/stac/lib/src/parsers/widgets/stac_text_style/stac_text_style.dart index 11e9eaff..f1fc5105 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_text_style/stac_text_style.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_text_style/stac_text_style.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/parsers/widgets/stac_font_weight/stac_font_weight.dart'; import 'package:stac/src/utils/color_utils.dart'; @@ -13,15 +14,15 @@ abstract class StacTextStyle with _$StacTextStyle { String? color, String? backgroundColor, String? styleFromTheme, - double? fontSize, + StacDouble? fontSize, StacFontWeight? fontWeight, FontStyle? fontStyle, String? fontFamily, List? fontFamilyFallback, - double? letterSpacing, - double? wordSpacing, + StacDouble? letterSpacing, + StacDouble? wordSpacing, TextBaseline? textBaseline, - double? height, + StacDouble? height, }) = _StacTextStyle; factory StacTextStyle.fromJson(dynamic json) => _fromJson(json); @@ -78,15 +79,15 @@ extension StacTextStyleParser on StacTextStyle { inherit: inherit, color: color?.toColor(context), backgroundColor: backgroundColor.toColor(context), - fontSize: fontSize, + fontSize: fontSize?.parse, fontWeight: fontWeight?.value, fontStyle: fontStyle, fontFamily: fontFamily, fontFamilyFallback: fontFamilyFallback, - letterSpacing: letterSpacing, - wordSpacing: wordSpacing, + letterSpacing: letterSpacing?.parse, + wordSpacing: wordSpacing?.parse, textBaseline: textBaseline, - height: height, + height: height?.parse, ); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_text_style/stac_text_style.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_text_style/stac_text_style.freezed.dart index 54ebe756..c20c036f 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_text_style/stac_text_style.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_text_style/stac_text_style.freezed.dart @@ -19,15 +19,15 @@ mixin _$StacTextStyle { String? get color; String? get backgroundColor; String? get styleFromTheme; - double? get fontSize; + StacDouble? get fontSize; StacFontWeight? get fontWeight; FontStyle? get fontStyle; String? get fontFamily; List? get fontFamilyFallback; - double? get letterSpacing; - double? get wordSpacing; + StacDouble? get letterSpacing; + StacDouble? get wordSpacing; TextBaseline? get textBaseline; - double? get height; + StacDouble? get height; /// Create a copy of StacTextStyle /// with the given fields replaced by the non-null parameter values. @@ -105,15 +105,15 @@ abstract mixin class $StacTextStyleCopyWith<$Res> { String? color, String? backgroundColor, String? styleFromTheme, - double? fontSize, + StacDouble? fontSize, StacFontWeight? fontWeight, FontStyle? fontStyle, String? fontFamily, List? fontFamilyFallback, - double? letterSpacing, - double? wordSpacing, + StacDouble? letterSpacing, + StacDouble? wordSpacing, TextBaseline? textBaseline, - double? height}); + StacDouble? height}); } /// @nodoc @@ -163,7 +163,7 @@ class _$StacTextStyleCopyWithImpl<$Res> fontSize: freezed == fontSize ? _self.fontSize : fontSize // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, fontWeight: freezed == fontWeight ? _self.fontWeight : fontWeight // ignore: cast_nullable_to_non_nullable @@ -183,11 +183,11 @@ class _$StacTextStyleCopyWithImpl<$Res> letterSpacing: freezed == letterSpacing ? _self.letterSpacing : letterSpacing // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, wordSpacing: freezed == wordSpacing ? _self.wordSpacing : wordSpacing // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, textBaseline: freezed == textBaseline ? _self.textBaseline : textBaseline // ignore: cast_nullable_to_non_nullable @@ -195,7 +195,7 @@ class _$StacTextStyleCopyWithImpl<$Res> height: freezed == height ? _self.height : height // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, )); } } @@ -231,7 +231,7 @@ class _StacTextStyle implements StacTextStyle { @override final String? styleFromTheme; @override - final double? fontSize; + final StacDouble? fontSize; @override final StacFontWeight? fontWeight; @override @@ -250,13 +250,13 @@ class _StacTextStyle implements StacTextStyle { } @override - final double? letterSpacing; + final StacDouble? letterSpacing; @override - final double? wordSpacing; + final StacDouble? wordSpacing; @override final TextBaseline? textBaseline; @override - final double? height; + final StacDouble? height; /// Create a copy of StacTextStyle /// with the given fields replaced by the non-null parameter values. @@ -340,15 +340,15 @@ abstract mixin class _$StacTextStyleCopyWith<$Res> String? color, String? backgroundColor, String? styleFromTheme, - double? fontSize, + StacDouble? fontSize, StacFontWeight? fontWeight, FontStyle? fontStyle, String? fontFamily, List? fontFamilyFallback, - double? letterSpacing, - double? wordSpacing, + StacDouble? letterSpacing, + StacDouble? wordSpacing, TextBaseline? textBaseline, - double? height}); + StacDouble? height}); } /// @nodoc @@ -398,7 +398,7 @@ class __$StacTextStyleCopyWithImpl<$Res> fontSize: freezed == fontSize ? _self.fontSize : fontSize // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, fontWeight: freezed == fontWeight ? _self.fontWeight : fontWeight // ignore: cast_nullable_to_non_nullable @@ -418,11 +418,11 @@ class __$StacTextStyleCopyWithImpl<$Res> letterSpacing: freezed == letterSpacing ? _self.letterSpacing : letterSpacing // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, wordSpacing: freezed == wordSpacing ? _self.wordSpacing : wordSpacing // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, textBaseline: freezed == textBaseline ? _self.textBaseline : textBaseline // ignore: cast_nullable_to_non_nullable @@ -430,7 +430,7 @@ class __$StacTextStyleCopyWithImpl<$Res> height: freezed == height ? _self.height : height // ignore: cast_nullable_to_non_nullable - as double?, + as StacDouble?, )); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_text_style/stac_text_style.g.dart b/packages/stac/lib/src/parsers/widgets/stac_text_style/stac_text_style.g.dart index 07ccb2d9..324095d3 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_text_style/stac_text_style.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_text_style/stac_text_style.g.dart @@ -12,7 +12,9 @@ _StacTextStyle _$StacTextStyleFromJson(Map json) => color: json['color'] as String?, backgroundColor: json['backgroundColor'] as String?, styleFromTheme: json['styleFromTheme'] as String?, - fontSize: (json['fontSize'] as num?)?.toDouble(), + fontSize: json['fontSize'] == null + ? null + : StacDouble.fromJson(json['fontSize']), fontWeight: $enumDecodeNullable(_$StacFontWeightEnumMap, json['fontWeight']), fontStyle: $enumDecodeNullable(_$FontStyleEnumMap, json['fontStyle']), @@ -20,11 +22,16 @@ _StacTextStyle _$StacTextStyleFromJson(Map json) => fontFamilyFallback: (json['fontFamilyFallback'] as List?) ?.map((e) => e as String) .toList(), - letterSpacing: (json['letterSpacing'] as num?)?.toDouble(), - wordSpacing: (json['wordSpacing'] as num?)?.toDouble(), + letterSpacing: json['letterSpacing'] == null + ? null + : StacDouble.fromJson(json['letterSpacing']), + wordSpacing: json['wordSpacing'] == null + ? null + : StacDouble.fromJson(json['wordSpacing']), textBaseline: $enumDecodeNullable(_$TextBaselineEnumMap, json['textBaseline']), - height: (json['height'] as num?)?.toDouble(), + height: + json['height'] == null ? null : StacDouble.fromJson(json['height']), ); Map _$StacTextStyleToJson(_StacTextStyle instance) => diff --git a/packages/stac/lib/src/parsers/widgets/stac_visual_density/stac_visual_density.dart b/packages/stac/lib/src/parsers/widgets/stac_visual_density/stac_visual_density.dart index 770df56e..a692fa4e 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_visual_density/stac_visual_density.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_visual_density/stac_visual_density.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; part 'stac_visual_density.freezed.dart'; part 'stac_visual_density.g.dart'; @@ -7,8 +8,8 @@ part 'stac_visual_density.g.dart'; @freezed abstract class StacVisualDensity with _$StacVisualDensity { const factory StacVisualDensity({ - required double horizontal, - required double vertical, + required StacDouble horizontal, + required StacDouble vertical, }) = _StacVisualDensity; factory StacVisualDensity.fromJson(Map json) => @@ -17,7 +18,7 @@ abstract class StacVisualDensity with _$StacVisualDensity { extension StacVisualDensityExt on StacVisualDensity { VisualDensity get parse => VisualDensity( - horizontal: horizontal, - vertical: vertical, + horizontal: horizontal.parse, + vertical: vertical.parse, ); } diff --git a/packages/stac/lib/src/parsers/widgets/stac_visual_density/stac_visual_density.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_visual_density/stac_visual_density.freezed.dart index 6cf2328e..41d05c46 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_visual_density/stac_visual_density.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_visual_density/stac_visual_density.freezed.dart @@ -15,8 +15,8 @@ T _$identity(T value) => value; /// @nodoc mixin _$StacVisualDensity { - double get horizontal; - double get vertical; + StacDouble get horizontal; + StacDouble get vertical; /// Create a copy of StacVisualDensity /// with the given fields replaced by the non-null parameter values. @@ -56,7 +56,7 @@ abstract mixin class $StacVisualDensityCopyWith<$Res> { StacVisualDensity value, $Res Function(StacVisualDensity) _then) = _$StacVisualDensityCopyWithImpl; @useResult - $Res call({double horizontal, double vertical}); + $Res call({StacDouble horizontal, StacDouble vertical}); } /// @nodoc @@ -79,11 +79,11 @@ class _$StacVisualDensityCopyWithImpl<$Res> horizontal: null == horizontal ? _self.horizontal : horizontal // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, vertical: null == vertical ? _self.vertical : vertical // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, )); } } @@ -96,9 +96,9 @@ class _StacVisualDensity implements StacVisualDensity { _$StacVisualDensityFromJson(json); @override - final double horizontal; + final StacDouble horizontal; @override - final double vertical; + final StacDouble vertical; /// Create a copy of StacVisualDensity /// with the given fields replaced by the non-null parameter values. @@ -144,7 +144,7 @@ abstract mixin class _$StacVisualDensityCopyWith<$Res> __$StacVisualDensityCopyWithImpl; @override @useResult - $Res call({double horizontal, double vertical}); + $Res call({StacDouble horizontal, StacDouble vertical}); } /// @nodoc @@ -167,11 +167,11 @@ class __$StacVisualDensityCopyWithImpl<$Res> horizontal: null == horizontal ? _self.horizontal : horizontal // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, vertical: null == vertical ? _self.vertical : vertical // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, )); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_visual_density/stac_visual_density.g.dart b/packages/stac/lib/src/parsers/widgets/stac_visual_density/stac_visual_density.g.dart index 84801d99..1e1e7208 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_visual_density/stac_visual_density.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_visual_density/stac_visual_density.g.dart @@ -8,8 +8,8 @@ part of 'stac_visual_density.dart'; _StacVisualDensity _$StacVisualDensityFromJson(Map json) => _StacVisualDensity( - horizontal: (json['horizontal'] as num).toDouble(), - vertical: (json['vertical'] as num).toDouble(), + horizontal: StacDouble.fromJson(json['horizontal']), + vertical: StacDouble.fromJson(json['vertical']), ); Map _$StacVisualDensityToJson(_StacVisualDensity instance) => diff --git a/packages/stac/lib/src/parsers/widgets/stac_wrap/stac_wrap.dart b/packages/stac/lib/src/parsers/widgets/stac_wrap/stac_wrap.dart index 7b6939b2..d561a059 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_wrap/stac_wrap.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_wrap/stac_wrap.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; export 'stac_wrap_parser.dart'; @@ -11,9 +12,9 @@ abstract class StacWrap with _$StacWrap { const factory StacWrap({ @Default(Axis.horizontal) Axis direction, @Default(WrapAlignment.start) WrapAlignment alignment, - @Default(0.0) double spacing, + @Default(StacDouble.zero) StacDouble spacing, @Default(WrapAlignment.start) WrapAlignment runAlignment, - @Default(0.0) double runSpacing, + @Default(StacDouble.zero) StacDouble runSpacing, @Default(WrapCrossAlignment.start) WrapCrossAlignment crossAxisAlignment, TextDirection? textDirection, @Default(VerticalDirection.down) VerticalDirection verticalDirection, diff --git a/packages/stac/lib/src/parsers/widgets/stac_wrap/stac_wrap.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_wrap/stac_wrap.freezed.dart index cfa60eb8..ca22a27b 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_wrap/stac_wrap.freezed.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_wrap/stac_wrap.freezed.dart @@ -17,9 +17,9 @@ T _$identity(T value) => value; mixin _$StacWrap { Axis get direction; WrapAlignment get alignment; - double get spacing; + StacDouble get spacing; WrapAlignment get runAlignment; - double get runSpacing; + StacDouble get runSpacing; WrapCrossAlignment get crossAxisAlignment; TextDirection? get textDirection; VerticalDirection get verticalDirection; @@ -90,9 +90,9 @@ abstract mixin class $StacWrapCopyWith<$Res> { $Res call( {Axis direction, WrapAlignment alignment, - double spacing, + StacDouble spacing, WrapAlignment runAlignment, - double runSpacing, + StacDouble runSpacing, WrapCrossAlignment crossAxisAlignment, TextDirection? textDirection, VerticalDirection verticalDirection, @@ -135,7 +135,7 @@ class _$StacWrapCopyWithImpl<$Res> implements $StacWrapCopyWith<$Res> { spacing: null == spacing ? _self.spacing : spacing // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, runAlignment: null == runAlignment ? _self.runAlignment : runAlignment // ignore: cast_nullable_to_non_nullable @@ -143,7 +143,7 @@ class _$StacWrapCopyWithImpl<$Res> implements $StacWrapCopyWith<$Res> { runSpacing: null == runSpacing ? _self.runSpacing : runSpacing // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, crossAxisAlignment: null == crossAxisAlignment ? _self.crossAxisAlignment : crossAxisAlignment // ignore: cast_nullable_to_non_nullable @@ -174,9 +174,9 @@ class _StacWrap implements StacWrap { const _StacWrap( {this.direction = Axis.horizontal, this.alignment = WrapAlignment.start, - this.spacing = 0.0, + this.spacing = StacDouble.zero, this.runAlignment = WrapAlignment.start, - this.runSpacing = 0.0, + this.runSpacing = StacDouble.zero, this.crossAxisAlignment = WrapCrossAlignment.start, this.textDirection, this.verticalDirection = VerticalDirection.down, @@ -194,13 +194,13 @@ class _StacWrap implements StacWrap { final WrapAlignment alignment; @override @JsonKey() - final double spacing; + final StacDouble spacing; @override @JsonKey() final WrapAlignment runAlignment; @override @JsonKey() - final double runSpacing; + final StacDouble runSpacing; @override @JsonKey() final WrapCrossAlignment crossAxisAlignment; @@ -292,9 +292,9 @@ abstract mixin class _$StacWrapCopyWith<$Res> $Res call( {Axis direction, WrapAlignment alignment, - double spacing, + StacDouble spacing, WrapAlignment runAlignment, - double runSpacing, + StacDouble runSpacing, WrapCrossAlignment crossAxisAlignment, TextDirection? textDirection, VerticalDirection verticalDirection, @@ -337,7 +337,7 @@ class __$StacWrapCopyWithImpl<$Res> implements _$StacWrapCopyWith<$Res> { spacing: null == spacing ? _self.spacing : spacing // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, runAlignment: null == runAlignment ? _self.runAlignment : runAlignment // ignore: cast_nullable_to_non_nullable @@ -345,7 +345,7 @@ class __$StacWrapCopyWithImpl<$Res> implements _$StacWrapCopyWith<$Res> { runSpacing: null == runSpacing ? _self.runSpacing : runSpacing // ignore: cast_nullable_to_non_nullable - as double, + as StacDouble, crossAxisAlignment: null == crossAxisAlignment ? _self.crossAxisAlignment : crossAxisAlignment // ignore: cast_nullable_to_non_nullable diff --git a/packages/stac/lib/src/parsers/widgets/stac_wrap/stac_wrap.g.dart b/packages/stac/lib/src/parsers/widgets/stac_wrap/stac_wrap.g.dart index b6e8c180..68fa35e8 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_wrap/stac_wrap.g.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_wrap/stac_wrap.g.dart @@ -12,11 +12,15 @@ _StacWrap _$StacWrapFromJson(Map json) => _StacWrap( alignment: $enumDecodeNullable(_$WrapAlignmentEnumMap, json['alignment']) ?? WrapAlignment.start, - spacing: (json['spacing'] as num?)?.toDouble() ?? 0.0, + spacing: json['spacing'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['spacing']), runAlignment: $enumDecodeNullable(_$WrapAlignmentEnumMap, json['runAlignment']) ?? WrapAlignment.start, - runSpacing: (json['runSpacing'] as num?)?.toDouble() ?? 0.0, + runSpacing: json['runSpacing'] == null + ? StacDouble.zero + : StacDouble.fromJson(json['runSpacing']), crossAxisAlignment: $enumDecodeNullable( _$WrapCrossAlignmentEnumMap, json['crossAxisAlignment']) ?? WrapCrossAlignment.start, diff --git a/packages/stac/lib/src/parsers/widgets/stac_wrap/stac_wrap_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_wrap/stac_wrap_parser.dart index a792f9da..a1b58d66 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_wrap/stac_wrap_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_wrap/stac_wrap_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; @@ -19,9 +20,9 @@ class StacWrapParser extends StacParser { return Wrap( direction: model.direction, alignment: model.alignment, - spacing: model.spacing, + spacing: model.spacing.parse, runAlignment: model.runAlignment, - runSpacing: model.runSpacing, + runSpacing: model.runSpacing.parse, crossAxisAlignment: model.crossAxisAlignment, textDirection: model.textDirection, verticalDirection: model.verticalDirection,