- dart는 포멧터(formatter)가 세미콜론 ; 을 자동으로 입력해주지 않는다.
- Variables
in case of usage of var
recommended way to use : var
case1
var name = "type of string";
name = 1 // error
should be string once it initialized
case2
var name ;
name = 'you'; //OK
name = 1; //OK
in a same way to declare variables like above
explicitly declared with class
String name = "type of string";
in case of usage of dynamic
dynamic name = "any type";
name = 1 ; // OK
name = true ; // OK
be changable
in case of usage of final
final String name = 'string'
name = 'string 1' // error
cannot assign again.
in case of usage of late
late final String name;
// do something, go to api then
name = 'name lazy from data'; // means one assignment
in case of usage of const
// 자바스크립트 & 타입스크립트의 const는 final과 더 흡사함.
cosnt : should be known at the compile time
// 컴파일 단계에서 이미 알고 있는 값 : const AppId , appBundleId etc.
const API_KEY = '112121';
const API_KEY = fetchApi(''); //error
==> (final or var) API_KEY = fetchApi(''); // OK
- null safety : ? mark
String name = 'String'
or
String? name = 'String' or null
name?.isNotEmpty;