Notice
Recent Posts
Recent Comments
Link
250x250
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 테스트
- Dialog
- 앱바
- intent
- scroll
- 안드로이드
- viewmodel
- TEST
- appbar
- Button
- android
- data
- Flutter
- Kotlin
- livedata
- tabbar
- LifeCycle
- Compose
- 계측
- textfield
- DART
- Coroutines
- drift
- 앱
- activity
- binding
- Navigation
- CustomScrollView
- ScrollView
- textview
Archives
- Today
- Total
Study Record
[Flutter] RefreshIndicator (새로 고침) 본문
728x90
✍ RefreshIndicator
스크롤할 수 있는 화면의 맨 상단을 위로 당기면 로딩 아이콘이 나오면서 서버에 데이터를 다시 가져오거나 하는 등 새롭게 다시 데이터를 뿌려줄 때 이용하면 좋은 위젯이다.
사용 방법은 간단하다. RefreshIndicator 에 child 와 onRefresh 에 새로 고침 아이콘을 하면서 실행할 작업을 정의한다. child 에 스크롤이 가능한 위젯을 넣으면 된다.
import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(home: RefreshIndicatorScreen()));
class RefreshIndicatorScreen extends StatelessWidget {
const RefreshIndicatorScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("RefreshIndicatorScreen")),
body: RefreshIndicator(
onRefresh: () async{
await Future<void>.delayed(Duration(seconds: 2));
},
child: ListView(
children: List.generate(
100,
(index) => Container(
color: Colors.greenAccent,
height: 100,
margin: EdgeInsets.all(16.0),
child: Center(child: Text("$index")),
),
),
),
),
);
}
}
728x90
'Flutter > widget_scrollView' 카테고리의 다른 글
[Flutter] 실시간 스크롤 offset 알아보기 (0) | 2023.03.16 |
---|---|
[Flutter] 스와이프로 위젯 삭제하기 (Dismissible) (0) | 2023.03.10 |
[Flutter] 스크롤바 (Scrollbar) (0) | 2023.03.09 |
[Flutter] SliverPersistentHeader (스크롤 중 위젯 고정) (0) | 2023.03.09 |
[Flutter] CustomScrollView 에서 앱바 컨트롤하기(숨김, 고정 등) - SliverAppBar (0) | 2023.03.08 |