diff --git a/modules/ensemble/lib/framework/widget/widget.dart b/modules/ensemble/lib/framework/widget/widget.dart index 1350014bf..06c6cfbee 100644 --- a/modules/ensemble/lib/framework/widget/widget.dart +++ b/modules/ensemble/lib/framework/widget/widget.dart @@ -100,7 +100,7 @@ abstract class EWidgetState rtn = AnimatedOpacity( // If visible, apply opacity if specified, else default to 1 opacity: widgetController.visible != false - ? (Utils.getValidOpacity(widgetController.opacity ?? 1) ?? 1) + ? (Utils.optionalDouble(widgetController.opacity ?? 1, min: 0, max: 1.0) ?? 1) : 0, duration: widgetController.visibilityTransitionDuration!, child: rtn); @@ -116,7 +116,7 @@ abstract class EWidgetState if (widgetController.visibilityTransitionDuration == null && widgetController.opacity != null) { rtn = Opacity( - opacity: Utils.getValidOpacity(widgetController.opacity!) ?? 1, + opacity: Utils.optionalDouble(widgetController.opacity!, min: 0, max: 1.0) ?? 1.0, child: rtn, ); } diff --git a/modules/ensemble/lib/util/utils.dart b/modules/ensemble/lib/util/utils.dart index 3dd6f37d6..b886a7db4 100644 --- a/modules/ensemble/lib/util/utils.dart +++ b/modules/ensemble/lib/util/utils.dart @@ -694,13 +694,6 @@ class Utils { return textAlign; } - static double? getValidOpacity(double opacity) { - if (opacity < 0 || opacity > 1) { - return 1; - } else { - return opacity; - } - } static Curve? getCurve(String? curveType) { Curve? curve; diff --git a/modules/ensemble/lib/widget/helpers/controllers.dart b/modules/ensemble/lib/widget/helpers/controllers.dart index 50e47c63f..f398af02c 100644 --- a/modules/ensemble/lib/widget/helpers/controllers.dart +++ b/modules/ensemble/lib/widget/helpers/controllers.dart @@ -261,7 +261,7 @@ abstract class WidgetController extends Controller with HasStyles { 'flex': (value) => flex = Utils.optionalInt(value, min: 1), 'expanded': (value) => expanded = Utils.getBool(value, fallback: false), 'visible': (value) => visible = Utils.getBool(value, fallback: true), - 'opacity': (value) => opacity = Utils.getValidOpacity(value), + 'opacity': (value) => opacity = Utils.optionalDouble(value, min: 0, max: 1), 'visibilityTransitionDuration': (value) => visibilityTransitionDuration = Utils.getDuration(value), 'elevation': (value) => @@ -487,7 +487,7 @@ abstract class EnsembleWidgetController extends EnsembleController 'flexMode': (value) => flexMode = FlexMode.values.from(value), 'flex': (value) => flex = Utils.optionalInt(value, min: 1), 'visible': (value) => visible = Utils.getBool(value, fallback: true), - 'opacity': (value) => opacity = Utils.getValidOpacity(value), + 'opacity': (value) => opacity = Utils.optionalDouble(value, min: 0, max: 1), 'visibilityTransitionDuration': (value) => visibilityTransitionDuration = Utils.getDuration(value), 'textDirection': (value) => textDirection = Utils.getTextDirection(value),