스크롤 형태의 위젯에서 너비 값이 지정되지 않은 스크롤 뷰는 `notification.metrics.axis == widget.axis: is not true` 오류가 발생할 수 있습니다. 따라서, 스크롤 형태의 위젯에서 너비를 알 수 있도록 `physics`를 `BouncingScrollPhysics()` 옵션으로 변경하여 너비를 알 수 있도록 해야 합니다.
예제
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Builder(builder: (context) {
return ListView(
shrinkWrap: true,
children: [
Container(
height: 50,
child: ListView(
scrollDirection: Axis.horizontal,
physics: const BouncingScrollPhysics(),
children: List.generate(
20,
(index) {
return Container(
padding: EdgeInsets.all(8),
height: 50,
width: 50,
child: Text(index.toString()),
),
);
}
),
),
],
);
}),
),
);
}
}
참고 링크
Failed assertion: line 243 pos 14: 'notification.metrics.axis == widget.axis': is not true. · Issue #107772 · flutter/flutter
Performing hot restart... Syncing files to device sdk gphone64 x86 64... ======== Exception caught by animation library ===================================================== The following assertion...
github.com
'notification.metrics.axis == widget.axis': is not true.
Arkadaşlar listview.builder kullanarak listelediğim bir widget var fakat scrollDirection’ı horizontal yaptığım zaman listenin sonuna gidildiğinde bu hatayı a...
www.flutterforum.org
'Dart > Flutter' 카테고리의 다른 글
[Flutter] 플러터 `Rive` 적용하기 (0) | 2022.12.23 |
---|---|
[Flutter] `TextField`, `TextFormField` 특정 포커스(Focus) 위치하기 (0) | 2022.12.23 |
[Flutter] 탭바(Tabbar) 스크롤 위치 기억하기 `Render Visible` (0) | 2022.12.23 |
[Flutter] Location `Attempt to invoke interface method 'void'` 오류 해결하기 (0) | 2022.12.21 |
[Flutter] `Location` 위치 정보 가져오기 (0) | 2022.12.19 |