final ScrollController _scrollController = ScrollController();
void _scrollToTop() {
_scrollController.animateTo(0,
duration: const Duration(milliseconds: 750), curve: Curves.ease);
}
// ScrollView의 controller 속성에 추가
SingleChildScrollView(
controller: _scrollController,
...
),
// Top 버튼 in Column
Padding(
padding: const EdgeInsets.all(margin16),
child: Align(
alignment: Alignment.centerRight,
child: SizedBox(
width: 50,
height: 50,
child: MaterialButton(
onPressed: () {
_scrollToTop();
},
color: Colors.grey,
splashColor: Colors.black,
child: const Text("TOP",
style: TextStyle(
color: Colors.white,
fontSize: 16,
)),
padding: const EdgeInsets.all(8),
shape: const CircleBorder(),
),
),
),
),
'프로그래밍 > Flutter' 카테고리의 다른 글
[Flutter] StatusBar Color (0) | 2022.04.21 |
---|---|
[Flutter] ExpandablePageView initial page (0) | 2022.04.18 |
[Flutter] BackPress to exit (0) | 2022.04.16 |
[Flutter] WebView on Web (0) | 2022.04.16 |
[Flutter] Android 어플 Flutter로 실행시키기 (0) | 2022.04.14 |
댓글