I am setting the linting rules for my flutter project and cannot remove the use_build_context_synchronously
warning. I am using GetX and flash in my project. The warning happens in a controller with the following code, more specifically, in the place where showFlash
is used.
Future<List<Item>> getItems(BuildContext context) async {
List<Item> items = await httpService.listItems();
if (items.isEmpty) {
showFlash(
context: context,
...
);
}
return items;
}
In the documentation, it mentions that we can use mounted
in StatefulWidget (https://dart-lang.github.io/linter/lints/use_build_context_synchronously.html), but I am currently in GetController of GetX. Can anyone please help?
I find a similar question in StackOverflow Flutter - How to use mounted in GetX, but applying the solutions does not resolve the warning.
Cheers