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

पैकेज विवरणv2.1.0

flutter_conditional_rendering

एक फ्लटर पैकेज जो शर्ती रेंडरिंग को बढ़ाता है, if-else और switch शर्तों का समर्थन करता है।

AndroidiOSWebmacOSWindowsLinux
30-दिन डाउनलोड
9.1 हज़ार
लाइक
114
Pub अंक
160

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

flutter pub add flutter_conditional_rendering

पैकेज अवलोकन

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

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

उपयोग

  • राज्य के आधार पर डायनामिक UI तत्व
  • फॉर्म में शर्तों के आधार पर विजेट प्रदर्शन
  • स्विच-आधारित लेआउट परिवर्तन
  • उपयोगकर्ता भूमिका-आधारित इंटरफेस रेंडरिंग
  • सरलीकृत नेस्टेड त्रिकोणीय अभिव्यक्तियाँ
  • प्लेटफॉर्म-विशिष्ट तर्क के साथ प्रतिक्रियाशील डिज़ाइन

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

  • विजेट ट्री में if-else सिंटैक्स का समर्थन करता है
  • switch-case शर्तानुसार रेंडरिंग प्रदान करता है
  • जटिल शर्तों में बॉयलरप्लेट को कम करता है
  • सभी फ्लटर प्लेटफॉर्म्स पर काम करता है
  • pub add कमांड के साथ न्यूनतम सेटअप
  • साफ, पढ़ने योग्य शर्त तर्क

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

  • स्पष्ट शर्तीय UI कोड चाहने वाले विकासकर्ता
  • अक्सर राज्य-निर्भर रेंडरिंग वाले प्रोजेक्ट्स
  • रखरखाव वाले विजेट लॉजिक को प्राथमिकता देने वाली टीमें
  • प्लेटफॉर्म-विशिष्ट यूआई बदलाव की आवश्यकता वाले ऐप्स
  • घोषित यूआई पैटर्न का उपयोग करने वाले फ्रंटएंड डेवलपर्स

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

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

मूल README

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

flutter_conditional_rendering

A flutter package which enhances conditional rendering, supports if-else and switch conditions.

Why

In flutter if you want to do conditional rendering, you may do this:

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        if (someCondition == true)
          Text('The condition is true!'),
      ],
    );
  }
}

But what if you want to use a tertiary (if-else) condition?

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        someCondition == true ?
          Text('The condition is true!'):
          Text('The condition is false!'),
      ],
    );
  }
}

It is okay for a single Text widget, but the readability quickly become very bad when the child widget is multi-layered.

Usage

If-Else condition:
class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        Conditional.single(
          context: context,
          conditionBuilder: (BuildContext context) => someCondition == true,
          widgetBuilder: (BuildContext context) => Text('The condition is true!'),
          fallbackBuilder: (BuildContext context) => Text('The condition is false!'),
        ),
      ],
    );
  }
}
Switch condition:
class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        ConditionalSwitch.single<String>(
          context: context,
          valueBuilder: (BuildContext context) => 'A',
          caseBuilders: {
            'A': (BuildContext context) => Text('The value is A!'),
            'B': (BuildContext context) => Text('The value is B!'),
          },
          fallbackBuilder: (BuildContext context) => Text('None of the cases matched!'),
        ),
      ],
    );
  }
}

Want a list of widgets?

If you want to conditionally render a list of widgets (List<Widget>) instead of a single one. Use Conditional.list() and ConditionalSwitch.list()!

Contributions

Feel free to contribute to this project.

If you find a bug or want a feature, but don't know how to fix/implement it, please fill an issue. If you fixed a bug or implemented a feature, please send a pull request.

श्रेणियाँ

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

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

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