반응형
발생 에러
- A RenderPadding expected a child of type RenderBox but received a child of type RenderSliverGrid.
- SliverGrid는 Sliver 계열의 위젯이므로 SliverToBoxAdapter 안에 직접적으로 넣을 수 없기에 발생하는 에러인듯하다.
목적
- CustomScrollView()위젯의 slivers 안에 SliverGrid() 위젯을 넣기 전
위젯을 감싸는 하나의 요소에 패딩을 넣어주기
코드
- SliverPadding을 사용하여 패딩 속성을 주기
SliverPadding(
padding: EdgeInsets.all(10),
sliver: SliverGrid(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
),
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return BoxLayOut(comment: '문구', sendIcon: Icons.accessibility);
},
childCount: 8,
),
),
),
'Flutter' 카테고리의 다른 글
[Flutter, 토이 프로젝트] 위젯 안의 요소의 TextStyle 한번에 지정 - DefaultTextStyle (0) | 2023.08.30 |
---|---|
[Flutter, 토이 프로젝트] 위젯 사이의 간격 간편하게 주고 싶을 때 - SizedBox (0) | 2023.08.22 |
[Flutter, 토이 프로젝트] ElevatedButton Radius 변경 - styleFrom (0) | 2023.08.19 |
[Flutter, 토이 프로젝트] 가로,세로 요소 스크롤 & 스와이프 - ListView (0) | 2023.08.19 |
[Flutter, 토이 프로젝트] 아이콘 좌우 반전 - Matrix4 (0) | 2023.08.19 |