-
Flutter_08. making a model class> Frontend/Flutter 2023. 5. 2. 23:14
1.
- flutter pub add uuid 설치 후, 아래와 같이 진행
import 'package:uuid/uuid.dart'; const uuid = Uuid(); class Expense { Expense({ required this.title, required this.amount, required this.date }): id = uuid.v4(); // in Dart, 'Initializer Lists' can be used to initialize class properties with values that are Not received as constructor function arguments // Basically, when this Expense class initialized, it will be assign as an initial value to ID property final String id; final String title; final double amount; final DateTime date; }
- 위의 사진과 같이, id 값에 초기값을 할당할 수 있다.
'> Frontend > Flutter' 카테고리의 다른 글
Flutter_10. Custom List & Formatting Data (0) 2023.05.03 Flutter_09.Enums and ListView (0) 2023.05.02 Flutter_07.Quiz App04_Map & For loops (마무리) (0) 2023.04.26 Flutter_06. QuizApp03_ Passing Data (0) 2023.04.24 Flutter_05. If-Statement & 퀴즈 데이터 (0) 2023.04.22