adv_async_widget 0.2.0 copy "adv_async_widget: ^0.2.0" to clipboard
adv_async_widget: ^0.2.0 copied to clipboard

Are you tired of always writing the same future and stream builders? Use AdvAsyncWidget to write only the code that you need for!

adv_async_widget #

GitHub Pub Version likes Pub Points Pub Popularity

Utility widgets for standard future and stream uses.

New advanced async builders #

This package contains 2 utility classes:

AdvFutureBuilder #

This class replace the standard FutureBuilder allowing you to have multiple build methods based on the connectionState.

Usage example:

  • case with standard FutureBuilder
FutureBuilder<String>(
    future: exampleFuture,
    //old standard builder with one method for everything
    builder: (context, snapshot) {
      if(snapshot.connectionState == ConnectionState.waiting) {
        return CircularProgressIndicator();
      }
      if(snapshot.hasError) {
        return Text("Error: ${snapshot.error}");
      }
      return Text(snapshot.data ?? "No data");
    }
)
  • case with AdvFutureBuilder
AdvFutureBuilder<String>(
    future: exampleFuture,
    //three different methods, one for each case
    onWait: (context) => CircularProgressIndicator(),
    onError: (context, error) => Text("Error: $error"),
    onData: (context, data) => Text(data ?? "No data"),
)

AdvStreamBuilder #

This class replace the standard StreamBuilder allowing you to have multiple build methods based on the connectionState. (yeah, they're the same, but this one is for stream instead of future)

Usage example:

  • case with standard StreamBuilder
StreamBuilder<String>(
    stream: exampleStream,
    //old standard builder with one method for everything
    builder: (context, snapshot) {
      if(snapshot.connectionState == ConnectionState.waiting) {
        return CircularProgressIndicator();
      }
      if(snapshot.hasError) {
        return Text("Error: ${snapshot.error}");
      }
      return Text(snapshot.data ?? "No data");
    }
)
  • case with AdvStreamBuilder
AdvStreamBuilder<String>(
    stream: exampleStream,
    //three different methods, one for each case
    onWait: (context) => CircularProgressIndicator(),
    onError: (context, error) => Text("Error: $error"),
    onData: (context, data) => Text(data ?? "No data"),
)

Full example #

You can find a full flutter example on pub example tab or inside GitHub example

2
likes
130
pub points
15%
popularity

Publisher

unverified uploader

Are you tired of always writing the same future and stream builders? Use AdvAsyncWidget to write only the code that you need for!

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on adv_async_widget