vxstate
VxState फ्लटर के लिए एक अन्य राज्य प्रबंधन समाधान है। यह Redux और VueX से बहुत प्रभावित है।
एक अन्य अवस्था प्रबंधन समाधान
यह अंग्रेज़ी मूल स्नैपशॉट है। नवीनतम सामग्री GitHub पर देखें।
VxState is a state management library built for Flutter apps with focus on simplicity. It is inspired by StoreKeeper & libraries like Redux, Vuex etc with the power of streams. Here is a basic idea of how it works:
Core of VxState is based on the InheritedModel widget from Flutter.
Add to your pubpsec:
dependencies:
...
vxstate: any
Create a store:
import 'package:vxstate/vxstate.dart';
class MyStore extends VxStore {
int count = 0;
}
Define mutations:
class Increment extends VxMutation<MyStore> {
perform() => store.count++;
}
Listen to mutations:
@override
Widget build(BuildContext context) {
// Define when this widget should re render
VxState.watch(context, on: [Increment]);
// Get access to the store
MyStore store = VxState.store as MyStore;
return Text("${store.count}");
}
Complete example:
import 'package:flutter/material.dart';
import 'package:vxstate/vxstate.dart';
// Build store and make it part of app
void main() {
runApp(VxState(
store: MyStore(),
child: MyApp(),
));
}
// Store definition
class MyStore extends VxStore {
int count = 0;
}
// Mutations
class Increment extends VxMutation<MyStore> {
perform() => store.count++;
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// Define when this widget should re render
VxState.watch(context, on: [Increment]);
// Get access to the store
MyStore store = VxState.store as MyStore;
return MaterialApp(
home: Scaffold(
body: Column(
children: <Widget>[
Text("Count: ${store.count}"),
RaisedButton(
child: Text("Increment"),
onPressed: () {
// Invoke mutation
Increment();
},
),
],
),
),
);
}
}
निर्भरता सूची 2 आइटम
{"sdk":"flutter"}{"sdk":"flutter"}उपयोग के अनुसार छाँटें, गतिविधि की तुलना करें और अपनाने से पहले मूल प्रोजेक्ट की आवश्यकताएँ जाँचें।
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗