RiverPod

김인범's avatar
Jan 13, 2025
RiverPod
💡
상태(Status)를 외부에서 관리하자.
⇒ UI에서 분리하자

RiverPod 적용하기

dev pub에 갑니다.
notion image
flutter_riverpod에 가서 인스톨링에서 터미널로 다운하는 코드를 복사해서
AS의 터미널에 붙여넣고, 실행하면 pub에 적용됩니다.
notion image
setting에 가서 plugin에서 RiverPod를 치면 나오는 상단의 스니펫을 인스톨 해준 뒤
 
live templates에서 flutter에 [+]을 눌러 단축키 명 = fno로 하여 아래의 코드를 넣어줍니다.
import 'package:flutter_riverpod/flutter_riverpod.dart'; final xxProvider = NotifierProvider<$NAME$VM, int>(() { return $NAME$(); }); class $NAME$VM extends Notifier<int> { @override int build() { return 0; } }
notion image
두 개를 체크해준 뒤 apply하고 ok하시면 됩니다.
 

viewModel 구조

notion image
Share article

taker