본문 바로가기
Dart/Flutter

[Flutter] 플러터 `notification.metrics.axis == widget.axis: is not true` 해결하기

by 검은냥냥이 2022. 12. 15.

스크롤 형태의 위젯에서 너비 값이 지정되지 않은 스크롤 뷰는 `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

 

728x90
사업자 정보 표시
레플라 | 홍대기 | 경기도 부천시 부일로 519 화신오피스텔 1404호 | 사업자 등록번호 : 726-04-01977 | TEL : 070-8800-6071 | Mail : support@reafla.co.kr | 통신판매신고번호 : 호 | 사이버몰의 이용약관 바로가기