webview_refresher

Creator: coderz1093

Last updated:

0 purchases

webview_refresher Image
webview_refresher Images

Languages

Categories

Add to Cart

Description:

webview refresher

Webview Refresher #
bring pull to refresh feature to official webview plugin
Install #
flutter pub add webview_refresher
copied to clipboard
Usage #
final controller = WebViewController();
Completer<void>? _completer;

Future onRefresh() {
_completer = Completer<void>();
return _completer!.future;
}

finishRefresh() {
if (_completer?.isCompleted ?? false) {
_completer?.complete();
}
}

@override
void initState() {
super.initState();
controller.setNavigationDelegate(NavigationDelegate(
onPageFinished: (url) {
finishRefresh();
},
onWebResourceError: (error) {
finishRefresh();
},
));
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('demo'),
actions: [
IconButton(
onPressed: () {
controller.loadRequest(Uri.parse('https://www.zhihu.com/'));
},
icon: const Icon(Icons.play_arrow_rounded),
),
],
),
body: WebviewRefresher(
controller: controller,
onRefresh: onRefresh,
),
);
}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.