flutter(37)
-
[Flutter] Don't use 'BuildContext's across async gaps
Don't use 'BuildContext's across async gaps. this error is BuildContext Optional error. may be thid code. if (isLogin) { Navigator.pop(context, "success"); } you must use mounted. if (mounted) { if (isLogin) { Navigator.pop(context, "success"); }
2024.01.29 -
[Flutter] ValueNotifier, ChangeNotifier
플루터에서 UI를 변경하기 위해서 StatefulWidget을 사용하고, setState메서드를 사용하여 UI를 변경한다. 이것이 기초중의 기초. 하지만, 계속해서 setState를 사용하여 build를 하게 되면 UI 전체가 갱신되기 때문에 부분적인 값만 변경하는 경우 불필요하다. 그래서 찾게 된 것이 ValueNotifier. 특정 값만을 변경하기 위해서는 ValueNotifier을 사용한다. 원하는 타입을 제네릭으로 넣어 상속하여 준다. class NotifyFriend extends ValueNotifier { NotifyFriend({int value = 0}):super(value); void increment() { value++; } void normalMethod() { } void no..
2024.01.29 -
[Flutter] SliverList
SliverList를 사용하는 이유는 스크롤을 했을때 다른 위젯을 자연스럽게 disable하는 역할이다.메인 이미지가 있었고, 스크롤을 하면 자연스럽게 메인이미지가 사용자에게 보이지 않도록 하고 싶었다. Sliver에 더 깊게 알 필요 없다. 단 두 가지만 알면 아마 원하는 동작을 만들 수 있을 것이다.사용법은 간단하다.(문서가 읽기 힘든 사람이면 지금 이 포스트를 잘 찾은것) SliverList를 사용하기 위해서 먼저 'CustomScrollView'를 부모뷰로 사용한다. 그리고 slivers 파라메터에 가리고 싶은 위젯을 SliverAppBar로 사용하고, 그 하위 스크롤 하고 싶은 위젯들을 SliverList에 선언한다.CustomScrollView( slivers: [ ..
2024.01.27 -
[Flutter] Calendar, DateTime, Intl, TimeOfDay
flutter pub add calendar importimport 'package:table_calendar/table_calendar.dart'; code body: SafeArea( top: true, child: TableCalendar( focusedDay: DateTime.now(), // focus date firstDay: DateTime(2019, 12, 5), // first date lastDay: DateTime(2024, 1, 30), // last date // --- required selectedDayPre..
2024.01.20 -
[Flutter] ImagePicker, GallerySaver #camera #gallery
you want select something images your gallery on device. flutter pub add image_picker importimport 'package:image_picker/image_picker.dart'; property XFile? imageFile; select Image void onPickImage() async { final XFile? selectImage = await ImagePicker().pickImage( source: ImageSource.gallery, ); setState(() { imageFile = selectImage; }); } seled Image show viewe..
2024.01.20