Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- FLUTTER
- C++
- UWP
- RxAndroid
- Python
- 알고리즘
- 안드로이드 구글맵
- C
- Kotlin
- android push
- Android P
- mfc
- kodility
- 프로그래머스
- livedata
- Android
- C/C++
- Flutter TextField
- Django REST
- 코틀린
- Rxjava2
- flutter firestore
- NDK
- Django REST Android
- 안드로이드
- android architecture component
- RxJava
- Java
- dart
- Django REST framework
Archives
- Today
- Total
개발하는 두더지
Flutter - @required 속성 사용하기 본문
@required 에 대해 알아보기
@required
속성은 생성자가 기본값이 없고 null 이 아닐 경우에 사용합니다. 그리고 assert
메서드를 이용해 null일 경우를 체크하는 기능도 있습니다.
이 annotation을 사용하기 위해서 meta
패키지를 추가해야 합니다.
import 'package:meta/meta.dart';
사용 예시는 아래와 같습니다.
class Backdrop extends StatefulWidget {
final Category currentCategory;
final Widget frontLayer;
final Widget backLayer;
final Widget frontTitle;
final Widget backTitle;
const Backdrop({
@required this.currentCategory,
@required this.frontLayer,
@required this.backLayer,
@required this.frontTitle,
@required this.backTitle,
}) : assert(currentCategory != null),
assert(frontLayer != null),
assert(backLayer != null),
assert(frontTitle != null),
assert(backTitle != null);
@override
_BackdropState createState() => _BackdropState();
}
'Flutter' 카테고리의 다른 글
Flutter - font와 label 스타일 변경하기 (0) | 2019.05.10 |
---|---|
Flutter - CardView 구현하기 (0) | 2019.05.08 |
Flutter - TextField를 이용하여 로그인 페이지 구현하기(2) (0) | 2019.04.28 |
Flutter - TextField를 이용하여 로그인 페이지 구현하기(1) (0) | 2019.04.28 |
Flutter - Firestore 라이브러리 사용하기 (3) (1) | 2019.04.26 |
Comments