Skip to content

Commit 0f94b5f

Browse files
committed
Fix SnackBar (and other controls) exit animation
1 parent 5392ae7 commit 0f94b5f

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

package/lib/src/controls/create_control.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ import 'window_drag_area.dart';
7373
Widget createControl(Control? parent, String id, bool parentDisabled,
7474
{Widget? nextChild}) {
7575
//debugPrint("createControl(): $id");
76-
return StoreConnector<AppState, ControlViewModel>(
76+
return StoreConnector<AppState, ControlViewModel?>(
7777
key: ValueKey<String>(id),
7878
distinct: true,
7979
converter: (store) {
@@ -88,6 +88,10 @@ Widget createControl(Control? parent, String id, bool parentDisabled,
8888
return state.controls[id] == null;
8989
},
9090
builder: (context, controlView) {
91+
if (controlView == null) {
92+
return const SizedBox.shrink();
93+
}
94+
9195
//debugPrint("createControl builder(): $id");
9296
switch (controlView.control.type) {
9397
case "page":

package/lib/src/controls/page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ class _PageControlState extends State<PageControl> {
534534
return StoreConnector<AppState, ControlViewModel>(
535535
distinct: true,
536536
converter: (store) {
537-
return ControlViewModel.fromStore(store, viewId);
537+
return ControlViewModel.fromStore(store, viewId)!;
538538
},
539539
ignoreChange: (state) {
540540
return state.controls[viewId] == null;

package/lib/src/models/control_view_model.dart

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@ class ControlViewModel extends Equatable {
1313
const ControlViewModel(
1414
{required this.control, required this.children, required this.dispatch});
1515

16-
static ControlViewModel fromStore(Store<AppState> store, String id) {
17-
return ControlViewModel(
18-
control: store.state.controls[id]!,
19-
children: store.state.controls[id]!.childIds
20-
.map((childId) => store.state.controls[childId])
21-
.whereNotNull()
22-
.toList(),
23-
dispatch: store.dispatch);
16+
static ControlViewModel? fromStore(Store<AppState> store, String id) {
17+
var control = store.state.controls[id];
18+
return control != null
19+
? ControlViewModel(
20+
control: control,
21+
children: control.childIds
22+
.map((childId) => store.state.controls[childId])
23+
.whereNotNull()
24+
.toList(),
25+
dispatch: store.dispatch)
26+
: null;
2427
}
2528

2629
@override

package/lib/src/models/controls_view_model.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:collection/collection.dart';
12
import 'package:equatable/equatable.dart';
23
import 'package:redux/redux.dart';
34

@@ -13,8 +14,10 @@ class ControlsViewModel extends Equatable {
1314
static ControlsViewModel fromStore(
1415
Store<AppState> store, Iterable<String> ids) {
1516
return ControlsViewModel(
16-
controlViews:
17-
ids.map((id) => ControlViewModel.fromStore(store, id)).toList(),
17+
controlViews: ids
18+
.map((id) => ControlViewModel.fromStore(store, id))
19+
.whereNotNull()
20+
.toList(),
1821
dispatch: store.dispatch);
1922
}
2023

0 commit comments

Comments
 (0)