miniriverpod ကို မိနစ်အနည်းငယ်အတွင်း ထည့်သွင်းပါ။

SDK constraints များကို သတ်မှတ်ပြီး၊ package ကို ထည့်သွင်းကာ ProviderScope + WidgetRef.watch တို့ မှန်ကန်စွာ ချိတ်ဆက်ထားကြောင်း အတည်ပြုပါ။

လိုအပ်ချက်များ

Analyzer နှင့် runtime မကိုက်ညီမှုကို ရှောင်ရှားရန် package နှင့် အတူတူသော constraints များကို အသုံးပြုပါ။

Dart SDK

>=3.10.0 <4.0.0

Flutter

အကြံပြုချက်

သင့် app ကို Dart 3.10 အောက်တွင် lock လုပ်ထားပါက ပထမဦးစွာ SDK constraints များကို မြှင့်တင်ပြီး၊ ထို့နောက် flutter pub get ကို run ပါ။

တပ်ဆင်ခြင်း

CLI ဖြင့် ထည့်သွင်းခြင်းကို ဦးစားပေးပြီး၊ ထို့နောက် version ကို package changelog နှင့် ကိုက်ညီအောင် ထိန်းထားပါ။

CLI

pubspec.yaml

# Add to dependencies
dependencies:
  miniriverpod: ^0.0.2

ပထမအဆင့်များ

သင့် app ကို ProviderScope အတွင်း ထားပြီး Provider ကို သတ်မှတ်ကာ ConsumerWidget မှ state ကို ပြသပါ။

import 'package:flutter/widgets.dart';
import 'package:miniriverpod/miniriverpod.dart';

final counterProvider = Provider<int>((ref) => 0);

void main() {
  runApp(const ProviderScope(child: CounterApp()));
}

class CounterApp extends ConsumerWidget {
  const CounterApp({super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final count = ref.watch(counterProvider);
    return Directionality(
      textDirection: TextDirection.ltr,
      child: Center(child: Text('$count')),
    );
  }
}
synchronous တန်ဖိုးများအတွက် Provider((ref) => ...) ကို အသုံးပြုပါ။
Future အတွက် AsyncProvider<T>((ref) async => ...) ကို အသုံးပြုပြီး Stream အတွက် ref.emit(stream) ကို အသုံးပြုပါ။
mutations ကို အကောင်အထည်ဖော်သည့်အခါ ref.invoke(provider.method()) သို့ ပြောင်းပါ။

နောက်တစ်ဆင့်များ

Core Concepts

args အခြေပြု provider identity, Scope injection, နှင့် codegen မလိုသော design ရွေးချယ်မှုများကို နားလည်ပါ။

Core Concepts ဖွင့်ရန်

Providers & Reads

watch/read/listen အပြုအမူနှင့် AsyncProvider refresh ပုံစံများကို လေ့လာပါ။

Providers ဖွင့်ရန်

API Reference

invalidate, refreshValue, keepAlive, invoke စသည့် methods များကို အမြန် ရှာဖွေပါ။

API Reference ဖွင့်ရန်