मिनटों में miniriverpod इंस्टॉल करें।
सिंगल-फाइल कोर और पतली Flutter बाइंडिंग वाला हल्का Riverpod-स्टाइल स्टेट मैनेजमेंट टूलकिट।
आवश्यकताएँ
सुनिश्चित करें कि आपका प्रोजेक्ट न्यूनतम SDK और Flutter वर्ज़न को पूरा करता है।
Dart SDK
>=3.10.0 <4.0.0
Flutter
>=3.38.0
टिप
यदि आप किसी मौजूदा प्रोजेक्ट को अपग्रेड कर रहे हैं, तो इंस्टॉल कमांड चलाने से पहले अपने SDK constraints अपडेट करें।
इंस्टॉलेशन
Flutter CLI के साथ पैकेज जोड़ें या pubspec को मैन्युअली अपडेट करें।
CLI
flutter pub add miniriverpod
pubspec.yaml
# अपनी dependencies में जोड़ें
dependencies:
miniriverpod: ^0.0.1
पहले कदम
ProviderScope वायर करें, एक Provider घोषित करें, और UI से watch करें।
main.dart
// 1) अपने ऐप को ProviderScope से रैप करें
void main() {
runApp(
const ProviderScope(
child: MyApp(),
),
);
}
// 2) एक Provider परिभाषित करें
final counterProvider = Provider<int>((ref) => 0);
// 3) UI से watch करें
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) => ...) is synchronous.
AsyncProvider<T>((ref) async => ...) handles Future or Stream.
From UI, subscribe with WidgetRef.watch(provider).
अगले कदम
API Reference
Quickly lookup methods such as invalidate, refreshValue, keepAlive, and invoke.
Open API Reference