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

पैकेज विवरणv1.0.0+4

ready_view

फ्लटर के साथ विकास करते समय, नेटवर्क या डेटाबेस से जानकारी प्राप्त करने के लिए असिंक्रोनस ऑपरेशन का उपयोग करना आम है। ऐसे मामलों में, हमें पृष्ठों पर लोडिंग विजेट शामिल करने की आवश्यकता होती है, लोडिंग पूरा होने की ट्रैकिंग करनी होती है, और लोडिंग पूरा होने के बाद मूल दृश्य प्रदर्शित करना होता है। इस श्रृंखला के कोड को शामिल करने से दृश्य कोड काफी जटिल और गड़बड़ हो सकता है। इसलिए, ready_view लाइब्रेरी असिंक्रोनस क्रियाओं को संभालने के लिए एक सरल और चालाक समाधान प्रदान करती है।

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

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

flutter pub add ready_view

पैकेज अवलोकन

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

ReadyView एक Flutter/Dart पैकेज है जिसका उद्देश्य UI विकास में असिंक्रोनस संचालन के हैंडलिंग को सरल बनाना है। यह नेटवर्क या डेटाबेस से डेटा लोड करते समय लोडिंग स्थिति, सफलता परिणाम और त्रुटियों के प्रबंधन के लिए एक साफ, घोषणात्मक तरीका प्रदान करता है। ReadyView के साथ सामग्री को लपेटकर, विकासकर्ताओं को लोडिंग इंडिकेटर और राज्य ट्रैकिंग के लिए बॉइलरप्लेट कोड लिखने से बचने की अनुमति मिलती है, जिससे अधिक साफ और बनाए रखने में आसान विजेट वृक्ष प्राप्त होते हैं। पैकेज सभी प्रमुख प्लेटफॉर्मों का समर्थन करता है और मौजूदा Flutter प्रोजेक्ट में आसानी से एकीकृत होता है।

उपयोग

  • API प्रतिक्रियाओं का निपटान
  • लोडिंग स्थिति प्रदर्शित कर रहे हैं
  • त्रुटि स्थितियों का प्रबंधन
  • असिंक्रोनस यूआई तर्क को सरल बनाना
  • हाथ से राज्य प्रबंधन का प्रतिस्थापन

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

  • घोषणात्मक लोडिंग स्थिति
  • एम्बेडेड त्रुटि संभाल
  • न्यूनतम बॉलरप्लेट
  • क्रॉस-प्लेटफॉर्म समर्थन
  • Future-आधारित ऑपरेशन्स के साथ आसान एकीकरण

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

  • स्पष्ट एएसिंक UI पैटर्न की तलाश में विकासकर्ता
  • अक्सर नेटवर्क/डेटाबेस कॉल करने वाले प्रोजेक्ट
  • विजेट की जटिलता को कम करना चाहने वाली टीमें
  • Flutter के शुरुआती लोग एसिंक वर्कफ्लो सीख रहे हैं
  • प्रतिक्रियाशील लोडिंग प्रतिक्रिया की आवश्यकता वाले ऐप्स

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

  • फ्यूचर्स के बारे में समझ की आवश्यकता है
  • सीमित एक्सिक्यूट कार्य वैलेटर्स
  • जटिल राज्य मशीन के लिए उपयुक्त नहीं
  • पुनर्प्रयास तंत्र के लिए अतिरिक्त तर्क की आवश्यकता हो सकती है
  • सरल fetch-और-प्रदर्शन परिदृश्यों के साथ सबसे अच्छा उपयोग किया जाता है

मूल README

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

pub package GitHub

ready_view

Motivation

When developing with Flutter, it is often necessary to use asynchronous operations when fetching information from networks or databases. In such cases, we need to include loading widgets on our pages, track the completion of loading, and display the original view once the loading is complete. Including this series of code can make the view code quite complex and messy.

Therefore, the ready_view library offers a simple and elegant solution for handling asynchronous actions.

Installation

flutter pub add ready_view

Usage

1. Change Code
When Stateless Widget
// replace
StatelessWidget => ReadyStatelessWidget

build(BuildContext context) => buildWhenReady(BuildContext context)
Stateful Widget
// replace
extends State<.. => extends ReadyState<..

build(BuildContext context) => buildWhenReady(BuildContext context)
2. Add readyState(Optional)

When asynchronous actions are required, you can override the readyState() to perform the necessary tasks.

// handle async operation here if needed
@override
Function? readyState(BuildContext context) {
  return () async {
    // your async code here
    await Future.delayed(const Duration(seconds: 2));
  };
}
3. Custom Loading Widget(Optional)

You can customize the loading widget by overriding the loadingWidget() if you want.

  // custom loading widget if needed
  @override
  Widget loadingWidget() {
    return Scaffold(
        body: Center(
            child: Container(
      width: 100,
      height: 100,
      color: Colors.red,
    )));
  }

Example

Stateless Widget
import 'package:flutter/material.dart';
import 'package:ready_view/ready_view.dart';

class StatelessExample extends ReadyStatelessWidget {
  const StatelessExample({super.key});

  // handle async operation here if needed
  @override
  Function? readyState(BuildContext context) {
    return () async {
      await Future.delayed(const Duration(seconds: 2));
    };
  }

  // custom loading widget if needed
  // @override
  // Widget loadingWidget() {
  //   return Scaffold(
  //       body: Center(
  //           child: Container(
  //     width: 100,
  //     height: 100,
  //     color: Colors.red,
  //   )));
  // }

  @override
  Widget buildWhenReady(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('StatelessExample'),
      ),
      body: const Center(
        child: Text('Content is ready!'),
      ),
    );
  }
}

void main() {
  runApp(const MaterialApp(
    home: StatelessExample(),
  ));
}
Stateful Widget
import 'package:flutter/material.dart';
import 'package:ready_view/ready_view.dart';

class StatefulExample extends StatefulWidget {
  const StatefulExample({super.key});

  @override
  ReadyState<StatefulExample> createState() => _StatefulExampleState();
}

class _StatefulExampleState extends ReadyState<StatefulExample> {
  
  // handle async operation here if needed
  @override
  Function? readyState(BuildContext context) {
    return () async {
      await Future.delayed(const Duration(seconds: 2));
    };
  }

  // custom loading widget if needed
  // @override
  // Widget loadingWidget() {
  //   return Scaffold(
  //       body: Center(
  //           child: Container(
  //     width: 100,
  //     height: 100,
  //     color: Colors.red,
  //   )));
  // }

  @override
  Widget buildWhenReady(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('StatefulExample'),
      ),
      body: const Center(
        child: Text('Content is ready!'),
      ),
    );
  }
}

void main() {
  runApp(const MaterialApp(
    home: StatefulExample(),
  ));
}
Comparison with FutureBuilder

Although similar to FutureBuilder, using FutureBuilder asynchronously when the view is first created requires setting up related state, including calling asynchronous functions in initState, and placing the FutureBuilder in the build function along with a separate loading widget. In contrast, ready_view allows you to keep your existing code as it is, while providing a cleaner and more intuitive way to handle asynchronous actions by separately calling the readyState and loadingWidget functions when needed.

श्रेणियाँ

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

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

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