분류 전체보기
-
flutter에서 ?, ! 의미는?flutter 파헤치기 2024. 2. 12. 01:37
variable_type ? : 변수값 null 허용 variable! : 변수값이 null 아니라고 100% 확실할 때 !를 붙이고 만약 변수값이 null 이면 오류 발생 void main() { // 변수 앞에 ?는 null 값을 허용하고, // 변수 뒤의 !는 null 값이면 컴파일 오류를 낸다. int? a = null; // OK : 변수 앞에 ?는 null 값을 허용한다. // int b = null; // Error : ?가 없으면 null 값을 불허한다. // late int c = null; // Error : ?가 없으면 null 값을 불허한다. // late const int dd; // Error : 컴파일 시점에 const는 값이 정해져야 된다. late final int d; /..
-
Collection forflutter 파헤치기 2024. 2. 12. 01:26
flutter void main() { // Collection for var persons = ['chanhong', 'hyeonseok', 'jisoung']; var newPerson = [ 'person: nico', 'person: lynn', for (var person in persons) "person: $person" ]; print(newPerson); } Output flutter: [person: nico, person: lynn, person: chanhong, person: hyeonseok, person: jisoung]
-
RegExp 정규식 숫자 찾기flutter 파헤치기 2024. 2. 12. 01:13
Flutter void main() { // RegExp : 숫자 찾기 String text = 'Hello, this is an example text 20with some 65 numbers like 12345 and symbols like @#\$'; RegExp regex = RegExp(r'\d+'); // Match one or more digits Iterable matches = regex.allMatches(text); for (Match match in matches) { print('Found match: ${match.group(0)}'); } } Output flutter: Found match: 20 flutter: Found match: 65 flutter: Found matc..