MHLab blog
📜
dart_flutter

(Flutter) AppBar 사용 시 중앙정렬 문제 (Android)

2023.06.27

thumbnail

개발을 하고 iOS 시뮬에서는 잘 되었는데…

iOS에서는 AppBar의 title이 중앙에 잘 배치되었다.

img02


근데 직접 APK를 만들어서 내 폰에 올려봤더니 왼쪽으로 정렬되어 있었다.
폰이 문제인가 싶어서 시뮬레이터를 돌렸더니 역시 똑같이 나왔다.


img03

왜 이런가 싶었는데 아주 쉽게 해결할 수 있는 문제였다.

class AppBar extends StatefulWidget implements PreferredSizeWidget {

  /// {@template flutter.material.appbar.centerTitle}
  /// Whether the title should be centered.
  ///
  /// If this property is null, then [AppBarTheme.centerTitle] of
  /// [ThemeData.appBarTheme] is used. If that is also null, then value is
  /// adapted to the current [TargetPlatform].
  /// {@endtemplate}
  final bool? centerTitle;

  ///....
}

그렇다.
저 속성을 true로 주면 깔끔하게 해결된다.


img01


플러터를 이제 막 하는 사람으로써..
이런 부분은 좀 신기했다.

둘다 똑같이 표현이 되어야 하는데 속성이 있고 없음으로 인해,
안드랑 아이폰 표현이 틀리다니..

앞으로 고생좀 할것 같은 예감이 든다..


작은 개인광고 양해 바랍니다 ^^;;
👇 주인장이 직접 만든 서비스 👇
/static/29a05fefb322c94d5eb3f7d05c7c224e/myc_icon.png
Typescript
React
Next.Js
Nest.Js
마와셀(웹) - 와인 가격 비교
와인 가격 비교 서비스
postweb
/static/29a05fefb322c94d5eb3f7d05c7c224e/myc_icon.png
Dart
Flutter
hive
provider
마와셀(엡) - 와인과 셀러 관리, 시음노트
보유한 와인의 관리, 시음노트 작성, 보유 와인 셀러의 관리 어플리케이션
/static/d35d260fd4813f4a6d284a7f4fbcdf49/bcow_icon.png
Typescript
React
Next.Js
Nest.Js
흑우집합소(웹) - 로또번호 추천 서비스
로또번호 추천 서비스
/static/d35d260fd4813f4a6d284a7f4fbcdf49/bcow_icon.png
Dart
Flutter
drift
provider
흑우집합소(앱) - 로또번호 추천 서비스
로또번호 추천 서비스

© Powered by danmin