refreshable_widget 0.1.3+5 copy "refreshable_widget: ^0.1.3+5" to clipboard
refreshable_widget: ^0.1.3+5 copied to clipboard

Refreshable widget

Refreshable Widget #

style: very good analysis Powered by Mason License: MIT

Refreshable widget

Goal 🏹 #

Refreshable Widget built for these two Stackoverflow issues, and also for my personal usage.

Possible use case: You have a widget you use with FutureBuilder, shows an async data. But you need to update it periodically because there's no socket or stream that you can listen to. For example a progress for user in a game, which requires you to fetch whole game periodically, like every 20 seconds.

Installation 💻 #

❗ In order to start using Refreshable Widget you must have the Flutter SDK installed on your machine.

Add refreshable_builder to your pubspec.yaml:


Install it:

flutter packages get

Usage 🛞 #

/// pass the type, [num] in below, which is a return type for [refreshCall] and [value] in [builder]
  // optional initial value if you have
  initialValue: challenge.userParticipation!.donePercent,
  // your API call or logic to refresh
  refreshCall: () async {
    final challenge = await service.getChallenge(id: widget.challengeId); 
    return challenge.userParticipation!.donePercent;
  refreshRate: const Duration(seconds: 20),
  // builder, which is called every time you have new value from refreshCall
  builder: (context, value) {
    return ProgressWidget(
      percent: value,
  // optional error and loading widgets