miniriverpod ਨੂੰ ਮਿੰਟਾਂ ਵਿੱਚ ਇੰਸਟਾਲ ਕਰੋ।

ਇੱਕ ਲਾਈਟ Riverpod-ਸਟਾਈਲ state management ਟੂਲਕਿਟ ਜਿਸ ਵਿੱਚ single-file core ਅਤੇ thin Flutter binding ਹੈ।

ਲੋੜਾਂ

ਯਕੀਨੀ ਬਣਾਓ ਕਿ ਤੁਹਾਡਾ ਪ੍ਰੋਜੈਕਟ ਘੱਟੋ-ਘੱਟ SDK ਅਤੇ Flutter ਵਰਜਨ ਨੂੰ ਪੂਰਾ ਕਰਦਾ ਹੈ।

Dart SDK

>=3.10.0 <4.0.0

Flutter

>=3.38.0

ਸੁਝਾਅ

ਜੇ ਤੁਸੀਂ ਮੌਜੂਦਾ ਪ੍ਰੋਜੈਕਟ ਅਪਗ੍ਰੇਡ ਕਰ ਰਹੇ ਹੋ, ਤਾਂ ਇੰਸਟਾਲ ਕਮਾਂਡ ਚਲਾਉਣ ਤੋਂ ਪਹਿਲਾਂ SDK ਸੀਮਾਵਾਂ ਅਪਡੇਟ ਕਰੋ।

ਇੰਸਟਾਲੇਸ਼ਨ

Flutter CLI ਨਾਲ ਪੈਕੇਜ ਜੋੜੋ ਜਾਂ pubspec ਨੂੰ ਹੱਥੋਂ ਅਪਡੇਟ ਕਰੋ।

CLI

flutter pub add miniriverpod

pubspec.yaml

# Add to your dependencies
dependencies:
  miniriverpod: ^0.0.1

ਪਹਿਲੇ ਕਦਮ

ProviderScope ਜੋੜੋ, Provider ਡਿਕਲੇਅਰ ਕਰੋ ਅਤੇ UI ਤੋਂ ਵੇਖੋ।

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) => ...) ਸਿੰਕ੍ਰੋਨਸ ਹੈ।
AsyncProvider<T>((ref) async => ...) Future ਜਾਂ Stream ਨੂੰ ਹੈਂਡਲ ਕਰਦਾ ਹੈ।
UI ਤੋਂ ਸਬਸਕ੍ਰਾਈਬ ਕਰਨ ਲਈ WidgetRef.watch(provider) ਵਰਤੋ।

ਅਗਲੇ ਕਦਮ

ਵਰਤੋਂ ਗਾਈਡ

ਜਾਣੋ ਕਿ miniriverpod Riverpod ਵਰਗਾ ਕਿਉਂ ਲੱਗਦਾ ਹੈ—ਬਿਨਾ overhead ਦੇ।

ਗਾਈਡ ਖੋਲ੍ਹੋ

GitHub

ਰਿਪੋ ਵਿੱਚ source, changelog ਅਤੇ samples ਵੇਖੋ।

GitHub ਖੋਲ੍ਹੋ

API Reference

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

Open API Reference