Roseline Blog
/
개발 이야기(173)
/
flutter cookbook
Search
Share
flutter cookbook
subtitle
flutter 꿀팁
Tags
flutter
front-end
cookbook
Created
2021/02/26
2 more properties
Gallery view
Search
flutter cookbook
스택오버플로우에 올라온 질문.
3항 연산자
if문
flutter에서 conditional하게 child widget 렌더링하기
how to use conditional child widget
flutter
tip
source: google image
type 'A' is not a subtype of type 'B'
아래와 같은 오류가 뜬다.
[dart] type casting + optional chaining
dart 타입 캐스팅, 옵셔널 체이닝
dart
model, fromJson 노가다
flutter에서 model 클래스 정의하고, fromJson 생성자를 일일이 만들어줘야하는 게 불편했다. 데이터를 가져올 때마다 매번 이래야하니 귀찮아 죽을 것 같았다.
두번째 모델을 만들려다가 flutter에도 왠지 graphql-code-generator 같은 비슷한 라이브러리가 있을 것 같았다.아니나 다를까 3개 정도가 있었는데 그 중
artemis
가 document도 잘 정리되어있고 star 수도 많아 쓸만해보였다.
[Flutter] artemis - graphql code generator
flutter - artemis 사용 방법과 장단점
오픈소스
graphql
flutter
what is factory?
source:
https://dribbble.com/shots/6986338-Factory-illustration
flutter에서 모델 클래스를 만들 때 아래 같은 코드가 자주 사용된다. 그런데 factory라는 것을 dart에서 처음 봤다. factory 키워드는 무엇이고 어떤 역할을 할까?
[Dart] what is factory?
singleton pattern class
dart
image source: flutter.ko-dev
부모 위젯의 state를 참조, 변경하는 법
자기 자신의 state를 업데이트하려면
setState
를 쓰면 된다. 하지만 자식이 부모 위젯의 state를 참조 또는 변경하려면 어떻게 해야할까?
[Flutter] 자식 위젯에서 부모 위젯 state 참조하기: findAncestorStateOfType
How to Update State of Parent Widget?
flutter
tip
state 변경되어도 rerendering 하지 않는 방법
아래 그림은 StatefulWidget의 생명주기(life cycle)이다. build 메서드는 StatefulWidget에서 화면 상에 보여줄 위젯을 그린다. build 메서드는 initState를 실행하거나, 부모 위젯에 의해 config가 업데이트 되었거나, setState로 인해 state가 변경되었을 때 실행된다.
source:
https://www.developerlibs.com/2019/12/flutter-lifecycle-widgets.html
[Flutter] 불필요한 rerendering을 피하는 방법
AutomaticKeepAliveClientMixin 클래스
performance
UI/UX
tip
flutter
by Header Form on Unsplash