Flutter အတွက် အလေးချိန်နည်းသော state management ဖြေရှင်းချက်။
code generation မလိုဘဲ၊ dependency အများကြီးမလိုဘဲ Riverpod ရဲ့ reactive architecture ကို အတွေ့အကြုံရယူပါ။
Code Gen မလို
ပုံမှန် Dart classes နှင့် providers ကိုရေးပါ။ build_runner မလိုအပ်ပါ။
အလေးချိန်နည်း
50KB ထက်နည်း။ performance-critical အက်ပ်များအတွက် သင့်တော်သည်။
ရင်းနှီးသိပြီးသား API
Riverpod ရဲ့ state-reading syntax ကို တိုက်ရိုက်အခြေခံထားသည်။
ပထမဆုံး အဆင့်များ
မိနစ်ပိုင်းအတွင်း miniriverpod ကို သင့် Flutter ပရောဂျက်ထဲ ထည့်သွင်းရန် သင်ယူပါ။
တပ်ဆင်ခြင်း
flutter pub add miniriverpod
အသုံးပြုမှုလမ်းညွှန်
user_provider.dart
import 'package:flutter/widgets.dart';
import 'package:miniriverpod/miniriverpod.dart';
// 1) Wrap your app with ProviderScope
void main() {
runApp(
const ProviderScope(
child: MyApp(),
),
);
}
// 2) Define a Provider
final counterProvider = Provider<int>((ref) => 0);
// 3) Watch from UI
class MyApp extends ConsumerWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final count = ref.watch(counterProvider);
return Directionality(
textDirection: TextDirection.ltr,
child: Center(child: Text('$count')),
);
}
}
အရေးကြီးသော မှတ်ချက်
မူရင်း Riverpod နှင့် မတူဘဲ၊ miniriverpod သည် Flutter အက်ပ်များကို အဓိက ရည်ရွယ်ထားပြီး standalone Dart projects များကို မထောက်ပံ့ပါ။ ၎င်းကြောင့် performance အတွက် internal logic ၏ 70% ကို ဖြုတ်ပစ်နိုင်ခဲ့သည်။
အရင်
Welcomeနောက်တစ်ခု
Installation