File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
packages/flutter/lib/src/widgets Expand file tree Collapse file tree 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> {
112112 @override
113113 void initState () {
114114 super .initState ();
115+ final Future <WindowCreationResult > createRegularFuture =
116+ createRegular (size: widget._preferredSize);
115117 setState (() {
116- _future = createRegular (size : widget._preferredSize) ;
118+ _future = createRegularFuture ;
117119 });
118120
119- _future ! .then ((WindowCreationResult metadata) async {
121+ createRegularFuture .then ((WindowCreationResult metadata) async {
120122 _viewId = metadata.flView.viewId;
121123 if (widget.controller != null ) {
122124 widget.controller! .view = metadata.flView;
@@ -156,8 +158,7 @@ class _RegularWindowState extends State<RegularWindow> {
156158 }
157159
158160 @override
159- void dispose () {
160- super .dispose ();
161+ Future <void > dispose () async {
161162 if (_listener != null ) {
162163 assert (_app != null );
163164 _app! ._unregisterListener (_listener! );
@@ -166,8 +167,14 @@ class _RegularWindowState extends State<RegularWindow> {
166167 // In the event that we're being disposed before we've been destroyed
167168 // we need to destroy ther window on our way out.
168169 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 {}
170175 }
176+
177+ super .dispose ();
171178 }
172179
173180 @override
You can’t perform that action at this time.
0 commit comments