반응형
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.purple,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _count = 0;
Future<Null> _handleRefresh() async{
await Future.delayed(Duration(seconds: 3));
setState(() {
_count = 5;
});
return null;
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("HomePage"),
),
body: RefreshIndicator(
child: new ListView.builder(
itemCount: _count +4,
itemBuilder: (context, index){
return Text("item $index");
},
),
onRefresh: _handleRefresh,
),
);
}
}
'flutter.widget' 카테고리의 다른 글
Drawer (0) | 2021.04.14 |
---|---|
AlertDialog (0) | 2021.04.13 |
FractionallySizedBox (0) | 2021.04.06 |
image (0) | 2020.11.30 |
WebView (0) | 2020.11.17 |