inblog logo
|
jay0628
    Flutter

    [Flutter] 24. 모두의 블로그 앱 만들기 (2) - 회원가입 페이지 (2)

    김주희's avatar
    김주희
    Jun 08, 2025
    [Flutter] 24. 모두의 블로그 앱 만들기 (2) - 회원가입 페이지 (2)
    ref = IOC 컨테이너
    함수는 매개변수 날려야됨!ref로 땡겨와서 repository에서 쓰는게 아니라!
     

    1.

    notion image
     

    2. 디렉토리 구조

    notion image
     

    session_gvm

    join_fm 내용 복붙해서 수정하기
    notion image
     

    session_gvm

    통신을 하고 난 다음에 만들어지는 거임
    notion image
     

    창고에 join/login/logout 함수 만들기

    notion image
     

    Repository 만들기

    notion image
     
    싱글톤 이런거 지금은 생각 안하고 그냥 짤게여
    notion image
    notion image
    response 안에 헤더와 바디가 있음
     
    notion image
    notion image
     
     
    매개변수 3개 fm에서 가져와서 map으로 바꿈 (dto 안만들고 걍 map으로 만들어서 던지면 됨)
    response = 헤더와 바디
    지금 헤더 안읽어도 됨 여기서 비지니스 로직 안읽을거고 에러 안나게 설정해뒀으니까 responseBody에 그냥 에러 메세지가 담길거임!
    viewmodel에서 비지니스 로직 처리할거임
    바디에 success와 status 없으면 repository에서 비지니스 로직 처리해야하고 response를 전달해줘야 함 파싱을 view model에서 하면 복잡해짐
    repo의 책임은 통신과 파싱 (통신과 body데이터만 응답해주기)
     
    success와 status있으면 repo에서 파싱하고 다 처리할 수 있음?
     

    UserRepository

    notion image
     
    view = 화면 (controller역할까지)
    viewmodel = service
    repository = repository
     
    화면 전달시 무조건 context 필요
    navigator의 history를 만들어둠→ context
    notion image
     
    네비게이터 객체 안에 context 존재 → 네비게이터 하나 더 있으면 알림창 뜨는 그런 애들을 위한 기존 context와 상관없는 애
    기존 context에서 왔다는걸 알아야 됨
     

    context 넘기는 방법

    notion image
    화면이 아닌 곳에서 context를 쓰고 싶으면
     
     
    notion image
     
    notion image
    여기 통과하면 로그인화면으로 감
    db 확인하려면 initUser 때려보면 됨
    notion image
     
     

    위에는 return이 빠져서 유효성 검사 통과 못해도 넘어감 다시 수정한 코드로 실행한 결과
    notion image
    Share article

    jay0628

    RSS·Powered by Inblog