목록전체 글 (58)
아무나 빌려가세요
필수 dart 패키지 import 'package:http_parser/http_parser.dart'; import 'package:image_picker/image_picker.dart'; import 'package:dio/dio.dart'; 촬영한 단일사진을 선택하는 함수 File? imageFile; ... onPressed: () => getImage(source: ImageSource.camera) //imageSource에서 camera로 할경우 촬영가능 gallary로 할 경우 이미지 갤러리로 이동 ... void getImage({required ImageSource source}) async { final file = await ImagePi..
Map phoneBook = { 'Kyle' : 79797, 'sdfsf' : 23424, 'asfsdf' : 234234, 'asdfsf':234234, }; void main(){ phoneBook\['james'\] = 01030111234; print(phoneBook\['Kyle'\]); // 79797 print(phoneBook.keys); // (Kyle, sdfsf, asfsdf, asdfsf, james) print(phoneBook.values); // (79797, 23424, 234234, 234234, 1030111234) print(phoneBook.length); //5 }
flutter에서 함수인자를 받는 고차함수를 설명 void main(){ Human park = Human(eating:slowEating) print(park.eating); // Closure slowEating => 클래스의 함수가 slowEating으로 변경 park.eating(); // 'eating slowly' 를 출력 } class Human { Human({this.eating}) Function eating; } void slowEating(){ print('eating slowly') }
타입을 숫자로 정할경우 나중에 볼때 혼돈이 올 수 있기 때문에 문자로 타입을 명확히 해주는 방법. 타입설정 enum SmartPhone = { IOS,ANDROID} void selectOS(SmartPhone phone){ if(phone == SmartPhone.IOS){ print('나는 아이폰이다'); }else{ print('나는 안드로이드다'); } } 이렇게 눈으로 봤을때 쉽게 알아볼 수 있도록 타입을 설정한다.
클래스는 3가지로 구성되어 있다. 클래스 안의 변수는 프로퍼티,함수는 메서드 그리고 constructor가 있다. 클래스를 선언할땐 '클래스의 이름' '생성한 이름' = 클래스(); 이렇게 생성한다. => Human park = Human(); constructor는 클래스를 선언할때 변수의 값을 바꿔줄 수 있다. class Human{ double height; -> 프로퍼티 Human(double height){ this.height (프로퍼티) = height; } } ..... Human park = Human(height = 14); 로 초기화를 해줄 수 있다. 위에 클래스를 봤을때 프로퍼티와 선언변수가 이름이 같은데 이것을 간단하게 해줄 수있다. constructor를 Human(this.he..