TIL

20231004 TIL

김빵그 2023. 10. 4. 17:36

Today 요약

[] leetCode 코딩테스트 1문제 

[] 프로그래머스 코딩테스트 1문제

[] dart 강의 2개

[] 옵시디언 정리

[] flutter 강의 4개


배운 점

1) dart type 확인 방법

String text = "hi~ dart ~ "; 
print(text.runtimeType); // text data type 정보를 가지고 옴


// result : String

2) 앱 상태에 따라 camera 변경

 

flutter camara 패키지 AppLifecycleState 앱 상태 확인

WidgetBindingObserver class _Screen extends State with WidgetsBindingObserver { @override void initState() { WodgetsBinding.instance.addObserver(this); } } WidgetBindingObserver를 활용하여 appLifecycleState의 변화를 감지할 수 있다 camera | F

252-archive.tistory.com

@override
void didChangeAppLifecycleState(AppLifecycleState state) {
  final CameraController? cameraController = controller;

  // App state changed before we got the chance to initialize.
  if (cameraController == null || !cameraController.value.isInitialized) {
    return;
  }

  if (state == AppLifecycleState.inactive) {
    cameraController.dispose();
  } else if (state == AppLifecycleState.resumed) {
    _initializeCameraController(cameraController.description);
  }
}

3) State Management

  • state 관리라는 것은 앱의 데이터를 체계적으로 정리하고, 데이터 변경을 감지 및 변경하는 방식
  • 위젯과 데이터를 분리 시키는 것

4) inherited widget

  • 정보를 트리 아래로 효율적으로 전파하는 위젯의 기본 클래스
  • InheritedWidget은 flutter 프레임워크에서 상속 계층 구조로 데이터를 공유하는 데 사용되는 중요한 개념 중 하나이다
  • 위젯 트리 내에서 데이터를 상위 위젯에서 하위 위젯으로 효과적으로 전달하고 공유하기 위한 방법을 제공
  • 주로 애플리케이션 상태, 테마 데이터, 로케일 설정, 인증 정보 및 기자 전역 데이터를 공유
  • 사용자 정의 위젯을 만들어, 데이터를 저장하고 하위 위젯에 전달, 이 데이터는 상속된 위젯 트리 내에서 변경될 때마다 하위 위젯에 자동으로 업데이트 된다

연휴라고 생일이라고 해이해졌다. 이번 주는 또 해외 출장 다녀오면 힘들다고 쉬겠지.. 그래도 틈틈이 공부해두자! 파이팅