티스토리 뷰
[Flutter] SliverList 중 고정되는 항목 만들기

SliverPersistentHeader widget의 pnned 요소를 true로 해서 CustomScrollView widget의 slivers에 추가해준다.
SliverPersistentHeader는 스크롤 될 때 ScrollView 상단에서 고정되는걸 볼 수 있다.
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
Expanded(
child: CustomScrollView(
slivers: [
SliverPersistentHeader(
pinned: true,
delegate: SliverPinnedHeaderDelegate(
minHeight: 50,
maxHeight: 50,
child: Container(
color: Colors.white,
child: ListTileTheme(
child: ListTile(
title: Text('SubTitle_01'),
),
),
)
)
),
SliverList(
delegate: SliverChildBuilderDelegate(
childCount: widget.products.length,
(context, index) {
return ShoppingListItem(product: widget.products[index], inCart: _shoppingCart.contains(widget.products[index]), onCardChanged: _handleCartChanged);
}
),
),
SliverPersistentHeader(
pinned: true,
delegate: SliverPinnedHeaderDelegate(
minHeight: 50,
maxHeight: 50,
child: Container(
color: Colors.white,
child: ListTileTheme(
child: ListTile(
title: Text('SubTitle_02'),
),
),
)
)
),
SliverList(
delegate: SliverChildBuilderDelegate(
childCount: widget.products.length,
(context, index) {
return ShoppingListItem(product: widget.products[index], inCart: _shoppingCart.contains(widget.products[index]), onCardChanged: _handleCartChanged);
}
),
),
],
),
)
],
),
);
}
}
'Programming Framework > Flutter' 카테고리의 다른 글
| [Flutter] GetIt 패키지를 이용한 Service Locator 전역 상태 관리 (0) | 2024.05.25 |
|---|---|
| [Flutter] JsonSerialize(encode / decode) (0) | 2024.05.24 |
| [Flutter] ListView 오류 Vertical viewport was given unbounded height. (0) | 2024.05.17 |
| [Flutter] 우측 상단 'DEBUG' 배너 제거하기 (0) | 2024.05.16 |
| [Flutter] IntelliJ Device Manager 버튼 안 보일 때 활성화 방법 (0) | 2024.05.16 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- Eclipse
- DART
- MariaDB
- egoverment
- Flutter
- express
- asp.net core
- Windows
- 스프링
- eGovFrame
- egov
- .NET Core
- Entity Framework Core
- jQuery
- 이클립스
- dotnet core
- 하이원
- Java
- php
- 전자정부
- CentOS
- ubuntu
- MySQL
- Linux
- high1
- Spring
- Fedora
- 자바
- c#
- JSP
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
글 보관함