First, how to implement the list drop-down refresh?

There is a RefreshIndicator in the Flutter, which is a drop-down refresh widget that enables the list to be drop-down refreshed

Second, the code

import 'package:flutter/material.dart'; void main() => runApp(MyRefreshListViewApp()); class MyRefreshListViewApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyRefreshListViewApp> { void initState(){ _scrollController.addListener((){ if(_scrollController.position.pixels==_scrollController.position.maxScrollExtent){ _loadData(); }}); super.initState(); } a List < String > cityNames = [' Beijing ', 'Shanghai', 'guangzhou', 'shenzhen, hangzhou, suzhou, chengdu, wuhan, luoyang,' xiamen ', 'Qingdao', 'Lhasa]; ScrollController _scrollController=ScrollController(); Future<Null> _handleRefresh()async{ await Future.delayed(Duration(seconds: 2)); setState(() { cityNames=cityNames.reversed.toList(); }); } _loadData() async{ await Future.delayed(Duration(milliseconds: 200)); setState(() { List<String>list=List<String>.from(cityNames); list.addAll(cityNames); cityNames=list; }); } @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar(title: Body: RefreshIndicator(onRefresh: _handleRefresh, Child: ListView(Controller: _scrollController, children:_buildList() ), ) )); } List<Widget> _buildList() { return cityNames.map((city)=>_item(city)).toList(); } Widget _item(String city){ return Container( height: 80, margin: EdgeInsets.only(bottom: 5), alignment: Alignment.center, decoration: BoxDecoration(color:Colors.green), child: Text( city, style: TextStyle(color:Colors.black54,fontSize: 20), ), ); }}Copy the code