File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -299,5 +299,35 @@ void main() {
299
299
// Verify that the selectedIdEditStateProvider is null
300
300
expect (container.read (selectedIdEditStateProvider), null );
301
301
});
302
+ testWidgets ("It should be properly disposed" , (tester) async {
303
+ await tester.pumpWidget (
304
+ const ProviderScope (
305
+ child: MaterialApp (
306
+ home: CollectionPane (),
307
+ ),
308
+ ),
309
+ );
310
+
311
+ // Grab the Dashboard widget and its ProviderContainer
312
+ final collectionPane = tester.element (find.byType (CollectionPane ));
313
+ final container = ProviderScope .containerOf (collectionPane);
314
+
315
+ // Pumping a different widget to remove the CollectionPane from the widget tree
316
+ await tester.pumpWidget (
317
+ const MaterialApp (
318
+ home: Scaffold (body: Text ('Foo' )),
319
+ ),
320
+ );
321
+
322
+ // Verify that the ProviderContainer has been disposed
323
+ // by trying to read from disposed container
324
+ bool isDisposed = false ;
325
+ try {
326
+ container.read (selectedIdEditStateProvider);
327
+ } catch (e) {
328
+ isDisposed = true ;
329
+ }
330
+ expect (isDisposed, true );
331
+ });
302
332
});
303
333
}
You can’t perform that action at this time.
0 commit comments