A flutter plugin for loading content asynchronously.

To use this plugin, add async_loader as a dependency in your pubspec.yaml file.

Create instance #

getMessage() async { return new Future.delayed(TIMEOUT, () => 'Welcome to your async screen'); } ... var _asyncLoader = new AsyncLoader( key: _asyncLoaderState, initState: () async => await getMessage(), renderLoad: () => new CircularProgressIndicator(), renderError: ([error]) => new Text('Sorry, there was an error loading your joke'), renderSuccess: ({data}) => new Text(data), );

Trigger reload #

class ExampleApp extends StatelessWidget { final GlobalKey<AsyncLoaderState> _asyncLoaderState = new GlobalKey<AsyncLoaderState>(); reload() { _asyncLoaderState.currentState.reloadState() } }

Full Example #