Skip to content

Commit 8fc1292

Browse files
committed
compose: Add some missing context.mounted checks
An upcoming Dart SDK update causes the analyzer to spot these.
1 parent fd4f897 commit 8fc1292

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/widgets/compose_box.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ Future<Iterable<_File>> _getFilePickerFiles(BuildContext context, FileType type)
493493
result = await FilePicker.platform
494494
.pickFiles(allowMultiple: true, withReadStream: true, type: type);
495495
} catch (e) {
496+
if (!context.mounted) return [];
496497
if (e is PlatformException && e.code == 'read_external_storage_denied') {
497498
// Observed on Android. If Android's error message tells us whether the
498499
// user has checked "Don't ask again", it seems the library doesn't pass
@@ -572,6 +573,7 @@ class _AttachFromCameraButton extends _AttachUploadsButton {
572573
// videos, but we don't want too many buttons.
573574
result = await picker.pickImage(source: ImageSource.camera, requestFullMetadata: false);
574575
} catch (e) {
576+
if (!context.mounted) return [];
575577
if (e is PlatformException && e.code == 'camera_access_denied') {
576578
// iOS has a quirk where it will only request the native
577579
// permission-request alert once, the first time the app wants to

0 commit comments

Comments
 (0)