xxxxxxxxxx
import 'package:flutter/material.dart';
class MyScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('My Screen'),
),
body: RefreshIndicator(
onRefresh: () async {
// Handle refresh logic here
},
child: ListView(
children: [
// Your widget content here
],
),
),
);
}
}
xxxxxxxxxx
final GlobalKey<RefreshIndicatorState> _refreshIndicatorKey =
GlobalKey<RefreshIndicatorState>();
body: RefreshIndicator(
key: _refreshIndicatorKey,
color: Colors.white,
backgroundColor: Colors.blue,
strokeWidth: 4.0,
onRefresh: () async {
// Replace this delay with the code to be executed during refresh
// and return a Future when code finishs execution.
return Future<void>.delayed(const Duration(seconds: 3));
},
// Pull from top to show refresh indicator.
child: ListView.builder(
itemCount: 25,
itemBuilder: (BuildContext context, int index) {
return ListTile(
title: Text('Item $index'),
);
},
),
),
xxxxxxxxxx
RefreshIndicator(
displacement: 250,
backgroundColor: Colors.yellow,
color: Colors.red,
strokeWidth: 3,
triggerMode: RefreshIndicatorTriggerMode.onEdge,
onRefresh: () async {
await Future.delayed(Duration(milliseconds: 1500));
setState(() {
itemCount = itemCount + 1;
});
},
child: Scaffold(
backgroundColor: Color(0xff246df8),
appBar: AppBar(
title: Text('Refresh Indicator'),
backgroundColor: Color(0xff246df8),
),
body: _buildCardDesign(),
),
);