miniriverpod'ni bir necha daqiqada o'rnating.

Riverpod uslubidagi yengil state management vositasi: bitta fayl core va ingichka Flutter binding bilan.

Talablar

Loyihangiz minimal SDK va Flutter versiyalariga mosligini tekshiring.

Dart SDK

>=3.10.0 <4.0.0

Flutter

>=3.38.0

Maslahat

Agar mavjud loyihani yangilayotgan bo'lsangiz, o'rnatish buyrug'ini ishga tushirishdan oldin SDK constraints'ni yangilang.

O'rnatish

Flutter CLI orqali paket qo'shing yoki pubspec'ni qo'lda yangilang.

CLI

flutter pub add miniriverpod

pubspec.yaml

# Add to your dependencies
dependencies:
  miniriverpod: ^0.0.1

Birinchi qadamlar

ProviderScope'ni ulang, Provider e'lon qiling va UI'dan kuzating.

main.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')),
    );
  }
}
Provider((ref) => ...) sinxron ishlaydi.
AsyncProvider<T>((ref) async => ...) Future yoki Stream'ni boshqaradi.
UI'dan WidgetRef.watch(provider) bilan obuna bo'ling.

Keyingi qadamlar

Foydalanish qo'llanmasi

Nega miniriverpod Riverpod'ga o'xshaydi, ammo ortiqcha yuklarsiz ekanini bilib oling.

Qo'llanmani ochish

GitHub

Repozitordagi source, changelog va namunalarga qarang.

GitHub'ni ochish

API Reference

Quickly lookup methods such as invalidate, refreshValue, keepAlive, and invoke.

Open API Reference