Today 요약
[✅] 프로그래머스 1문제
[✅] flutter 강의 3개
배운 점
1)flutter ThemeMode
materialApp(
themeMode:ThemeMode.system,
)
- ThemeMode.dark : 휴대폰이 라이트모드여도 강제 다크모드
- ThemeMode.light : 휴대폰이 다크모드여도 강제 라이트모드
- system : 앱이 실행되는 기기의 환경에 맞추는것
2) DarkTheme
MaterialApp(
themeMode:ThemeMode.system,
theme:ThemeData(),
darkTheme:ThemeData(
brightness:Brightness.dark,
scaffoldBackgroundColor:Colors.black,
...
)
)
- brightness : 전형적인 테마 밝기
- darkTheme으로 따로 색상 빼서 적용하거나
- color : isDarkMode(context) ? Colors.red : Colors.black 이렇게도 사용가능하다
import 'package:flutter/material.dart';
bool isDarkMode(BuildContext context) =>
MediaQuery.of(context).platformBrightness == Brightness.dark;
3) flutter font
(new) TextTheme TextTheme({
TextStyle? displayLarge,
TextStyle? displayMedium,
TextStyle? displaySmall,
TextStyle? headlineLarge,
TextStyle? headlineMedium,
TextStyle? headlineSmall,
TextStyle? titleLarge,
TextStyle? titleMedium,
TextStyle? titleSmall,
TextStyle? bodyLarge,
TextStyle? bodyMedium,
TextStyle? bodySmall,
TextStyle? labelLarge,
TextStyle? labelMedium,
TextStyle? labelSmall,
TextStyle? headline1,
TextStyle? headline2,
TextStyle? headline3,
TextStyle? headline4,
TextStyle? headline5,
TextStyle? headline6,
TextStyle? subtitle1,
TextStyle? subtitle2,
TextStyle? bodyText1,
TextStyle? bodyText2,
TextStyle? caption,
TextStyle? button,
TextStyle? overline,
})
google_fonts | Flutter Package
A Flutter package to use fonts from fonts.google.com. Supports HTTP fetching, caching, and asset bundling.
pub.dev
TextTheme class - material library - Dart API
Material design text theme. Definitions for the various typographical styles found in Material Design (e.g., labelLarge, bodySmall). Rather than creating a TextTheme directly, you can obtain an instance as Typography.black or Typography.white. To obtain th
api.flutter.dev
MaterialApp(
theme:ThemeData(
textTheme : TextTheme(
displayLarge:GoogleFonts.openSans(
fontSize:95,
fontWeight:FontWeight.w300,
letterSpacing:-1.5,
),...
)
)
)
- 사용시에는 아래와 같이 사용하면 된다
Text(
"테스트",
style:Theme.of(context).textTheme.headlineLarge,
)
- 기존 속성은 유지하되 새로운 속성을 추가하고 싶다면 아래와 같이 copyWith를 사용하면 된다
Text(
"테스트",
style:Theme.of(context).textTheme.headlineLarge!.copyWith(color:Colors.red),
)
졸린 주말..
'TIL' 카테고리의 다른 글
20230821 TIL (0) | 2023.08.21 |
---|---|
20230820 TIL (0) | 2023.08.20 |
20230816 TIL (0) | 2023.08.16 |
20230808 TIL (0) | 2023.08.08 |
20230807 TIL (1) | 2023.08.07 |