A Flutter component that supports tapping Reload when fetching data fails.

Usage

  @override
  Widget build(BuildContext context) {
    return ReloadWidget(
      (BuildContext builderContext) {
        return Center(
          child: Text(
            'Data: $_data',
            style: const TextStyle(
              fontSize: 28,
              fontWeight: FontWeight.w700,
              color: Colors.green
            )
          )
        );
      },
      onReload: () async {
        // To simulate API calls
        final Result result = await Api.call();
  
        if (result.success) {
          _data = result.data;
        }
      
        return result.success ? ReloadStatus.succeeded : ReloadStatus.timeout;
      }
    );
  }

Libraries

reload_widget