Closed
Description
Issue encountered while using austerity package, when passing a future function as parameter it wrongfully marks it as an discared_future issue, an example using flutter is provided below. For background on the issue already raised with austerity see this issue.
Looking at the priorities file this should be marked as a p2 issue, as mentioned in the other thread this is fixed by ignoring the rule for this line. I also did not find any other issues on this fact.
An example of code generating a false positive would be:
Future<String> getValue() async {
await Future.delayed(Duration(seconds: 3));
return 'Woolha';
}
FutureBuilder<String>(
future: getValue(),
builder: (
BuildContext context,
AsyncSnapshot<String> snapshot,
) {
print(snapshot.connectionState);
if (snapshot.connectionState == ConnectionState.waiting) {
return CircularProgressIndicator();
} else if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasError) {
return const Text('Error');
} else if (snapshot.hasData) {
return Text(snapshot.data);
} else {
return const Text('Empty data');
}
} else {
return Text('State: ${snapshot.connectionState}');
}
},
)
Metadata
Metadata
Assignees
Labels
A lower priority bug or feature requestFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.Issues with the analyzer's support for the linter packageIssues related to lint rules that report a problem when it isn't a problem.Incorrect behavior (everything from a crash to more subtle misbehavior)