सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
मोमेंटम एक फ्लटर पैकेज है जो मॉडल-व्यू-कंट्रोलर (MVC) पैटर्न को लागू करता है, राज्य प्रबंधन, डिपेंडेंसी इंजेक्शन और सेवा स्थान के लिए एक एकीकृत समाधान प्रदान करता है। यह निर्देशित मॉडल, व्यू और कंट्रोलर परतों के माध्यम से चिंताओं को अलग करके एप्लिकेशन आर्किटेक्चर को सरल बनाता है, जिससे स्केलेबल और बनाए रखने योग्य कोड बनता है। मोमेंटम फ्लटर के विजेट ट्री के साथ बिना किसी दिक्कत के एकीकृत होता है और सभी प्रमुख प्लेटफॉर्म, जैसे Android, iOS, Web, macOS, Windows और Linux का समर्थन करता है। इसका हल्का डिज़ाइन कोड के स्पष्ट संगठन और घटकों के बीच कुशल डेटा प्रवाह को बढ़ावा देता है।
उपयोग
स्केलेबल फ्लटर एप्लिकेशन बिल्ड करना
जटिल ऐप राज्य का प्रबंधन
निर्भरता निवेश का कार्यान्वयन
बहुत सारे राज्य प्रबंधन समाधानों का प्रतिस्थापन
मॉड्यूलर और परीक्षण योग्य कोड बनाना
मुख्य विशेषताएँ
निर्मित एमवीसी संरचना
एकीकृत निर्भरता इंजेक्शन
सेवा स्थान निर्धारण कार्यक्षमता
क्रॉस-प्लेटफ़ॉर्म समर्थन
न्यूनतम बॉयलरप्लेट
स्वचालित नियंत्रक जीवनचक्र प्रबंधन
इनके लिए उपयुक्त
संरचित एप्लिकेशन संरचना की खोज कर रहे विकासकर्मी
राज्य और निर्भरता प्रबंधन को एकीकृत करने वाली टीमें
रखरखाव और मॉड्यूलर कोड की आवश्यकता वाले प्रोजेक्ट
बहुप्लेटफॉर्म लक्षित फ्लटर एप्प्स
अन्य पैटर्न के बजाय MVC को प्राथमिकता देने वाले डेवलपर्स
विचार योग्य बातें
MVC के अपरिचित विकासकर्मियों के लिए सीखने का ढलान
वैकल्पिक विकल्पों के मुकाबले सीमित समुदाय ग्रहण
पहले के कोडबेस को पुनर्गठित करने की आवश्यकता हो सकती है
मध्यम से बड़े पैमाने के प्रोजेक्ट्स के लिए सबसे उपयुक्त
सरल या प्रोटोटाइप ऐप्स के लिए आदर्श नहीं
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
MVC pattern for flutter. Works as state management, dependency injection and service locator.
Model View Controller
Here's a diagram describing the flow between the state (model), widget (view) and the logic (controller):
Both MomentumController and MomentumModel are abstract classes that needs to be implemented. A pair of model and controller is called a component. MomentumBuilder is simply a widget. This is used to listen to controllers for rebuilds and accessing models to display their values.
Example
If you want to see a full code example that runs. Visit the example tab for more details or you can visit the official webpage. Otherwise, if you only want to see a glimpse of how momentum works, read the Overview and FAQs below.
Advance Example:Listify (clone the repo and run the app, requires Flutter 2.0.0)
Overview
MomentumModel - the data or state. Must be Immutable.
MomentumBuilder - the view or widget to display the state.
MomentumBuilder(
controllers: [ProfileController], /// injects both `ProfileController` and `ProfileModel`.
builder: (context, snapshot) {
var profileState = snapshot<ProfileModel>(); /// grab the `ProfileModel` using snapshot.var username = profileState.username;
return// some widgets here ...
}
)
MomentumController - the logic to manipulate the model or state.