Skip to content

Instantly share code, notes, and snippets.

@IkhwanSI13
Created March 18, 2021 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IkhwanSI13/c38089a2ef6853b837e10a5988ec6475 to your computer and use it in GitHub Desktop.
Save IkhwanSI13/c38089a2ef6853b837e10a5988ec6475 to your computer and use it in GitHub Desktop.
Liquid-Pull-To-Refresh
import 'package:flutter/material.dart';
import 'package:liquid_pull_to_refresh/liquid_pull_to_refresh.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
final GlobalKey<LiquidPullToRefreshState> _refreshIndicatorKey =
GlobalKey<LiquidPullToRefreshState>();
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
body: LiquidPullToRefresh(
key: _refreshIndicatorKey,
onRefresh: () async {
await onRefresh();
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Container(
height: 112,
color: Colors.amberAccent,
padding: EdgeInsets.fromLTRB(24, 12, 24, 12),
child: Align(
alignment: Alignment.center,
child: Text("Container Text"),
),
),
Expanded(
child: ListView.builder(
physics: AlwaysScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: 25,
padding: EdgeInsets.only(top: 8, bottom: 32),
itemBuilder: (BuildContext context, int index) {
return InkWell(
onTap: () {},
child: Container(
padding: EdgeInsets.fromLTRB(24, 12, 24, 12),
child: Text("ListView.Builder Text"),
),
);
}))
],
),
),
),
);
}
onRefresh() async {
await Future.delayed(const Duration(seconds: 2), () => "2");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment