पैकेज, रिपॉज़िटरी और ऐप श्रेणियाँ खोजें

पैकेज विवरणv0.10.0

flutter_state_management

राज्य प्रबंधन के लिए ChangeNotifier के उपयोग को आसान बनाने वाले सहायक क्लासेस का संग्रह

AndroidiOSWebmacOSWindowsLinux
30-दिन डाउनलोड
296
लाइक
4
Pub अंक
160

पैकेज इंस्टॉल करें

flutter pub add flutter_state_management

पैकेज अवलोकन

सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।

एक हल्का पैकेज जो ChangeNotifier के साथ काम करने के लिए सहायता क्लास प्रदान करके Flutter में राज्य प्रबंधन को सरल बनाता है। यह बॉयलरप्लेट कोड को कम करता है और ऐप राज्य के प्रबंधन में डेवलपर उत्पादकता को बढ़ाता है। इस पैकेज को Flutter के प्रतिक्रियाशी ढांचे के साथ बिना किसी असुविधा के एकीकृत करने के लिए डिज़ाइन किया गया है, और यह Android, iOS, Web, macOS, Windows और Linux सहित सभी प्रमुख प्लेटफॉर्म का समर्थन करता है। बड़े राज्य प्रबंधन समाधानों की जटिलता के बिना एक न्यूनतम, साफ दृष्टिकोण के लिए राज्य हैंडलिंग की खोज करने वाले डेवलपर्स के लिए यह पैकेज आदर्श है।

उपयोग

  • छोटे ऐप में सरल राज्य अद्यतन
  • ChangeNotifier के अमल में बॉयलरप्लेट को कम करना
  • फॉर्म और UI कंपोनेंट्स में राज्य तर्क को सुगम बनाना
  • कई विजेट्स के मध्य साझा डेटा का प्रबंधन करना
  • BLoC या प्रोवाइडर का हल्का विकल्प

मुख्य विशेषताएँ

  • ChangeNotifier के लिए सहायक क्लासेस
  • न्यूनतम सेटअप और एकीकरण
  • क्रॉस-प्लेटफ़ॉर्म समर्थन
  • साफ और पढ़ने में आसान कोड संरचना
  • सामान्य राज्य पैटर्न के लिए आंतरिक सहायता कार्य

इनके लिए उपयुक्त

  • शुरुआती Flutter विकासकर्ता
  • छोटे से मध्यम आकार के प्रोजेक्ट
  • मूल अवस्था प्रबंधन की आवश्यकता वाले ऐप्स
  • सरलता के लिए जटिलता से अधिक प्राथमिकता देने वाले विकासकर्मी
  • त्वरित प्रोटोटाइपिंग चाहने वाली टीमें

विचार योग्य बातें

  • जटिल राज्य प्रवाह के लिए उपयुक्त नहीं
  • पूर्ण-सुविधा वाले अवस्था प्रबंधन लाइब्रेरी की तुलना में सीमित
  • बड़े पैमाने वाले एप्लिकेशन के लिए अतिरिक्त टूलिंग की आवश्यकता हो सकती है
  • स्केलिंग के समय अन्य राज्य प्रबंधन दृष्टिकोणों के साथ सबसे अच्छा उपयोग किया जाता है
  • स्थायी संग्रहण या एसिंक हैंडलिंग के लिए निर्मित नहीं है

मूल README

संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।

Flutter State Management

Just a couple of utility classes to make it easier to use Flutter framework's built-in ChangeNotifier and Listenable for state management.

Features

  • No learning curve if you already know Flutter
  • Simple package based on ChangeNotifier (No bloatware)

Usage

Create your model class

class Counter extends StateNotifier<int, String> {
  Counter() : super(const Active(data: 0));

  void increment() async {
    setWaiting();

    await Future.delayed(const Duration(seconds: 2));

    if (data > 20) {
     setFailed('greater than 20');
    } else {
      setActive(data + 1);
    }
  }
}

Or if you want the state to persist across restarts

class Counter extends PersistedStateNotifier<int, String> {
  Counter() : super(IsarKeyValue(), startState: 0);

  void increment() async {
    setWaiting();

    await Future.delayed(const Duration(seconds: 2));

    if (data > 20) {
      setFailed('greater than 20');
    } else {
      setActive(data + 1);
    }
  }
}

Handle State Changes in UI

To only rebuild specific parts:
  1. Use ValueListenableBuilder from the Flutter framework:
final counter = Counter();

ValueListenableBuilder(
  valueListenable: counter,
  child: Text()
  builder: (context, state, child) => // return updated UI here (can also use counter.builderArg here)
  child: const Text('Hello'),
  ),
);

You can also use builderArg helper:

builder: counter.builderArg(
  onActive: ,
  onWaiting: ,
  onNone: ,
  onFailure: ,
),
  1. Or use StateNotifierBuilder that comes with this package and is more user friendly:
final counter = Counter();

counter.builder(
  onActive: (context, data) => Text(data.toString()),
),


\

To rebuild whole widget

Convert your existing StatelessWidget to RStatelessWidget, and StatefulWidget to RStatefulWidget and and just watch the model inside the build method:

class CounterText extends RStatelessWidget {
  @override
  Widget build(BuildContext context) {
    counter.watch(context); // call watch inside the build method (do not use any if) 
    return Text(data.toString());
  }
}

श्रेणियाँ

सोर्स रिपॉज़िटरी

इस पैकेज का उपयोग करने वाले प्रोजेक्ट

अभी कोई डेटा उपलब्ध नहीं है।