Skip to content

False positives for FutureBuilders when passing future functions to the future parameter. #1

@RemcoSchrijver

Description

@RemcoSchrijver

Really like the package, only problem I'm having right now is that FutureBuilders spawns false positives when assigning a function to be used as a future.

An example 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}');
     }
  },
)

And getValue() is now rightfully marked as non-awaited future, however because this is a future builder this function is not used as such. Is this a user error on my part or is this just a false positive part of the framework?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions