본문 바로가기
Front-End/Flutter

[Flutter] 05. 색상

by 삼준 2024. 3. 16.
반응형

색상과 관련된 내용을 모아보았음.

1. Colors 클래스

Colors.색상명

으로 간편하게 색을 지정할 수 있음.

공식 문서 : https://api.flutter.dev/flutter/material/Colors-class.html

 

Colors class - material library - Dart API

Color and ColorSwatch constants which represent Material design's color palette. Instead of using an absolute color from these palettes, consider using Theme.of to obtain the local ThemeData.colorScheme, which defines the colors that most of the Material c

api.flutter.dev

2. Color 클래스

Color(int형 헥사코드)

를 사용해서 사용자가 원하는 색상으로 지정할 수도 있음.

헥사코드는 0xOORRGGBB 로 구성됨. 앞의 두 자리는 불투명도임.

Color.fromRGBO(), Color.fromARGB() 도 사용가능함.

공식 문서 : https://api.flutter.dev/flutter/dart-ui/Color-class.html

 

Color class - dart:ui library - Dart API

Color class An immutable 32 bit color value in ARGB format. Consider the light teal of the Flutter logo. It is fully opaque, with a red channel value of 0x42 (66), a green channel value of 0xA5 (165), and a blue channel value of 0xF5 (245). In the common "

api.flutter.dev

3. withOpacity, withAlpha

Color 객체 뒤에 붙여 투명도를 조절하는 메소드.

매개변수로 들어가는 숫자가 0에 가까울수록 투명해지고 1로 가까워질수록 불투명함.

공식 문서 : https://api.flutter.dev/flutter/dart-ui/Color/withOpacity.html

 

withOpacity method - Color class - dart:ui library - Dart API

withOpacity method Color withOpacity(double opacity ) Returns a new color that matches this color with the alpha channel replaced with the given opacity (which ranges from 0.0 to 1.0). Out of range values will have unexpected effects. Implementation Color

api.flutter.dev

참고로, Opacity는 투명도를 설정했을 때 설정한 요소의 모든 자식 요소까지 전부 같은 투명도로 설정하고, Alpha은 투명도를 설정한 요소에만 투명도를 설정하는 차이가 있음.

4. ColorPicker

앱 사용자가 팔레트에서 색상을 고르는 기능을 만들때 필요한 패키지.

 

공식 문서 : https://pub.dev/packages/flutter_colorpicker

 

flutter_colorpicker | Flutter package

HSV(HSB)/HSL/RGB/Material color picker inspired by all the good design for your amazing flutter apps.

pub.dev

 

반응형

'Front-End > Flutter' 카테고리의 다른 글

[Flutter] 07. Row, Column, GridView  (0) 2024.03.16
[Flutter] 06. 버튼, 잉크웰  (0) 2024.03.16
[Flutter] 04. 반응형 위젯  (0) 2024.03.16
[Flutter] 03. showModalBottomSheet  (0) 2024.03.16
[Flutter] 02. 화면 전환, 이동  (0) 2024.03.16

댓글