File tree 1 file changed +12
-5
lines changed
packages/flutter/lib/src/widgets
1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -112,11 +112,13 @@ class _RegularWindowState extends State<RegularWindow> {
112
112
@override
113
113
void initState () {
114
114
super .initState ();
115
+ final Future <WindowCreationResult > createRegularFuture =
116
+ createRegular (size: widget._preferredSize);
115
117
setState (() {
116
- _future = createRegular (size : widget._preferredSize) ;
118
+ _future = createRegularFuture ;
117
119
});
118
120
119
- _future ! .then ((WindowCreationResult metadata) async {
121
+ createRegularFuture .then ((WindowCreationResult metadata) async {
120
122
_viewId = metadata.flView.viewId;
121
123
if (widget.controller != null ) {
122
124
widget.controller! .view = metadata.flView;
@@ -156,8 +158,7 @@ class _RegularWindowState extends State<RegularWindow> {
156
158
}
157
159
158
160
@override
159
- void dispose () {
160
- super .dispose ();
161
+ Future <void > dispose () async {
161
162
if (_listener != null ) {
162
163
assert (_app != null );
163
164
_app! ._unregisterListener (_listener! );
@@ -166,8 +167,14 @@ class _RegularWindowState extends State<RegularWindow> {
166
167
// In the event that we're being disposed before we've been destroyed
167
168
// we need to destroy ther window on our way out.
168
169
if (! _hasBeenDestroyed && _viewId != null ) {
169
- destroyWindow (_viewId! );
170
+ // In the event of an argument error, we do nothing. We assume that
171
+ // the window has been successfully destroyed somehow else.
172
+ try {
173
+ await destroyWindow (_viewId! );
174
+ } on ArgumentError {}
170
175
}
176
+
177
+ super .dispose ();
171
178
}
172
179
173
180
@override
You can’t perform that action at this time.
0 commit comments