Created
March 18, 2021 06:39
-
-
Save IkhwanSI13/c38089a2ef6853b837e10a5988ec6475 to your computer and use it in GitHub Desktop.
Liquid-Pull-To-Refresh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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