From e37a8392b79c22bc1cac6d5c993653b18857f49c Mon Sep 17 00:00:00 2001 From: Aaron Lademann Date: Mon, 13 Nov 2023 13:51:56 -0700 Subject: [PATCH 01/14] Make ErrorBoundary state fields non-nullable Since they are internal implementation details that are never set to null. --- lib/src/component/error_boundary.dart | 8 +++---- .../error_boundary.over_react.g.dart | 23 +++++++++++-------- .../component/error_boundary_recoverable.dart | 6 ++--- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/lib/src/component/error_boundary.dart b/lib/src/component/error_boundary.dart index c6b543c1f..190c188f9 100644 --- a/lib/src/component/error_boundary.dart +++ b/lib/src/component/error_boundary.dart @@ -123,12 +123,12 @@ mixin ErrorBoundaryState on UiState { /// more frequently than [ErrorBoundaryProps.identicalErrorFrequencyTolerance], a static copy of /// the render tree's HTML that was captured at the time of the error will be rendered. /// See: [ErrorBoundaryProps.onComponentIsUnrecoverable] for more information about this scenario. - bool? hasError; + late bool hasError; /// Whether to show "fallback" UI when [hasError] is true. /// /// This value will always be true if [ErrorBoundaryProps.fallbackUIRenderer] is non-null. - bool? showFallbackUIOnError; + late bool showFallbackUIOnError; } @Component2(isWrapper: true, isErrorBoundary: true) @@ -208,7 +208,7 @@ class ErrorBoundaryComponent @override render() { - if (state.hasError!) { // [2] + if (state.hasError) { // [2] return (Dom.div() ..key = 'ohnoes' ..addTestId('ErrorBoundary.unrecoverableErrorInnerHtmlContainerNode') @@ -224,7 +224,7 @@ class ErrorBoundaryComponent void componentDidUpdate(Map prevProps, Map prevState, [dynamic snapshot]) { // If the child is different, and the error boundary is currently in an error state, // give the children a chance to mount. - if (state.hasError!) { + if (state.hasError) { final childThatCausedError = typedPropsFactory(prevProps).children!.single; if (childThatCausedError != props.children!.single) { reset(); diff --git a/lib/src/component/error_boundary.over_react.g.dart b/lib/src/component/error_boundary.over_react.g.dart index eaf2a8c52..ca466a392 100644 --- a/lib/src/component/error_boundary.over_react.g.dart +++ b/lib/src/component/error_boundary.over_react.g.dart @@ -365,24 +365,27 @@ const PropsMeta _$metaForErrorBoundaryProps = PropsMeta( mixin $ErrorBoundaryState on ErrorBoundaryState { static const StateMeta meta = _$metaForErrorBoundaryState; @override - bool? get hasError => - (state[_$key__hasError__ErrorBoundaryState] ?? null) as bool?; + bool get hasError => + ((state[_$key__hasError__ErrorBoundaryState] ?? null)!) as bool; @override - set hasError(bool? value) => + set hasError(bool value) => state[_$key__hasError__ErrorBoundaryState] = value; @override - bool? get showFallbackUIOnError => - (state[_$key__showFallbackUIOnError__ErrorBoundaryState] ?? null) - as bool?; + bool get showFallbackUIOnError => + ((state[_$key__showFallbackUIOnError__ErrorBoundaryState] ?? null)!) + as bool; @override - set showFallbackUIOnError(bool? value) => + set showFallbackUIOnError(bool value) => state[_$key__showFallbackUIOnError__ErrorBoundaryState] = value; /* GENERATED CONSTANTS */ static const StateDescriptor _$prop__hasError__ErrorBoundaryState = - StateDescriptor(_$key__hasError__ErrorBoundaryState); + StateDescriptor(_$key__hasError__ErrorBoundaryState, + isRequired: true, isNullable: true); static const StateDescriptor - _$prop__showFallbackUIOnError__ErrorBoundaryState = - StateDescriptor(_$key__showFallbackUIOnError__ErrorBoundaryState); + _$prop__showFallbackUIOnError__ErrorBoundaryState = StateDescriptor( + _$key__showFallbackUIOnError__ErrorBoundaryState, + isRequired: true, + isNullable: true); static const String _$key__hasError__ErrorBoundaryState = 'ErrorBoundaryState.hasError'; static const String _$key__showFallbackUIOnError__ErrorBoundaryState = diff --git a/lib/src/component/error_boundary_recoverable.dart b/lib/src/component/error_boundary_recoverable.dart index 656f680b8..503fab7d0 100644 --- a/lib/src/component/error_boundary_recoverable.dart +++ b/lib/src/component/error_boundary_recoverable.dart @@ -72,7 +72,7 @@ class RecoverableErrorBoundaryComponent Date: Mon, 13 Nov 2023 13:58:07 -0700 Subject: [PATCH 02/14] Revert overzealous migration script changes No reason for these local vars that are initialized immediately to be nullable / typed on the left side. --- lib/src/component/resize_sensor.dart | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/src/component/resize_sensor.dart b/lib/src/component/resize_sensor.dart index eb7f862a2..6b4cd6a98 100644 --- a/lib/src/component/resize_sensor.dart +++ b/lib/src/component/resize_sensor.dart @@ -205,8 +205,7 @@ class ResizeSensorComponent extends UiComponent2 with SafeAni @override render() { - // FIXME null-safety why was this changed from `var` to `ReactElement?`? - ReactElement? expandSensor = (Dom.div() + final expandSensor = (Dom.div() ..className = 'resize-sensor-expand' ..onScroll = _handleSensorScroll ..style = props.shrink! ? shrinkBaseStyle : baseStyle @@ -215,7 +214,7 @@ class ResizeSensorComponent extends UiComponent2 with SafeAni (Dom.div()..style = expandSensorChildStyle)() ); - ReactElement? collapseSensor = (Dom.div() + final collapseSensor = (Dom.div() ..className = 'resize-sensor-collapse' ..onScroll = _handleSensorScroll ..style = props.shrink! ? shrinkBaseStyle : baseStyle @@ -224,7 +223,7 @@ class ResizeSensorComponent extends UiComponent2 with SafeAni (Dom.div()..style = collapseSensorChildStyle)() ); - ReactElement? resizeSensor = (Dom.div() + final resizeSensor = (Dom.div() ..className = 'resize-sensor' ..style = props.shrink! ? shrinkBaseStyle : baseStyle ..key = 'resizeSensor' From 140fcd8e861af62806659eedc47f762dbc62a3d0 Mon Sep 17 00:00:00 2001 From: Aaron Lademann Date: Mon, 13 Nov 2023 13:59:18 -0700 Subject: [PATCH 03/14] Avoid uninitialized var MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I’m not actually sure this would cause a problem, but it seemed like an awkward way to set the default IMO. --- lib/src/component/resize_sensor.dart | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/src/component/resize_sensor.dart b/lib/src/component/resize_sensor.dart index 6b4cd6a98..c2e75fbd8 100644 --- a/lib/src/component/resize_sensor.dart +++ b/lib/src/component/resize_sensor.dart @@ -229,13 +229,11 @@ class ResizeSensorComponent extends UiComponent2 with SafeAni ..key = 'resizeSensor' )(expandSensor, collapseSensor); - Map wrapperStyles; + var wrapperStyles = defaultWrapperStyles; if (props.isFlexChild!) { wrapperStyles = wrapperStylesFlexChild; } else if (props.isFlexContainer!) { wrapperStyles = wrapperStylesFlexContainer; - } else { - wrapperStyles = defaultWrapperStyles; } var mergedStyle = newStyleFromProps(props); From 8ada8d237932605e2fab2372aab648ebf1c61cc0 Mon Sep 17 00:00:00 2001 From: Aaron Lademann Date: Mon, 13 Nov 2023 14:46:39 -0700 Subject: [PATCH 04/14] Modernize #boyscoutin --- lib/src/component/resize_sensor.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/component/resize_sensor.dart b/lib/src/component/resize_sensor.dart index c2e75fbd8..244895aea 100644 --- a/lib/src/component/resize_sensor.dart +++ b/lib/src/component/resize_sensor.dart @@ -236,13 +236,13 @@ class ResizeSensorComponent extends UiComponent2 with SafeAni wrapperStyles = wrapperStylesFlexContainer; } - var mergedStyle = newStyleFromProps(props); - mergedStyle = {}..addAll(wrapperStyles)..addAll(mergedStyle); - return (Dom.div() ..modifyProps(addUnconsumedDomProps) ..className = forwardingClassNameBuilder().toClassName() - ..style = mergedStyle + ..style = { + ...wrapperStyles, + ...newStyleFromProps(props) + } )( props.children, resizeSensor From 5b468ffe0563cfdf2ff7d45c91123baba041d0ba Mon Sep 17 00:00:00 2001 From: Aaron Lademann Date: Mon, 13 Nov 2023 15:01:01 -0700 Subject: [PATCH 05/14] Make AbstractTransition state field non-nullable Since it is an internal implementation detail that is never set to null. This also required that the `initiallyShown` abstract getter become non-nullable. --- lib/src/component/abstract_transition.dart | 10 +++++----- .../component/abstract_transition.over_react.g.dart | 12 +++++++----- lib/src/component/error_boundary.over_react.g.dart | 5 ++--- .../component/abstract_transition_test.dart | 2 +- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/src/component/abstract_transition.dart b/lib/src/component/abstract_transition.dart index e962365a6..7116ed86b 100644 --- a/lib/src/component/abstract_transition.dart +++ b/lib/src/component/abstract_transition.dart @@ -30,7 +30,7 @@ mixin AbstractTransitionState on UiState { /// The current phase of transition the [AbstractTransitionComponent] is in. /// /// Default: [AbstractTransitionComponent.initiallyShown] ? [TransitionPhase.SHOWN] : [TransitionPhase.HIDDEN] - TransitionPhase? transitionPhase; + late TransitionPhase transitionPhase; } /// How to use [AbstractTransitionComponent]: @@ -101,14 +101,14 @@ abstract class AbstractTransitionComponent (newState() - ..transitionPhase = this.initiallyShown! ? TransitionPhase.SHOWN : TransitionPhase.HIDDEN + ..transitionPhase = this.initiallyShown ? TransitionPhase.SHOWN : TransitionPhase.HIDDEN ); /// Stream for listening to `transitionend` events on the [AbstractTransitionComponent]. StreamSubscription? _endTransitionSubscription; /// Whether the [AbstractTransitionComponent] should be visible initially when mounted. - bool? get initiallyShown; + bool get initiallyShown; /// Returns the DOM node that will transition. Element? getTransitionDomNode(); @@ -274,7 +274,7 @@ abstract class AbstractTransitionComponent + TransitionPhase get transitionPhase => (state[_$key__transitionPhase__AbstractTransitionState] ?? null) - as TransitionPhase?; + as TransitionPhase; @override - set transitionPhase(TransitionPhase? value) => + set transitionPhase(TransitionPhase value) => state[_$key__transitionPhase__AbstractTransitionState] = value; /* GENERATED CONSTANTS */ static const StateDescriptor - _$prop__transitionPhase__AbstractTransitionState = - StateDescriptor(_$key__transitionPhase__AbstractTransitionState); + _$prop__transitionPhase__AbstractTransitionState = StateDescriptor( + _$key__transitionPhase__AbstractTransitionState, + isRequired: true, + isNullable: true); static const String _$key__transitionPhase__AbstractTransitionState = 'AbstractTransitionState.transitionPhase'; diff --git a/lib/src/component/error_boundary.over_react.g.dart b/lib/src/component/error_boundary.over_react.g.dart index ca466a392..4e812a885 100644 --- a/lib/src/component/error_boundary.over_react.g.dart +++ b/lib/src/component/error_boundary.over_react.g.dart @@ -366,14 +366,13 @@ mixin $ErrorBoundaryState on ErrorBoundaryState { static const StateMeta meta = _$metaForErrorBoundaryState; @override bool get hasError => - ((state[_$key__hasError__ErrorBoundaryState] ?? null)!) as bool; + (state[_$key__hasError__ErrorBoundaryState] ?? null) as bool; @override set hasError(bool value) => state[_$key__hasError__ErrorBoundaryState] = value; @override bool get showFallbackUIOnError => - ((state[_$key__showFallbackUIOnError__ErrorBoundaryState] ?? null)!) - as bool; + (state[_$key__showFallbackUIOnError__ErrorBoundaryState] ?? null) as bool; @override set showFallbackUIOnError(bool value) => state[_$key__showFallbackUIOnError__ErrorBoundaryState] = value; diff --git a/test/over_react/component/abstract_transition_test.dart b/test/over_react/component/abstract_transition_test.dart index 93da9d4a7..68037f3c5 100644 --- a/test/over_react/component/abstract_transition_test.dart +++ b/test/over_react/component/abstract_transition_test.dart @@ -668,7 +668,7 @@ class TransitionerComponent extends AbstractTransitionComponent findDomNode(this); @override - bool? get initiallyShown => props.initiallyShown; + bool get initiallyShown => props.initiallyShown!; @override bool? get hasTransition => props.hasTransition; From ac1b57883ac775221758ceb27c3062b4144678d8 Mon Sep 17 00:00:00 2001 From: Aaron Lademann Date: Mon, 13 Nov 2023 15:04:58 -0700 Subject: [PATCH 06/14] Make more AbstractTransition required getters non-nullable --- lib/src/component/abstract_transition.dart | 10 +++++----- .../over_react/component/abstract_transition_test.dart | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/src/component/abstract_transition.dart b/lib/src/component/abstract_transition.dart index 7116ed86b..b3fa5a28e 100644 --- a/lib/src/component/abstract_transition.dart +++ b/lib/src/component/abstract_transition.dart @@ -114,13 +114,13 @@ abstract class AbstractTransitionComponent true; + bool get hasTransition => true; /// Whether the Element returned by [getTransitionDomNode] will have a transition event when showing. - bool get hasTransitionIn => hasTransition! && transitionInCount > 0; + bool get hasTransitionIn => hasTransition && transitionInCount > 0; /// Whether the Element returned by [getTransitionDomNode] will have a transition event when hiding. - bool get hasTransitionOut => hasTransition! && transitionOutCount > 0; + bool get hasTransitionOut => hasTransition && transitionOutCount > 0; /// The number of `transitionend` events that occur when the transition node is shown. /// @@ -133,7 +133,7 @@ abstract class AbstractTransitionComponent props.transitionOutCount ?? props.transitionCount ?? 1; /// The duration that can elapse before a transition timeout occurs. - Duration? get transitionTimeout => const Duration(seconds: 1); + Duration get transitionTimeout => const Duration(seconds: 1); /// Timer used to determine if a transition timeout has occurred. Timer? _transitionEndTimer; @@ -191,7 +191,7 @@ abstract class AbstractTransitionComponent props.initiallyShown!; @override - bool? get hasTransition => props.hasTransition; + bool get hasTransition => props.hasTransition!; @override - Duration? get transitionTimeout => props.transitionTimeout; + Duration get transitionTimeout => props.transitionTimeout!; @override render() { From 797a2425d58d65d078a7fef550c933dc93207938 Mon Sep 17 00:00:00 2001 From: Aaron Lademann Date: Mon, 13 Nov 2023 15:11:42 -0700 Subject: [PATCH 07/14] Make WithTransition state field non-nullable Since it is an internal implementation detail that is never set to null. --- lib/src/component/with_transition.dart | 6 +++--- lib/src/component/with_transition.over_react.g.dart | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/src/component/with_transition.dart b/lib/src/component/with_transition.dart index b90f3aec6..7a0ace58a 100644 --- a/lib/src/component/with_transition.dart +++ b/lib/src/component/with_transition.dart @@ -170,7 +170,7 @@ mixin WithTransitionState on UiState { /// /// Do not set directly. @protected - TransitionPhase? $transitionPhase; + late TransitionPhase $transitionPhase; } class WithTransitionComponent extends UiStatefulComponent2 { @@ -224,7 +224,7 @@ class WithTransitionComponent extends UiStatefulComponent2 + TransitionPhase get $transitionPhase => (state[_$key__$transitionPhase__WithTransitionState] ?? null) - as TransitionPhase?; + as TransitionPhase; @override @protected - set $transitionPhase(TransitionPhase? value) => + set $transitionPhase(TransitionPhase value) => state[_$key__$transitionPhase__WithTransitionState] = value; /* GENERATED CONSTANTS */ static const StateDescriptor _$prop__$transitionPhase__WithTransitionState = - StateDescriptor(_$key__$transitionPhase__WithTransitionState); + StateDescriptor(_$key__$transitionPhase__WithTransitionState, + isRequired: true, isNullable: true); static const String _$key__$transitionPhase__WithTransitionState = 'WithTransitionState.\$transitionPhase'; From 5db06179fef5390dfe36c7abe7f18c0bfdf62816 Mon Sep 17 00:00:00 2001 From: Aaron Lademann Date: Mon, 13 Nov 2023 15:24:25 -0700 Subject: [PATCH 08/14] Flux store, actions are req-non-nullable --- .../component_declaration/flux_component.dart | 16 ++++++---- .../flux_component.over_react.g.dart | 21 ++++++------ .../component2/handler_precedence.dart | 4 +-- .../component2/redraw_on.dart | 2 +- .../stateful/handler_precedence.dart | 4 +-- .../component2/stateful/redraw_on.dart | 2 +- .../component2/stateful/store_handlers.dart | 2 +- .../component2/store_handlers.dart | 2 +- .../handler_precedence.dart | 4 +-- .../flux_component_test/redraw_on.dart | 2 +- .../stateful/handler_precedence.dart | 4 +-- .../stateful/redraw_on.dart | 2 +- .../stateful/store_handlers.dart | 2 +- .../flux_component_test/store_handlers.dart | 2 +- .../fixtures/connect_flux_counter.dart | 2 +- .../fixtures/flux_counter.dart | 6 ++-- .../components/big_block.dart | 32 +++++++++---------- .../components/big_block.dart | 32 +++++++++---------- .../components/big_block.dart | 4 +-- .../components/big_block.dart | 4 +-- 20 files changed, 78 insertions(+), 71 deletions(-) diff --git a/lib/src/component_declaration/flux_component.dart b/lib/src/component_declaration/flux_component.dart index 79fa71824..97ffb6078 100644 --- a/lib/src/component_declaration/flux_component.dart +++ b/lib/src/component_declaration/flux_component.dart @@ -50,14 +50,18 @@ mixin FluxUiPropsMixin on UiProps implements FluxUiProps on UiProps implements FluxUiProps extends UiProps { /// There is no strict rule on the [ActionsT] type. Depending on application /// structure, there may be [Action]s available directly on this object, or /// this object may represent a hierarchy of actions. - ActionsT? get actions => props[_actionsPropKey] as ActionsT?; - set actions(ActionsT? value) => props[_actionsPropKey] = value; + ActionsT get actions => props[_actionsPropKey] as ActionsT; + set actions(ActionsT value) => props[_actionsPropKey] = value; /// The prop defined by [StoresT]. /// @@ -125,8 +129,8 @@ abstract class FluxUiProps extends UiProps { /// [StoresT] should be a class that provides access to these multiple stores. /// Then, you can explicitly select the [Store] instances that should be /// listened to by overriding [_FluxComponentMixin.redrawOn]. - StoresT? get store => props[_storePropKey] as StoresT?; - set store(StoresT? value) => props[_storePropKey] = value; + StoresT get store => props[_storePropKey] as StoresT; + set store(StoresT value) => props[_storePropKey] = value; } /// Builds on top of [UiComponent], adding w_flux integration, much like the [FluxComponent] in w_flux. diff --git a/lib/src/component_declaration/flux_component.over_react.g.dart b/lib/src/component_declaration/flux_component.over_react.g.dart index 663fec09e..30ed6c60f 100644 --- a/lib/src/component_declaration/flux_component.over_react.g.dart +++ b/lib/src/component_declaration/flux_component.over_react.g.dart @@ -16,24 +16,27 @@ mixin $FluxUiPropsMixin static const PropsMeta meta = _$metaForFluxUiPropsMixin; @override @override - ActionsT? get actions => - (props[_$key__actions__FluxUiPropsMixin] ?? null) as ActionsT?; + ActionsT get actions => + (props[_$key__actions__FluxUiPropsMixin] ?? null) as ActionsT; @override @override - set actions(ActionsT? value) => + set actions(ActionsT value) => props[_$key__actions__FluxUiPropsMixin] = value; @override @override - StoresT? get store => - (props[_$key__store__FluxUiPropsMixin] ?? null) as StoresT?; + StoresT get store => + (props[_$key__store__FluxUiPropsMixin] ?? null) as StoresT; @override @override - set store(StoresT? value) => props[_$key__store__FluxUiPropsMixin] = value; + set store(StoresT value) => props[_$key__store__FluxUiPropsMixin] = value; /* GENERATED CONSTANTS */ static const PropDescriptor _$prop__actions__FluxUiPropsMixin = - PropDescriptor(_$key__actions__FluxUiPropsMixin); - static const PropDescriptor _$prop__store__FluxUiPropsMixin = - PropDescriptor(_$key__store__FluxUiPropsMixin); + PropDescriptor(_$key__actions__FluxUiPropsMixin, + isRequired: true, isNullable: true); + static const PropDescriptor _$prop__store__FluxUiPropsMixin = PropDescriptor( + _$key__store__FluxUiPropsMixin, + isRequired: true, + isNullable: true); static const String _$key__actions__FluxUiPropsMixin = 'FluxUiPropsMixin.actions'; static const String _$key__store__FluxUiPropsMixin = 'FluxUiPropsMixin.store'; diff --git a/test/over_react/component_declaration/flux_component_test/component2/handler_precedence.dart b/test/over_react/component_declaration/flux_component_test/component2/handler_precedence.dart index a3326b916..07d2b7cbc 100644 --- a/test/over_react/component_declaration/flux_component_test/component2/handler_precedence.dart +++ b/test/over_react/component_declaration/flux_component_test/component2/handler_precedence.dart @@ -31,10 +31,10 @@ class TestHandlerPrecedenceComponent extends FluxUiComponent2 Dom.div()(); @override - redrawOn() => [props.store!.store1, props.store!.store2]; + redrawOn() => [props.store.store1, props.store.store2]; @override - getStoreHandlers() => {props.store!.store1: increment}; + getStoreHandlers() => {props.store.store1: increment}; increment(Store store) { numberOfHandlerCalls += 1; diff --git a/test/over_react/component_declaration/flux_component_test/component2/redraw_on.dart b/test/over_react/component_declaration/flux_component_test/component2/redraw_on.dart index 3f814c490..ee403b4c4 100644 --- a/test/over_react/component_declaration/flux_component_test/component2/redraw_on.dart +++ b/test/over_react/component_declaration/flux_component_test/component2/redraw_on.dart @@ -30,7 +30,7 @@ class TestRedrawOnComponent extends FluxUiComponent2 { render() => Dom.div()(); @override - redrawOn() => [props.store!.store1, props.store!.store2]; + redrawOn() => [props.store.store1, props.store.store2]; @override void setState(Map? _, [Function()? callback]) { diff --git a/test/over_react/component_declaration/flux_component_test/component2/stateful/handler_precedence.dart b/test/over_react/component_declaration/flux_component_test/component2/stateful/handler_precedence.dart index c50350889..e4cfda0df 100644 --- a/test/over_react/component_declaration/flux_component_test/component2/stateful/handler_precedence.dart +++ b/test/over_react/component_declaration/flux_component_test/component2/stateful/handler_precedence.dart @@ -34,10 +34,10 @@ class TestStatefulHandlerPrecedenceComponent extends FluxUiStatefulComponent2 Dom.div()(); @override - redrawOn() => [props.store!.store1, props.store!.store2]; + redrawOn() => [props.store.store1, props.store.store2]; @override - getStoreHandlers() => {props.store!.store1: increment}; + getStoreHandlers() => {props.store.store1: increment}; increment(Store store) { numberOfHandlerCalls += 1; diff --git a/test/over_react/component_declaration/flux_component_test/component2/stateful/redraw_on.dart b/test/over_react/component_declaration/flux_component_test/component2/stateful/redraw_on.dart index f7bc66ab4..713f0bd4f 100644 --- a/test/over_react/component_declaration/flux_component_test/component2/stateful/redraw_on.dart +++ b/test/over_react/component_declaration/flux_component_test/component2/stateful/redraw_on.dart @@ -33,7 +33,7 @@ class TestStatefulRedrawOnComponent extends FluxUiStatefulComponent2 Dom.div()(); @override - redrawOn() => [props.store!.store1, props.store!.store2]; + redrawOn() => [props.store.store1, props.store.store2]; @override void setState(Map? _, [Function()? callback]) { diff --git a/test/over_react/component_declaration/flux_component_test/component2/stateful/store_handlers.dart b/test/over_react/component_declaration/flux_component_test/component2/stateful/store_handlers.dart index 4060bb916..e3ff01d99 100644 --- a/test/over_react/component_declaration/flux_component_test/component2/stateful/store_handlers.dart +++ b/test/over_react/component_declaration/flux_component_test/component2/stateful/store_handlers.dart @@ -33,7 +33,7 @@ class TestStatefulStoreHandlersComponent extends FluxUiStatefulComponent2 Dom.div()(); @override - getStoreHandlers() => {props.store!: increment}; + getStoreHandlers() => {props.store: increment}; increment(Store store) { numberOfHandlerCalls += 1; diff --git a/test/over_react/component_declaration/flux_component_test/component2/store_handlers.dart b/test/over_react/component_declaration/flux_component_test/component2/store_handlers.dart index 4d90e5efa..32b81ae13 100644 --- a/test/over_react/component_declaration/flux_component_test/component2/store_handlers.dart +++ b/test/over_react/component_declaration/flux_component_test/component2/store_handlers.dart @@ -30,7 +30,7 @@ class TestStoreHandlersComponent extends FluxUiComponent2 Dom.div()(); @override - getStoreHandlers() => {props.store!: increment}; + getStoreHandlers() => {props.store: increment}; increment(Store store) { numberOfHandlerCalls += 1; diff --git a/test/over_react/component_declaration/flux_component_test/handler_precedence.dart b/test/over_react/component_declaration/flux_component_test/handler_precedence.dart index c811bb605..27c60996b 100644 --- a/test/over_react/component_declaration/flux_component_test/handler_precedence.dart +++ b/test/over_react/component_declaration/flux_component_test/handler_precedence.dart @@ -31,10 +31,10 @@ class TestHandlerPrecedenceComponent extends FluxUiComponent Dom.div()(); @override - redrawOn() => [props.store!.store1, props.store!.store2]; + redrawOn() => [props.store.store1, props.store.store2]; @override - getStoreHandlers() => {props.store!.store1: increment}; + getStoreHandlers() => {props.store.store1: increment}; increment(Store store) { numberOfHandlerCalls += 1; diff --git a/test/over_react/component_declaration/flux_component_test/redraw_on.dart b/test/over_react/component_declaration/flux_component_test/redraw_on.dart index 153493bc4..e8a300717 100644 --- a/test/over_react/component_declaration/flux_component_test/redraw_on.dart +++ b/test/over_react/component_declaration/flux_component_test/redraw_on.dart @@ -30,7 +30,7 @@ class TestRedrawOnComponent extends FluxUiComponent { render() => Dom.div()(); @override - redrawOn() => [props.store!.store1, props.store!.store2]; + redrawOn() => [props.store.store1, props.store.store2]; @override void setState(_, [Function()? callback]) { diff --git a/test/over_react/component_declaration/flux_component_test/stateful/handler_precedence.dart b/test/over_react/component_declaration/flux_component_test/stateful/handler_precedence.dart index 7773bd37c..c86f6cb1e 100644 --- a/test/over_react/component_declaration/flux_component_test/stateful/handler_precedence.dart +++ b/test/over_react/component_declaration/flux_component_test/stateful/handler_precedence.dart @@ -34,10 +34,10 @@ class TestStatefulHandlerPrecedenceComponent extends FluxUiStatefulComponent Dom.div()(); @override - redrawOn() => [props.store!.store1, props.store!.store2]; + redrawOn() => [props.store.store1, props.store.store2]; @override - getStoreHandlers() => {props.store!.store1: increment}; + getStoreHandlers() => {props.store.store1: increment}; increment(Store store) { numberOfHandlerCalls += 1; diff --git a/test/over_react/component_declaration/flux_component_test/stateful/redraw_on.dart b/test/over_react/component_declaration/flux_component_test/stateful/redraw_on.dart index 705fe8942..cfa795973 100644 --- a/test/over_react/component_declaration/flux_component_test/stateful/redraw_on.dart +++ b/test/over_react/component_declaration/flux_component_test/stateful/redraw_on.dart @@ -33,7 +33,7 @@ class TestStatefulRedrawOnComponent extends FluxUiStatefulComponent Dom.div()(); @override - redrawOn() => [props.store!.store1, props.store!.store2]; + redrawOn() => [props.store.store1, props.store.store2]; @override void setState(_, [Function()? callback]) { diff --git a/test/over_react/component_declaration/flux_component_test/stateful/store_handlers.dart b/test/over_react/component_declaration/flux_component_test/stateful/store_handlers.dart index e6bb748b2..d9617d921 100644 --- a/test/over_react/component_declaration/flux_component_test/stateful/store_handlers.dart +++ b/test/over_react/component_declaration/flux_component_test/stateful/store_handlers.dart @@ -33,7 +33,7 @@ class TestStatefulStoreHandlersComponent extends FluxUiStatefulComponent Dom.div()(); @override - getStoreHandlers() => {props.store!: increment}; + getStoreHandlers() => {props.store: increment}; increment(Store store) { numberOfHandlerCalls += 1; diff --git a/test/over_react/component_declaration/flux_component_test/store_handlers.dart b/test/over_react/component_declaration/flux_component_test/store_handlers.dart index 4efd523e9..41c1f2c92 100644 --- a/test/over_react/component_declaration/flux_component_test/store_handlers.dart +++ b/test/over_react/component_declaration/flux_component_test/store_handlers.dart @@ -30,7 +30,7 @@ class TestStoreHandlersComponent extends FluxUiComponent render() => Dom.div()(); @override - getStoreHandlers() => {props.store!: increment}; + getStoreHandlers() => {props.store: increment}; increment(Store store) { numberOfHandlerCalls += 1; diff --git a/test/over_react_redux/fixtures/connect_flux_counter.dart b/test/over_react_redux/fixtures/connect_flux_counter.dart index bfd4bb4d5..56b95c950 100644 --- a/test/over_react_redux/fixtures/connect_flux_counter.dart +++ b/test/over_react_redux/fixtures/connect_flux_counter.dart @@ -57,7 +57,7 @@ class ConnectFluxCounterComponent } else if (props.increment != null) { props.increment!(); } else { - props.actions!.incrementAction(1); + props.actions.incrementAction(1); } } )('+'), diff --git a/test/over_react_redux/fixtures/flux_counter.dart b/test/over_react_redux/fixtures/flux_counter.dart index cd2ae6ee2..be20d752d 100644 --- a/test/over_react_redux/fixtures/flux_counter.dart +++ b/test/over_react_redux/fixtures/flux_counter.dart @@ -32,17 +32,17 @@ class FluxCounterComponent extends FluxUiComponent2 { @override render() { return (Dom.div()..modifyProps(addUnconsumedProps))( - Dom.div()('Count: ${props.store!.count}'), + Dom.div()('Count: ${props.store.count}'), (Dom.button() ..addTestId('button-increment') ..onClick = (_) { - props.actions!.incrementAction(1); + props.actions.incrementAction(1); } )('+'), (Dom.button() ..addTestId('button-decrement') ..onClick = (_) { - props.actions!.decrementAction(1); + props.actions.decrementAction(1); } )('-'), props.children, diff --git a/web/flux_to_redux/advanced/examples/flux_implementation/components/big_block.dart b/web/flux_to_redux/advanced/examples/flux_implementation/components/big_block.dart index 560d82d1e..20318b9c0 100644 --- a/web/flux_to_redux/advanced/examples/flux_implementation/components/big_block.dart +++ b/web/flux_to_redux/advanced/examples/flux_implementation/components/big_block.dart @@ -22,7 +22,7 @@ part 'big_block.over_react.g.dart'; UiFactory BigBlock = castUiFactory(_$BigBlock); // ignore: undefined_identifier mixin BigBlockPropsMixin on UiProps { - AnotherColorStore? store2; + late AnotherColorStore store2; } class BigBlockProps = UiProps @@ -31,10 +31,10 @@ class BigBlockProps = UiProps class BigBlockComponent extends FluxUiComponent2 { @override redrawOn() => [ - props.store!, - props.store!.midLevelStore, - props.store!.midLevelStore.lowLevelStore, - props.store2!, + props.store, + props.store.midLevelStore, + props.store.midLevelStore.lowLevelStore, + props.store2, ]; @override @@ -43,7 +43,7 @@ class BigBlockComponent extends FluxUiComponent2 { (Dom.div() ..style = { 'padding': '50px', - 'backgroundColor': props.store!.backgroundColor, + 'backgroundColor': props.store.backgroundColor, 'color': 'white', 'display': 'flex', 'alignItems': 'center', @@ -59,25 +59,25 @@ class BigBlockComponent extends FluxUiComponent2 { )( (Dom.button() ..onClick = (_) { - props.actions!.changeMainBackgroundColor(props.store!.backgroundColor); + props.actions.changeMainBackgroundColor(props.store.backgroundColor); } ..style = {'padding': '10px', 'margin': '10px'} )('Change Main Background Color'), (Dom.button() ..onClick = (_) { - props.actions!.changeBlockOneBackgroundColor(props.store!.midLevelStore.backgroundColor); + props.actions.changeBlockOneBackgroundColor(props.store.midLevelStore.backgroundColor); } ..style = {'padding': '10px', 'margin': '10px'} )('Change Block 1 Background Color'), (Dom.button() ..onClick = (_) { - props.actions!.changeBlockTwoBackgroundColor(props.store!.midLevelStore.lowLevelStore.backgroundColor); + props.actions.changeBlockTwoBackgroundColor(props.store.midLevelStore.lowLevelStore.backgroundColor); } ..style = {'padding': '10px', 'margin': '10px'} )('Change Block 2 Background Color'), (Dom.button() ..onClick = (_) { - props.actions!.changeBlockThreeBackgroundColor(props.store2!.backgroundColor); + props.actions.changeBlockThreeBackgroundColor(props.store2.backgroundColor); } ..style = {'padding': '10px', 'margin': '10px'} )('Change Block 3 Background Color'), @@ -85,18 +85,18 @@ class BigBlockComponent extends FluxUiComponent2 { (Dom.div()..style = {'display': 'flex', 'flexDirection': 'column'})( (LittleBlock() ..blockTitle = 'Block 1' - ..backgroundColor = this.props.store!.midLevelStore.backgroundColor - ..colorString = this.props.store!.midLevelStore.backgroundColor + ..backgroundColor = this.props.store.midLevelStore.backgroundColor + ..colorString = this.props.store.midLevelStore.backgroundColor )(), (LittleBlock() ..blockTitle = 'Block 2' - ..backgroundColor = this.props.store!.midLevelStore.lowLevelStore.backgroundColor - ..colorString = this.props.store!.midLevelStore.lowLevelStore.backgroundColor + ..backgroundColor = this.props.store.midLevelStore.lowLevelStore.backgroundColor + ..colorString = this.props.store.midLevelStore.lowLevelStore.backgroundColor )(), (LittleBlock() ..blockTitle = 'Block 3' - ..backgroundColor = this.props.store2!.backgroundColor - ..colorString = this.props.store2!.backgroundColor + ..backgroundColor = this.props.store2.backgroundColor + ..colorString = this.props.store2.backgroundColor )(), ), ), diff --git a/web/flux_to_redux/advanced/examples/influx_implementation/components/big_block.dart b/web/flux_to_redux/advanced/examples/influx_implementation/components/big_block.dart index 61a77a869..e16b46c96 100644 --- a/web/flux_to_redux/advanced/examples/influx_implementation/components/big_block.dart +++ b/web/flux_to_redux/advanced/examples/influx_implementation/components/big_block.dart @@ -23,9 +23,9 @@ UiFactory BigBlock = castUiFactory(_$BigBlock); // ignore: undefi @Props() mixin BigBlockPropsMixin on UiProps { - LowLevelStore? lowLevelStore; + late LowLevelStore lowLevelStore; - AnotherColorStore? secondStore; + late AnotherColorStore secondStore; } class BigBlockProps = UiProps @@ -34,9 +34,9 @@ class BigBlockProps = UiProps class BigBlockComponent extends FluxUiComponent2 { @override redrawOn() => [ - props.store!, - props.lowLevelStore!, - props.secondStore!, + props.store, + props.lowLevelStore, + props.secondStore, ]; @override @@ -45,7 +45,7 @@ class BigBlockComponent extends FluxUiComponent2 { (Dom.div() ..style = { 'padding': '50px', - 'backgroundColor': props.store!.state.mainBackgroundColor, + 'backgroundColor': props.store.state.mainBackgroundColor, 'color': 'white', 'display': 'flex', 'alignItems': 'center', @@ -61,25 +61,25 @@ class BigBlockComponent extends FluxUiComponent2 { )( (Dom.button() ..onClick = (_) { - props.actions!.changeMainBackgroundColor(props.store!.blockOneBackgroundColor); + props.actions.changeMainBackgroundColor(props.store.blockOneBackgroundColor); } ..style = {'padding': '10px', 'margin': '10px'} )('Change Main Background Color'), (Dom.button() ..onClick = (_) { - props.actions!.changeBlockOneBackgroundColor(props.store!.mainBackgroundColor); + props.actions.changeBlockOneBackgroundColor(props.store.mainBackgroundColor); } ..style = {'padding': '10px', 'margin': '10px'} )('Change Block 1 Background Color'), (Dom.button() ..onClick = (_) { - props.actions!.changeBlockTwoBackgroundColor(props.store!.mainBackgroundColor); + props.actions.changeBlockTwoBackgroundColor(props.store.mainBackgroundColor); } ..style = {'padding': '10px', 'margin': '10px'} )('Change Block 2 Background Color'), (Dom.button() ..onClick = (_) { - props.actions!.changeBlockThreeBackgroundColor(props.secondStore!.backgroundColor); + props.actions.changeBlockThreeBackgroundColor(props.secondStore.backgroundColor); } ..style = {'padding': '10px', 'margin': '10px'} )('Change Block 3 Background Color'), @@ -87,18 +87,18 @@ class BigBlockComponent extends FluxUiComponent2 { (Dom.div()..style = {'display': 'flex', 'flexDirection': 'column'})( (LittleBlock() ..blockTitle = 'Block 1' - ..backgroundColor = props.store!.state.blockOneBackgroundColor - ..colorString = props.store!.state.blockOneBackgroundColor + ..backgroundColor = props.store.state.blockOneBackgroundColor + ..colorString = props.store.state.blockOneBackgroundColor )(), (LittleBlock() ..blockTitle = 'Block 2' - ..backgroundColor = props.lowLevelStore!.state.backgroundColor - ..colorString = props.lowLevelStore!.state.backgroundColor + ..backgroundColor = props.lowLevelStore.state.backgroundColor + ..colorString = props.lowLevelStore.state.backgroundColor )(), (LittleBlock() ..blockTitle = 'Block 3' - ..backgroundColor = props.secondStore!.state.backgroundColor - ..colorString = props.secondStore!.state.backgroundColor + ..backgroundColor = props.secondStore.state.backgroundColor + ..colorString = props.secondStore.state.backgroundColor )(), ), ), diff --git a/web/flux_to_redux/simple/examples/flux_implementation/components/big_block.dart b/web/flux_to_redux/simple/examples/flux_implementation/components/big_block.dart index 8bd4cf591..4287a852c 100644 --- a/web/flux_to_redux/simple/examples/flux_implementation/components/big_block.dart +++ b/web/flux_to_redux/simple/examples/flux_implementation/components/big_block.dart @@ -26,11 +26,11 @@ class BigBlockComponent extends FluxUiComponent2 { @override render() { return (Fragment()( - (Dom.div()..style = {'padding': '50px', 'backgroundColor': props.store!.backgroundColor, 'color': 'white'})( + (Dom.div()..style = {'padding': '50px', 'backgroundColor': props.store.backgroundColor, 'color': 'white'})( 'This module uses a flux pattern to change its background color.', (Dom.button() ..onClick = (_) { - props.actions!.changeBackgroundColor('green'); + props.actions.changeBackgroundColor('green'); } ..style = {'padding': '10px', 'margin': '10px'} )('Change Background Color'), diff --git a/web/flux_to_redux/simple/examples/influx_implementation/components/big_block.dart b/web/flux_to_redux/simple/examples/influx_implementation/components/big_block.dart index 2a3fe0771..280465543 100644 --- a/web/flux_to_redux/simple/examples/influx_implementation/components/big_block.dart +++ b/web/flux_to_redux/simple/examples/influx_implementation/components/big_block.dart @@ -26,11 +26,11 @@ class BigBlockComponent extends FluxUiComponent2 { @override render() { return (Fragment()( - (Dom.div()..style = {'padding': '50px', 'backgroundColor': props.store!.backgroundColor, 'color': 'white'})( + (Dom.div()..style = {'padding': '50px', 'backgroundColor': props.store.backgroundColor, 'color': 'white'})( 'This module uses a flux pattern to change its background color.', (Dom.button() ..onClick = (_) { - props.actions!.changeBackgroundColor('blue'); + props.actions.changeBackgroundColor('blue'); } ..style = {'padding': '10px', 'margin': '10px'} )('Change Background Color'), From 5c25a4e3284cf185e6b5dbdb308a1b4cb2a83d4f Mon Sep 17 00:00:00 2001 From: Aaron Lademann Date: Mon, 13 Nov 2023 15:32:49 -0700 Subject: [PATCH 09/14] ConnectFluxPropsMixin.actions is req-non-nullable Same with the actions params that get passed around `connectFlux` utils --- lib/src/over_react_redux/over_react_flux.dart | 18 +++++------ .../over_react_flux.over_react.g.dart | 9 +++--- .../connect_flux_integration_test.dart | 6 ++-- test/over_react_redux/connect_flux_test.dart | 32 +++++++++---------- .../fixtures/connect_flux_counter.dart | 2 +- .../connect_flux_counter.over_react.g.dart | 10 +++--- .../redux_multi_provider_test.dart | 6 ++-- .../components/connect_flux_big_block.dart | 6 ++-- .../components/connect_flux_big_block.dart | 2 +- 9 files changed, 46 insertions(+), 45 deletions(-) diff --git a/lib/src/over_react_redux/over_react_flux.dart b/lib/src/over_react_redux/over_react_flux.dart index f88daedd4..801698712 100644 --- a/lib/src/over_react_redux/over_react_flux.dart +++ b/lib/src/over_react_redux/over_react_flux.dart @@ -43,7 +43,7 @@ abstract class _$ConnectFluxPropsMixin implements UiProps { @override Map get props; - TActions? actions; + late TActions actions; } /// The actions that are associated with a given [InfluxStoreMixin] store @@ -436,8 +436,8 @@ UiFactory Function(UiFactory) connectFlux({ Map Function(TStore state)? mapStateToProps, Map Function(TStore state, TProps ownProps)? mapStateToPropsWithOwnProps, - Map Function(TActions? actions)? mapActionsToProps, - Map Function(TActions? actions, TProps ownProps)? mapActionsToPropsWithOwnProps, + Map Function(TActions actions)? mapActionsToProps, + Map Function(TActions actions, TProps ownProps)? mapActionsToPropsWithOwnProps, Map Function(TProps stateProps, TProps dispatchProps, TProps ownProps)? mergeProps, // Use default parameter values instead of ??= in the function body to allow consumers @@ -519,7 +519,7 @@ UiFactory Function(UiFactory) Map wrappedMapStateToProps(TStore state) { return { ...originalMapStateToProps!(state), - ...mapActionsToProps!(actionsForStore[state] as TActions?), + ...mapActionsToProps!(actionsForStore[state] as TActions), }; } @@ -530,7 +530,7 @@ UiFactory Function(UiFactory) if (case4) { mapStateToProps = (state) { return { - ...mapActionsToProps!(actionsForStore[state] as TActions?), + ...mapActionsToProps!(actionsForStore[state] as TActions), }; }; } @@ -542,7 +542,7 @@ UiFactory Function(UiFactory) return { ...originalMapStateWithOwnProps!(state, ownProps), ...mapActionsToPropsWithOwnProps!( - actionsForStore[state] as TActions?, ownProps), + actionsForStore[state] as TActions, ownProps), }; } @@ -554,7 +554,7 @@ UiFactory Function(UiFactory) mapStateToPropsWithOwnProps = (state, ownProps) { return { ...mapActionsToPropsWithOwnProps!( - actionsForStore[state] as TActions?, ownProps), + actionsForStore[state] as TActions, ownProps), }; }; } @@ -568,7 +568,7 @@ UiFactory Function(UiFactory) return { ...newMapStateToProps!(state), ...mapActionsToPropsWithOwnProps!( - actionsForStore[state] as TActions?, ownProps), + actionsForStore[state] as TActions, ownProps), }; }; @@ -583,7 +583,7 @@ UiFactory Function(UiFactory) Map wrappedMapStateToPropsWithOwnProps(TStore state, TProps ownProps) { return { ...originalMapStateWithOwnProps!(state, ownProps), - ...mapActionsToProps!(actionsForStore[state] as TActions?), + ...mapActionsToProps!(actionsForStore[state] as TActions), }; } diff --git a/lib/src/over_react_redux/over_react_flux.over_react.g.dart b/lib/src/over_react_redux/over_react_flux.over_react.g.dart index c670fc766..52cb90f90 100644 --- a/lib/src/over_react_redux/over_react_flux.over_react.g.dart +++ b/lib/src/over_react_redux/over_react_flux.over_react.g.dart @@ -16,16 +16,17 @@ abstract class ConnectFluxPropsMixin /// @override - TActions? get actions => - (props[_$key__actions___$ConnectFluxPropsMixin] ?? null) as TActions?; + TActions get actions => + (props[_$key__actions___$ConnectFluxPropsMixin] ?? null) as TActions; /// @override - set actions(TActions? value) => + set actions(TActions value) => props[_$key__actions___$ConnectFluxPropsMixin] = value; /* GENERATED CONSTANTS */ static const PropDescriptor _$prop__actions___$ConnectFluxPropsMixin = - PropDescriptor(_$key__actions___$ConnectFluxPropsMixin); + PropDescriptor(_$key__actions___$ConnectFluxPropsMixin, + isRequired: true, isNullable: true); static const String _$key__actions___$ConnectFluxPropsMixin = 'actions'; static const List $props = [ diff --git a/test/over_react_redux/connect_flux_integration_test.dart b/test/over_react_redux/connect_flux_integration_test.dart index 5b71f03db..4d6c5dcef 100644 --- a/test/over_react_redux/connect_flux_integration_test.dart +++ b/test/over_react_redux/connect_flux_integration_test.dart @@ -105,7 +105,7 @@ main() { mapStateToProps: (state) => (ConnectFluxCounter()..currentCount = state.count), mapActionsToProps: (actions) => (ConnectFluxCounter() - ..increment = actions!.incrementAction + ..increment = actions.incrementAction ..decrement = actions.decrementAction), )(ConnectFluxCounter); @@ -154,7 +154,7 @@ main() { mapStateToProps: (state) => (ConnectFluxCounter()..currentCount = state.count), mapActionsToProps: (actions) => (ConnectFluxCounter() - ..increment = actions!.incrementAction + ..increment = actions.incrementAction ..decrement = actions.decrementAction), )(ConnectFluxCounter); @@ -241,7 +241,7 @@ main() { mapStateToProps: (state) => (ConnectFluxCounter()..currentCount = state.count), mapActionsToProps: (actions) => (ConnectFluxCounter() - ..increment = actions!.incrementAction + ..increment = actions.incrementAction ..decrement = actions.decrementAction), )(ConnectFluxCounter); diff --git a/test/over_react_redux/connect_flux_test.dart b/test/over_react_redux/connect_flux_test.dart index 2564349ed..16ed88665 100644 --- a/test/over_react_redux/connect_flux_test.dart +++ b/test/over_react_redux/connect_flux_test.dart @@ -87,7 +87,7 @@ main() { ConnectedCounter = connectFlux( mapStateToProps: (state) => (ConnectFluxCounter()..currentCount = state.count), mapActionsToProps: (actions) => (ConnectFluxCounter() - ..increment = actions!.incrementAction + ..increment = actions.incrementAction ..decrement = actions.decrementAction), )(ConnectFluxCounter); @@ -143,7 +143,7 @@ main() { ConnectedCounter = connectFlux( mapStateToProps: (state) => (ConnectFluxCounter()..currentCount = state.count), mapActionsToProps: (actions) => (ConnectFluxCounter() - ..increment = actions!.incrementAction + ..increment = actions.incrementAction ..decrement = actions.decrementAction), forwardRef: true)(ConnectFluxCounter); @@ -189,7 +189,7 @@ main() { mapStateToPropsWithOwnProps: (state, ownProps) => (ConnectFluxCounter()..currentCount = state.count), mapActionsToProps: (actions) => (ConnectFluxCounter() - ..increment = actions!.incrementAction + ..increment = actions.incrementAction ..decrement = actions.decrementAction), forwardRef: true, )(ConnectFluxCounter); @@ -223,7 +223,7 @@ main() { return ConnectFluxCounter()..currentCount = state.count; }, mapActionsToProps: (actions) => (ConnectFluxCounter() - ..increment = actions!.incrementAction + ..increment = actions.incrementAction ..decrement = actions.decrementAction), forwardRef: true, )(ConnectFluxCounter); @@ -261,7 +261,7 @@ main() { return ConnectFluxCounter()..currentCount = state.count; }, mapActionsToProps: (actions) => (ConnectFluxCounter() - ..increment = actions!.incrementAction + ..increment = actions.incrementAction ..decrement = actions.decrementAction), forwardRef: true, )(ConnectFluxCounter); @@ -296,7 +296,7 @@ main() { ConnectedCounter = connectFlux( mapStateToProps: (state) => (ConnectFluxCounter()..currentCount = state.count), mapActionsToProps: (actions) { - return ConnectFluxCounter()..decrement = actions!.decrementAction; + return ConnectFluxCounter()..decrement = actions.decrementAction; }, mergeProps: (stateProps, dispatchProps, ownProps) { propsReferences.addAll([stateProps, dispatchProps, ownProps]); @@ -387,7 +387,7 @@ main() { return ConnectFluxCounter()..currentCount = state.count; }, mapActionsToProps: (actions) => - (ConnectFluxCounter()..increment = actions!.incrementAction), + (ConnectFluxCounter()..increment = actions.incrementAction), areStatePropsEqual: (next, prev) { methodsCalled.add({ 'called': 'areStatePropsEqual', @@ -553,7 +553,7 @@ main() { mapStateToProps: (state) => (ConnectFluxCounter()..currentCount = state.count), mapActionsToProps: (actions) { return ConnectFluxCounter() - ..increment = actions!.incrementAction + ..increment = actions.incrementAction ..decrement = actions.decrementAction; }, forwardRef: true, @@ -561,7 +561,7 @@ main() { ConnectFluxCounterProps Function([Map]) ConnectedBigCounter = connectFlux( mapStateToProps: (state) => (ConnectFluxCounter()..currentCount = state.count), mapActionsToProps: (actions) => (ConnectFluxCounter() - ..increment = actions!.incrementAction + ..increment = actions.incrementAction ..decrement = actions.decrementAction), context: bigCounterContext, forwardRef: true, @@ -593,7 +593,7 @@ main() { ConnectedCounter = connectFlux( mapStateToProps: (state) => (ConnectFluxCounter()..currentCount = state.count), mapActionsToProps: (actions) => (ConnectFluxCounter() - ..increment = actions!.incrementAction + ..increment = actions.incrementAction ..decrement = actions.decrementAction), forwardRef: true, )(ConnectFluxCounter); @@ -601,7 +601,7 @@ main() { ConnectFluxCounterProps Function([Map]) ConnectedBigCounter = connectFlux( mapStateToProps: (state) => (ConnectFluxCounter()..currentCount = state.count), mapActionsToProps: (actions) => (ConnectFluxCounter() - ..increment = actions!.incrementAction + ..increment = actions.incrementAction ..decrement = actions.decrementAction), context: bigCounterContext, forwardRef: true, @@ -734,7 +734,7 @@ main() { mapStateToProps: (state) => (ConnectFluxCounter()..mutatedList = state.listYouDefShouldntMutate), mapActionsToProps: (actions) => - (ConnectFluxCounter()..mutateStoreDirectly = actions!.mutateStoreDirectly), + (ConnectFluxCounter()..mutateStoreDirectly = actions.mutateStoreDirectly), )(ConnectFluxCounter); final jacket = mount((ReduxProvider()..store = store1)( @@ -759,18 +759,18 @@ main() { } typedef MapStateToPropsCallback = Map Function(FluxStore); -typedef MapActionsToPropsCallback = Map Function(FluxActions?); +typedef MapActionsToPropsCallback = Map Function(FluxActions); typedef MapStateToPropsWithOwnPropsCallback = Map Function(FluxStore, ConnectFluxCounterProps); -typedef MapActionsToPropsWithOwnPropsCallback = Map Function(FluxActions?, ConnectFluxCounterProps); +typedef MapActionsToPropsWithOwnPropsCallback = Map Function(FluxActions, ConnectFluxCounterProps); MapStateToPropsCallback get testMapStateToProps => (state) => (ConnectFluxCounter()..currentCount = state.count); MapActionsToPropsCallback get testMapActionsToProps => - (actions) => (ConnectFluxCounter()..increment = actions!.incrementAction); + (actions) => (ConnectFluxCounter()..increment = actions.incrementAction); MapStateToPropsWithOwnPropsCallback get testMapStateToPropsWithOwnProps => (state, ownProps) => (ConnectFluxCounter()..currentCount = state.count); MapActionsToPropsWithOwnPropsCallback get testMapActionsToPropsWithOwnProps => - (actions, ownProps) => (ConnectFluxCounter()..increment = actions!.incrementAction); + (actions, ownProps) => (ConnectFluxCounter()..increment = actions.incrementAction); class ParameterTestCase { final String name; diff --git a/test/over_react_redux/fixtures/connect_flux_counter.dart b/test/over_react_redux/fixtures/connect_flux_counter.dart index 56b95c950..4c294e0e3 100644 --- a/test/over_react_redux/fixtures/connect_flux_counter.dart +++ b/test/over_react_redux/fixtures/connect_flux_counter.dart @@ -36,7 +36,7 @@ class _$ConnectFluxCounterProps extends UiProps { void Function()? mutateStoreDirectly; - FluxActions? actions; + late FluxActions actions; } @Component2() diff --git a/test/over_react_redux/fixtures/connect_flux_counter.over_react.g.dart b/test/over_react_redux/fixtures/connect_flux_counter.over_react.g.dart index 16df6e0e5..3d1c923d4 100644 --- a/test/over_react_redux/fixtures/connect_flux_counter.over_react.g.dart +++ b/test/over_react_redux/fixtures/connect_flux_counter.over_react.g.dart @@ -90,13 +90,12 @@ abstract class _$ConnectFluxCounterPropsAccessorsMixin /// @override - FluxActions? get actions => - (props[_$key__actions___$ConnectFluxCounterProps] ?? null) - as FluxActions?; + FluxActions get actions => + (props[_$key__actions___$ConnectFluxCounterProps] ?? null) as FluxActions; /// @override - set actions(FluxActions? value) => + set actions(FluxActions value) => props[_$key__actions___$ConnectFluxCounterProps] = value; /* GENERATED CONSTANTS */ static const PropDescriptor _$prop__currentCount___$ConnectFluxCounterProps = @@ -113,7 +112,8 @@ abstract class _$ConnectFluxCounterPropsAccessorsMixin _$prop__mutateStoreDirectly___$ConnectFluxCounterProps = PropDescriptor(_$key__mutateStoreDirectly___$ConnectFluxCounterProps); static const PropDescriptor _$prop__actions___$ConnectFluxCounterProps = - PropDescriptor(_$key__actions___$ConnectFluxCounterProps); + PropDescriptor(_$key__actions___$ConnectFluxCounterProps, + isRequired: true, isNullable: true); static const String _$key__currentCount___$ConnectFluxCounterProps = 'ConnectFluxCounterProps.currentCount'; static const String _$key__wrapperStyles___$ConnectFluxCounterProps = diff --git a/test/over_react_redux/redux_multi_provider_test.dart b/test/over_react_redux/redux_multi_provider_test.dart index 48e023fe1..45b7f1efb 100644 --- a/test/over_react_redux/redux_multi_provider_test.dart +++ b/test/over_react_redux/redux_multi_provider_test.dart @@ -50,7 +50,7 @@ main() { mapStateToProps: (state) => (ConnectFluxCounter()..currentCount = state.count), mapActionsToProps: (actions) => - (ConnectFluxCounter()..increment = actions!.incrementAction), + (ConnectFluxCounter()..increment = actions.incrementAction), context: context1, )(ConnectFluxCounter); @@ -59,7 +59,7 @@ main() { mapStateToProps: (state) => (ConnectFluxCounter()..currentCount = state.count), mapActionsToProps: (actions) => - (ConnectFluxCounter()..increment = actions!.incrementAction), + (ConnectFluxCounter()..increment = actions.incrementAction), context: context2, )(ConnectFluxCounter); @@ -68,7 +68,7 @@ main() { mapStateToProps: (state) => (ConnectFluxCounter()..currentCount = state.count), mapActionsToProps: (actions) => - (ConnectFluxCounter()..increment = actions!.incrementAction), + (ConnectFluxCounter()..increment = actions.incrementAction), context: context3, )(ConnectFluxCounter); diff --git a/web/flux_to_redux/advanced/examples/influx_implementation/components/connect_flux_big_block.dart b/web/flux_to_redux/advanced/examples/influx_implementation/components/connect_flux_big_block.dart index b2e23f935..5c57da227 100644 --- a/web/flux_to_redux/advanced/examples/influx_implementation/components/connect_flux_big_block.dart +++ b/web/flux_to_redux/advanced/examples/influx_implementation/components/connect_flux_big_block.dart @@ -42,7 +42,7 @@ UiFactory ConnectFluxBigBlock = composeHocs([ ..blockOneBackgroundColor = state.blockOneBackgroundColor ), mapActionsToProps: (actions) => (ConnectFluxBigBlock() - ..changeMainBackgroundColor = actions!.changeMainBackgroundColor + ..changeMainBackgroundColor = actions.changeMainBackgroundColor ..changeBlockOneBackgroundColor = actions.changeBlockOneBackgroundColor ), ), @@ -52,7 +52,7 @@ UiFactory ConnectFluxBigBlock = composeHocs([ // [7] mapStateToProps: (state) => (ConnectFluxBigBlock()..blockTwoBackgroundColor = state.backgroundColor), mapActionsToProps: (actions) => - (ConnectFluxBigBlock()..changeBlockTwoBackgroundColor = actions!.changeBlockTwoBackgroundColor), + (ConnectFluxBigBlock()..changeBlockTwoBackgroundColor = actions.changeBlockTwoBackgroundColor), ), // [5] connectFlux( @@ -60,7 +60,7 @@ UiFactory ConnectFluxBigBlock = composeHocs([ // [7] mapStateToProps: (state) => (ConnectFluxBigBlock()..blockThreeBackgroundColor = state.backgroundColor), mapActionsToProps: (actions) => - (ConnectFluxBigBlock()..changeBlockThreeBackgroundColor = actions!.changeBlockThreeBackgroundColor), + (ConnectFluxBigBlock()..changeBlockThreeBackgroundColor = actions.changeBlockThreeBackgroundColor), ), ])(castUiFactory(_$ConnectFluxBigBlock)); // ignore: undefined_identifier diff --git a/web/flux_to_redux/simple/examples/influx_implementation/components/connect_flux_big_block.dart b/web/flux_to_redux/simple/examples/influx_implementation/components/connect_flux_big_block.dart index 0b1d8f341..bd932aa85 100644 --- a/web/flux_to_redux/simple/examples/influx_implementation/components/connect_flux_big_block.dart +++ b/web/flux_to_redux/simple/examples/influx_implementation/components/connect_flux_big_block.dart @@ -33,7 +33,7 @@ UiFactory ConnectFluxBigBlock = // [5] mapStateToProps: (state) => (ConnectFluxBigBlock()..backgroundColor = state.backgroundColor), mapActionsToProps: (actions) => - (ConnectFluxBigBlock()..changeBackgroundColor = actions!.changeBackgroundColor), + (ConnectFluxBigBlock()..changeBackgroundColor = actions.changeBackgroundColor), )(castUiFactory(_$ConnectFluxBigBlock)); // ignore: undefined_identifier mixin ConnectFluxBigBlockPropsMixin on UiProps { From ff760b5f0b14bc928bd0e7b4ba135aacfb4b662e Mon Sep 17 00:00:00 2001 From: Aaron Lademann Date: Mon, 13 Nov 2023 15:43:03 -0700 Subject: [PATCH 10/14] ReduxProviderProps.store is req-non-nullable --- lib/src/over_react_redux/over_react_redux.dart | 2 +- .../over_react_redux/over_react_redux.over_react.g.dart | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/src/over_react_redux/over_react_redux.dart b/lib/src/over_react_redux/over_react_redux.dart index 3cb8973d6..27247f686 100644 --- a/lib/src/over_react_redux/over_react_redux.dart +++ b/lib/src/over_react_redux/over_react_redux.dart @@ -423,7 +423,7 @@ class JsReactRedux { @Props(keyNamespace: '') mixin ReduxProviderPropsMixin on UiProps { /// The __single__ Redux store in your application. - Store? store; + late Store store; /// You may provide a context instance. If you do so, you will need to provide the same context /// instance to all of your connected components as well. diff --git a/lib/src/over_react_redux/over_react_redux.over_react.g.dart b/lib/src/over_react_redux/over_react_redux.over_react.g.dart index 871f4b737..6f7b6c092 100644 --- a/lib/src/over_react_redux/over_react_redux.over_react.g.dart +++ b/lib/src/over_react_redux/over_react_redux.over_react.g.dart @@ -46,10 +46,10 @@ const PropsMeta _$metaForConnectPropsMixin = PropsMeta( mixin $ReduxProviderPropsMixin on ReduxProviderPropsMixin { static const PropsMeta meta = _$metaForReduxProviderPropsMixin; @override - Store? get store => - (props[_$key__store__ReduxProviderPropsMixin] ?? null) as Store?; + Store get store => + (props[_$key__store__ReduxProviderPropsMixin] ?? null) as Store; @override - set store(Store? value) => + set store(Store value) => props[_$key__store__ReduxProviderPropsMixin] = value; @override dynamic get context => @@ -59,7 +59,8 @@ mixin $ReduxProviderPropsMixin on ReduxProviderPropsMixin { props[_$key__context__ReduxProviderPropsMixin] = value; /* GENERATED CONSTANTS */ static const PropDescriptor _$prop__store__ReduxProviderPropsMixin = - PropDescriptor(_$key__store__ReduxProviderPropsMixin); + PropDescriptor(_$key__store__ReduxProviderPropsMixin, + isRequired: true, isNullable: true); static const PropDescriptor _$prop__context__ReduxProviderPropsMixin = PropDescriptor(_$key__context__ReduxProviderPropsMixin); static const String _$key__store__ReduxProviderPropsMixin = 'store'; From 1a27a52a58739c02e6ac2c1c994818a634d32092 Mon Sep 17 00:00:00 2001 From: Aaron Lademann Date: Mon, 13 Nov 2023 15:43:24 -0700 Subject: [PATCH 11/14] ReduxMultiProviderProps.storesByContext is req-non-nullable --- lib/src/over_react_redux/redux_multi_provider.dart | 7 +++---- .../redux_multi_provider.over_react.g.dart | 11 +++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/src/over_react_redux/redux_multi_provider.dart b/lib/src/over_react_redux/redux_multi_provider.dart index 9a75388de..f3b7c7e0c 100644 --- a/lib/src/over_react_redux/redux_multi_provider.dart +++ b/lib/src/over_react_redux/redux_multi_provider.dart @@ -57,8 +57,7 @@ class _$ReduxMultiProviderProps extends UiProps { /// Each context and store instance should be unique. Referencing the context /// in a connected component is exactly the same as it would with a standard /// [ReduxProvider]. - @requiredProp - Map? storesByContext; + late Map storesByContext; } @Component2() @@ -68,7 +67,7 @@ class ReduxMultiProviderComponent get propTypes => { keyForProp((p) => p.storesByContext): (props, info) { final storesByContext = props.storesByContext; - if (storesByContext != null && storesByContext.isEmpty) { + if (storesByContext.isEmpty) { return PropError.value( storesByContext, info.propName, 'It must not be empty'); } @@ -79,7 +78,7 @@ class ReduxMultiProviderComponent @override render() { dynamic content = props.children; - props.storesByContext!.forEach((context, store) { + props.storesByContext.forEach((context, store) { content = (ReduxProvider() ..store = store ..context = context diff --git a/lib/src/over_react_redux/redux_multi_provider.over_react.g.dart b/lib/src/over_react_redux/redux_multi_provider.over_react.g.dart index 03972578f..1625e24b6 100644 --- a/lib/src/over_react_redux/redux_multi_provider.over_react.g.dart +++ b/lib/src/over_react_redux/redux_multi_provider.over_react.g.dart @@ -32,10 +32,9 @@ abstract class _$ReduxMultiProviderPropsAccessorsMixin /// /// @override - @requiredProp - Map? get storesByContext => + Map get storesByContext => (props[_$key__storesByContext___$ReduxMultiProviderProps] ?? null) - as Map?; + as Map; /// A `Map` of contexts that connected components within the component tree /// can use to receive updates from specific stores. @@ -46,14 +45,14 @@ abstract class _$ReduxMultiProviderPropsAccessorsMixin /// /// @override - @requiredProp - set storesByContext(Map? value) => + set storesByContext(Map value) => props[_$key__storesByContext___$ReduxMultiProviderProps] = value; /* GENERATED CONSTANTS */ static const PropDescriptor _$prop__storesByContext___$ReduxMultiProviderProps = PropDescriptor( _$key__storesByContext___$ReduxMultiProviderProps, - isRequired: true); + isRequired: true, + isNullable: true); static const String _$key__storesByContext___$ReduxMultiProviderProps = 'ReduxMultiProviderProps.storesByContext'; From 8dcccb7bc81382c7182ee05feefb943c1cd59d43 Mon Sep 17 00:00:00 2001 From: Aaron Lademann Date: Wed, 15 Nov 2023 08:14:02 -0700 Subject: [PATCH 12/14] Make deprecated ErrorBoundary state fields non-nullable Missed this in e37a8392b79c22bc1cac6d5c993653b18857f49c --- .../component/_deprecated/error_boundary.dart | 4 ++-- .../_deprecated/error_boundary_mixins.dart | 8 ++++---- .../error_boundary_mixins.over_react.g.dart | 18 ++++++++++-------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/src/component/_deprecated/error_boundary.dart b/lib/src/component/_deprecated/error_boundary.dart index 8faaee5a7..27e483186 100644 --- a/lib/src/component/_deprecated/error_boundary.dart +++ b/lib/src/component/_deprecated/error_boundary.dart @@ -119,7 +119,7 @@ class ErrorBoundaryComponent @override - bool? get hasError => - (state[_$key__hasError___$ErrorBoundaryStateMixin] ?? null) as bool?; + bool get hasError => + (state[_$key__hasError___$ErrorBoundaryStateMixin] ?? null) as bool; /// Whether a component within the tree that the [ErrorBoundary] is wrapping around threw an error. /// @@ -359,7 +359,7 @@ abstract class ErrorBoundaryStateMixin implements _$ErrorBoundaryStateMixin { /// /// @override - set hasError(bool? value) => + set hasError(bool value) => state[_$key__hasError___$ErrorBoundaryStateMixin] = value; /// Whether to show "fallback" UI when [hasError] is true. @@ -368,9 +368,9 @@ abstract class ErrorBoundaryStateMixin implements _$ErrorBoundaryStateMixin { /// /// @override - bool? get showFallbackUIOnError => + bool get showFallbackUIOnError => (state[_$key__showFallbackUIOnError___$ErrorBoundaryStateMixin] ?? null) - as bool?; + as bool; /// Whether to show "fallback" UI when [hasError] is true. /// @@ -378,14 +378,16 @@ abstract class ErrorBoundaryStateMixin implements _$ErrorBoundaryStateMixin { /// /// @override - set showFallbackUIOnError(bool? value) => + set showFallbackUIOnError(bool value) => state[_$key__showFallbackUIOnError___$ErrorBoundaryStateMixin] = value; /* GENERATED CONSTANTS */ static const StateDescriptor _$prop__hasError___$ErrorBoundaryStateMixin = - StateDescriptor(_$key__hasError___$ErrorBoundaryStateMixin); + StateDescriptor(_$key__hasError___$ErrorBoundaryStateMixin, + isRequired: true, isNullable: true); static const StateDescriptor _$prop__showFallbackUIOnError___$ErrorBoundaryStateMixin = - StateDescriptor(_$key__showFallbackUIOnError___$ErrorBoundaryStateMixin); + StateDescriptor(_$key__showFallbackUIOnError___$ErrorBoundaryStateMixin, + isRequired: true, isNullable: true); static const String _$key__hasError___$ErrorBoundaryStateMixin = 'ErrorBoundaryStateMixin.hasError'; static const String _$key__showFallbackUIOnError___$ErrorBoundaryStateMixin = From f13cdb1c928a2298d9a8ca106cabb6c64a2448a2 Mon Sep 17 00:00:00 2001 From: Aaron Lademann Date: Fri, 17 Nov 2023 08:19:52 -0700 Subject: [PATCH 13/14] Replace block ifs with null-aware calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit since Dart can’t infer non-null types on class fields :( --- .../_deprecated/abstract_transition.dart | 8 ++---- .../component/_deprecated/error_boundary.dart | 10 ++----- .../_deprecated/error_boundary_mixins.dart | 4 +-- .../component/_deprecated/resize_sensor.dart | 4 +-- lib/src/component/abstract_transition.dart | 8 ++---- lib/src/component/error_boundary.dart | 10 ++----- .../component/error_boundary_recoverable.dart | 4 +-- lib/src/component/resize_sensor.dart | 4 +-- .../_deprecated/abstract_transition_test.dart | 28 +++++-------------- .../component/abstract_transition_test.dart | 24 ++++------------ .../fixtures/dummy_composite_component.dart | 12 ++------ 11 files changed, 28 insertions(+), 88 deletions(-) diff --git a/lib/src/component/_deprecated/abstract_transition.dart b/lib/src/component/_deprecated/abstract_transition.dart index d8d1d31dd..5cac0b441 100644 --- a/lib/src/component/_deprecated/abstract_transition.dart +++ b/lib/src/component/_deprecated/abstract_transition.dart @@ -382,17 +382,13 @@ abstract class AbstractTransitionComponent with SafeAni ..scrollLeft = maxSensorSize ..scrollTop = maxSensorSize; - if (props.onDidReset != null) { - props.onDidReset!(); - } + props.onDidReset?.call(); } /// Call to repair / re-initialize a [ResizeSensor] that was detached from the DOM when it mounted. diff --git a/lib/src/component/abstract_transition.dart b/lib/src/component/abstract_transition.dart index b3fa5a28e..f0ee00eae 100644 --- a/lib/src/component/abstract_transition.dart +++ b/lib/src/component/abstract_transition.dart @@ -367,17 +367,13 @@ abstract class AbstractTransitionComponent with SafeAni ..scrollLeft = maxSensorSize ..scrollTop = maxSensorSize; - if (props.onDidReset != null) { - props.onDidReset!(); - } + props.onDidReset?.call(); } /// Call to repair / re-initialize a [ResizeSensor] that was detached from the DOM when it mounted. diff --git a/test/over_react/component/_deprecated/abstract_transition_test.dart b/test/over_react/component/_deprecated/abstract_transition_test.dart index 420a982c0..e380da319 100644 --- a/test/over_react/component/_deprecated/abstract_transition_test.dart +++ b/test/over_react/component/_deprecated/abstract_transition_test.dart @@ -689,61 +689,47 @@ class TransitionerComponent extends AbstractTransitionComponent transitionPhasesSet = []; diff --git a/test/over_react/component/abstract_transition_test.dart b/test/over_react/component/abstract_transition_test.dart index ecdb293b3..cd03653bf 100644 --- a/test/over_react/component/abstract_transition_test.dart +++ b/test/over_react/component/abstract_transition_test.dart @@ -685,25 +685,19 @@ class TransitionerComponent extends AbstractTransitionComponent transitionPhasesSet = []; diff --git a/test/over_react/dom/fixtures/dummy_composite_component.dart b/test/over_react/dom/fixtures/dummy_composite_component.dart index abd3d2c94..3c4781f6b 100644 --- a/test/over_react/dom/fixtures/dummy_composite_component.dart +++ b/test/over_react/dom/fixtures/dummy_composite_component.dart @@ -32,25 +32,19 @@ class _$TestCompositeComponentProps extends UiProps { class TestCompositeComponentComponent extends UiComponent { @override void componentDidMount() { - if (props.onComponentDidMount != null) { - props.onComponentDidMount!(); - } + props.onComponentDidMount?.call(); } @override void componentDidUpdate(_, __) { - if (props.onComponentDidUpdate != null) { - props.onComponentDidUpdate!(); - } + props.onComponentDidUpdate?.call(); } @override void componentWillUnmount() { super.componentWillUnmount(); - if (props.onComponentWillUnmount != null) { - props.onComponentWillUnmount!(); - } + props.onComponentWillUnmount?.call(); } @override From 136eb834d6cc04b101a76857716aa18ac9e04702 Mon Sep 17 00:00:00 2001 From: Aaron Lademann Date: Fri, 17 Nov 2023 14:47:57 -0700 Subject: [PATCH 14/14] Remove unnecessary test --- .../redux_multi_provider_test.dart | 38 +++++++------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/test/over_react_redux/redux_multi_provider_test.dart b/test/over_react_redux/redux_multi_provider_test.dart index a58ec49ba..0380aa411 100644 --- a/test/over_react_redux/redux_multi_provider_test.dart +++ b/test/over_react_redux/redux_multi_provider_test.dart @@ -117,30 +117,20 @@ main() { expect(findDomNode(context3Counter)!.innerHtml, contains('Count: 3')); }); - group('works as expected when storesByContext is', () { - test('null', () { - expect( - () => mount(ReduxMultiProvider()( - (Dom.div()..addTestId('content'))('foo'), - )), - logsPropRequiredError('ReduxMultiProviderProps.storesByContext')); - }); - - test('empty', () { - expect( - () => mount((ReduxMultiProvider()..storesByContext = {})( - (Dom.div()..addTestId('content'))('foo'), - )), - logsPropValueError('{}', 'ReduxMultiProviderProps.storesByContext', - 'It must not be empty')); - - final jacket = mount((ReduxMultiProvider()..storesByContext = {})( - (Dom.div()..addTestId('content'))('foo'), - )); - - expect(queryByTestId(jacket.mountNode, 'content')!.innerHtml, - contains('foo')); - }); + test('works as expected when storesByContext is empty', () { + expect( + () => mount((ReduxMultiProvider()..storesByContext = {})( + (Dom.div()..addTestId('content'))('foo'), + )), + logsPropValueError('{}', 'ReduxMultiProviderProps.storesByContext', + 'It must not be empty')); + + final jacket = mount((ReduxMultiProvider()..storesByContext = {})( + (Dom.div()..addTestId('content'))('foo'), + )); + + expect(queryByTestId(jacket.mountNode, 'content')!.innerHtml, + contains('foo')); }); }); }