본문 바로가기
IT 정보/플러터 flutter

플러터 app bar, background color, button 색상이 적용 안될 때

by 쩜오개미 2024. 1. 17.

어느 순간

앱바 theme: ThemeData 의 primarySwatch

백그라운드 컬러 버튼 컬러 등이

갑자기 적용이 안되었다.

 

After upgrading to Flutter 3.16, the app bar, background color, button size, and spaces change - Stack Overflow

 

After upgrading to Flutter 3.16, the app bar, background color, button size, and spaces change

I upgraded my Flutter version to 3.16. When I run my app, I notice a lot of changes in the UI. The app bar doesn't have shadows anymore. When I scroll, the app bar is now tinted with a color and s...

stackoverflow.com

 

이글에 의하면 

Flutter 3.16 으로 업그레이드 해서 그렇다는데 ..

이 플러터 버전부터 Material3 가 적용되어서 그렇다고 한다.

 

Material3 에서 색상 적용하는 것은 도저히 어떻게 하는지 모르겠고

 

위 글대로 

return MaterialApp(
  debugShowCheckedModeBanner: false, //디버그 리본 없애기
  theme: ThemeData(
    useMaterial3: false,
    // 기타 코드
    ),
    home: {홈에 넣을 위젯 작성}
);

 

이런식으로 

useMaterial3: false, 비활성화 시키면 

이전의 Material 2가 적용된다고 한다.

 

비활성화 하니

이전에 적용한 앱바와 버튼의 색상이 다시 보였다.

 

두 버전의 차이

 

To see the differences between Material 2 and Material 3, go to this interactive demo: https://flutter.github.io/samples/web/material_3_demo/#/

To see all the breaking changes in the Flutter 3.16 update, go to this link: 

https://docs.flutter.dev/release/breaking-changes#released-in-flutter-316

 

위 stack overflow 에는 

Material3 를 비활성화 하는 방법 말고도 몇가지 방법이 더 있으므로 

참조하면 좋겠다.

728x90
반응형

댓글