Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[various] Enable use_build_context_synchronously #6585

Merged
merged 4 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ linter:
- unnecessary_to_list_in_spreads
- unrelated_type_equality_checks
- unsafe_html
# - use_build_context_synchronously # LOCAL CHANGE - Needs to be enabled and violations fixed.
- use_build_context_synchronously
# - use_colored_box # not yet tested
# - use_decorated_box # not yet tested
# - use_enums # not yet tested
Expand Down
1 change: 1 addition & 0 deletions packages/file_selector/file_selector/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT

* Updates example code for `use_build_context_synchronously` lint.
* Updates minimum Flutter version to 3.0.

## 0.9.2+2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ class GetDirectoryPage extends StatelessWidget {
// Operation was canceled by the user.
return;
}
await showDialog<void>(
context: context,
builder: (BuildContext context) => TextDisplay(directoryPath),
);
if (context.mounted) {
await showDialog<void>(
context: context,
builder: (BuildContext context) => TextDisplay(directoryPath),
);
}
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ class OpenImagePage extends StatelessWidget {
final String fileName = file.name;
final String filePath = file.path;

await showDialog<void>(
context: context,
builder: (BuildContext context) => ImageDisplay(fileName, filePath),
);
if (context.mounted) {
await showDialog<void>(
context: context,
builder: (BuildContext context) => ImageDisplay(fileName, filePath),
);
}
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ class OpenMultipleImagesPage extends StatelessWidget {
// Operation was canceled by the user.
return;
}
await showDialog<void>(
context: context,
builder: (BuildContext context) => MultipleImagesDisplay(files),
);
if (context.mounted) {
await showDialog<void>(
context: context,
builder: (BuildContext context) => MultipleImagesDisplay(files),
);
}
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ class OpenTextPage extends StatelessWidget {
final String fileName = file.name;
final String fileContent = await file.readAsString();

await showDialog<void>(
context: context,
builder: (BuildContext context) => TextDisplay(fileName, fileContent),
);
if (context.mounted) {
await showDialog<void>(
context: context,
builder: (BuildContext context) => TextDisplay(fileName, fileContent),
);
}
}

@override
Expand Down
1 change: 1 addition & 0 deletions packages/file_selector/file_selector_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT

* Updates example code for `use_build_context_synchronously` lint.
* Updates minimum Flutter version to 3.0.

## 0.5.0+2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ class OpenImagePage extends StatelessWidget {
final String fileName = file.name;
final String filePath = file.path;

await showDialog<void>(
context: context,
builder: (BuildContext context) => ImageDisplay(fileName, filePath),
);
if (context.mounted) {
await showDialog<void>(
context: context,
builder: (BuildContext context) => ImageDisplay(fileName, filePath),
);
}
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ class OpenMultipleImagesPage extends StatelessWidget {
// Operation was canceled by the user.
return;
}
await showDialog<void>(
context: context,
builder: (BuildContext context) => MultipleImagesDisplay(files),
);
if (context.mounted) {
await showDialog<void>(
context: context,
builder: (BuildContext context) => MultipleImagesDisplay(files),
);
}
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ class OpenTextPage extends StatelessWidget {
final String fileName = file.name;
final String fileContent = await file.readAsString();

await showDialog<void>(
context: context,
builder: (BuildContext context) => TextDisplay(fileName, fileContent),
);
if (context.mounted) {
await showDialog<void>(
context: context,
builder: (BuildContext context) => TextDisplay(fileName, fileContent),
);
}
}

@override
Expand Down
1 change: 1 addition & 0 deletions packages/file_selector/file_selector_linux/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT

* Updates example code for `use_build_context_synchronously` lint.
* Updates minimum Flutter version to 3.0.

## 0.9.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ class GetDirectoryPage extends StatelessWidget {
// Operation was canceled by the user.
return;
}
await showDialog<void>(
context: context,
builder: (BuildContext context) => TextDisplay(directoryPath),
);
if (context.mounted) {
await showDialog<void>(
context: context,
builder: (BuildContext context) => TextDisplay(directoryPath),
);
}
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ class GetMultipleDirectoriesPage extends StatelessWidget {
// Operation was canceled by the user.
return;
}
await showDialog<void>(
context: context,
builder: (BuildContext context) => TextDisplay(directoryPaths.join('\n')),
);
if (context.mounted) {
await showDialog<void>(
context: context,
builder: (BuildContext context) =>
TextDisplay(directoryPaths.join('\n')),
);
}
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ class OpenImagePage extends StatelessWidget {
final String fileName = file.name;
final String filePath = file.path;

await showDialog<void>(
context: context,
builder: (BuildContext context) => ImageDisplay(fileName, filePath),
);
if (context.mounted) {
await showDialog<void>(
context: context,
builder: (BuildContext context) => ImageDisplay(fileName, filePath),
);
}
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ class OpenMultipleImagesPage extends StatelessWidget {
// Operation was canceled by the user.
return;
}
await showDialog<void>(
context: context,
builder: (BuildContext context) => MultipleImagesDisplay(files),
);
if (context.mounted) {
await showDialog<void>(
context: context,
builder: (BuildContext context) => MultipleImagesDisplay(files),
);
}
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ class OpenTextPage extends StatelessWidget {
final String fileName = file.name;
final String fileContent = await file.readAsString();

await showDialog<void>(
context: context,
builder: (BuildContext context) => TextDisplay(fileName, fileContent),
);
if (context.mounted) {
await showDialog<void>(
context: context,
builder: (BuildContext context) => TextDisplay(fileName, fileContent),
);
}
}

@override
Expand Down
1 change: 1 addition & 0 deletions packages/file_selector/file_selector_macos/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT

* Updates example code for `use_build_context_synchronously` lint.
* Updates minimum Flutter version to 3.0.

## 0.9.0+4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ class GetDirectoryPage extends StatelessWidget {
// Operation was canceled by the user.
return;
}
await showDialog<void>(
context: context,
builder: (BuildContext context) => TextDisplay(directoryPath),
);
if (context.mounted) {
await showDialog<void>(
context: context,
builder: (BuildContext context) => TextDisplay(directoryPath),
);
}
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ class OpenImagePage extends StatelessWidget {
final String fileName = file.name;
final String filePath = file.path;

await showDialog<void>(
context: context,
builder: (BuildContext context) => ImageDisplay(fileName, filePath),
);
if (context.mounted) {
await showDialog<void>(
context: context,
builder: (BuildContext context) => ImageDisplay(fileName, filePath),
);
}
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ class OpenMultipleImagesPage extends StatelessWidget {
// Operation was canceled by the user.
return;
}
await showDialog<void>(
context: context,
builder: (BuildContext context) => MultipleImagesDisplay(files),
);
if (context.mounted) {
await showDialog<void>(
context: context,
builder: (BuildContext context) => MultipleImagesDisplay(files),
);
}
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ class OpenTextPage extends StatelessWidget {
final String fileName = file.name;
final String fileContent = await file.readAsString();

await showDialog<void>(
context: context,
builder: (BuildContext context) => TextDisplay(fileName, fileContent),
);
if (context.mounted) {
await showDialog<void>(
context: context,
builder: (BuildContext context) => TextDisplay(fileName, fileContent),
);
}
}

@override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT

* Updates example code for `use_build_context_synchronously` lint.
* Updates minimum Flutter version to 3.0.

## 0.9.1+4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ class GetDirectoryPage extends StatelessWidget {
// Operation was canceled by the user.
return;
}
await showDialog<void>(
context: context,
builder: (BuildContext context) => TextDisplay(directoryPath),
);
if (context.mounted) {
await showDialog<void>(
context: context,
builder: (BuildContext context) => TextDisplay(directoryPath),
);
}
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ class OpenImagePage extends StatelessWidget {
final String fileName = file.name;
final String filePath = file.path;

await showDialog<void>(
context: context,
builder: (BuildContext context) => ImageDisplay(fileName, filePath),
);
if (context.mounted) {
await showDialog<void>(
context: context,
builder: (BuildContext context) => ImageDisplay(fileName, filePath),
);
}
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ class OpenMultipleImagesPage extends StatelessWidget {
// Operation was canceled by the user.
return;
}
await showDialog<void>(
context: context,
builder: (BuildContext context) => MultipleImagesDisplay(files),
);
if (context.mounted) {
await showDialog<void>(
context: context,
builder: (BuildContext context) => MultipleImagesDisplay(files),
);
}
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ class OpenTextPage extends StatelessWidget {
final String fileName = file.name;
final String fileContent = await file.readAsString();

await showDialog<void>(
context: context,
builder: (BuildContext context) => TextDisplay(fileName, fileContent),
);
if (context.mounted) {
await showDialog<void>(
context: context,
builder: (BuildContext context) => TextDisplay(fileName, fileContent),
);
}
}

@override
Expand Down
3 changes: 2 additions & 1 deletion packages/image_picker/image_picker_windows/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 0.1.0+4

* Updates example code for `use_build_context_synchronously` lint.
* Updates minimum Flutter version to 3.0.

## 0.1.0+3
Expand Down
Loading