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 | 29 | 30 | 31 |
Tags
- 앱
- drift
- livedata
- scroll
- TEST
- Flutter
- 테스트
- appbar
- android
- textfield
- 계측
- tabbar
- Button
- 안드로이드
- Kotlin
- Dialog
- ScrollView
- DART
- 앱바
- CustomScrollView
- Coroutines
- activity
- intent
- Compose
- LifeCycle
- binding
- Navigation
- textview
- data
- viewmodel
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")),
),
),
),
),
);
}
}

RefreshIndicator class - material library - Dart API
A widget that supports the Material "swipe to refresh" idiom. When the child's Scrollable descendant overscrolls, an animated circular progress indicator is faded into view. When the scroll ends, if the indicator has been dragged far enough for it to becom
api.flutter.dev
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 |