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

पैकेज विवरणv4.0.0

injector

injector एक सरल उपयोग करने वाला और हल्का डार्ट निर्भरता इंजेक्शन लाइब्रेरी है

AndroidiOSWebmacOSWindowsLinux
30-दिन डाउनलोड
9.3 लाख
लाइक
63
Pub अंक
160

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

flutter pub add injector

पैकेज अवलोकन

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

इंजेक्टर एक हल्का और आसान उपयोग करने वाला डार्ट डिपेंडेंसी इंजेक्शन लाइब्रेरी है, जिसका उद्देश्य फ्लटर एप्लिकेशन में डिपेंडेंसी के प्रबंधन को सरल बनाना है। यह डिपेंडेंसी के रजिस्टर और रिजॉल्व करने के लिए एक साफ और न्यूनतम API प्रदान करता है, जो सिंगलटन और ट्रांजिएंट इंस्टेंस दोनों का समर्थन करता है। फ्लटर प्रोजेक्ट में बिना किसी अड़च्चन के एकीकरण के साथ, यह कोड की मॉड्यूलरिटी और परीक्षण क्षमता को बढ़ाता है। यह लाइब्रेरी ऐसे विकासकर्ताओं के लिए आदर्श है जो अधिक जटिल DI समाधानों के बजाय एक सरल विकल्प चाहते हैं बिना किसी कार्यक्षमता के नुकसान के।

उपयोग

  • Flutter ऐप में सरल डिपेंडेंसी प्रबंधन
  • मॉक्ड निर्भरताओं के साथ परीक्षण
  • मॉड्यूलर एप्लिकेशन आर्किटेक्चर
  • सेवा इन्स्टेंटिएशन में बॉयलरप्लेट को कम करना
  • राज्य प्रबंधन सेटअप को सुगम बनाना
  • घटकों के बीच ढीला जुड़ाव सक्षम करना

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

  • न्यूनतम और स्वाभाविक API
  • सिंगलटन और ट्रांजीएंट बाइंडिंग का समर्थन
  • Flutter के साथ आसान एकीकरण
  • निर्माणकर्ता निवेश के लिए आंतरिक समर्थन
  • हल्का आकार
  • व्यापक दस्तावेज़ीकरण

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

  • शुरुआती से मध्यम स्तर तक के Flutter विकासकर्मी
  • छोटे से मध्यम आकार के एप्लिकेशन
  • उन्नत विशेषताओं के बजाय सरलता पर ध्यान केंद्रित परियोजनाएँ
  • त्वरित डीआई कार्यान्वयन के लिए खोज रहे टीमें
  • परीक्षण और बनाए रखने योग्य कोड की आवश्यकता वाले अनुप्रयोग

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

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

मूल README

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

Injector 💉 Build Status

Injector is a simple dependency injection lib for Dart.

It does not replace a complex dependency injection framework like Dagger, but it provides the basics that most apps need. Feature requests are welcomed!

Internally the injector is a singleton that stores instances and builders in a Map.

Use registerDependency<Type>() to register the dependency. Never ever try to register or get dependencies without the generic type! Dart allows it, but we don't ;)

All instances are lazy loaded, meaning that at the time you request the dependency the instance is created.

Get your dependency using get<Type>().

Usage

A simple usage example:

// Register a dependency (Every time a new instance)
injector.registerDependency<Car>(() {
      var engine = injector.get<Engine>();
      var fuel = injector.get<Fuel>();
      var driver = injector.get<Driver>();
      
      return CarImpl(engine,fuel,driver);
    });
    
// Register a singleton
injector.registerSingleton<Car>(() {
          var engine = injector.get<Engine>();
          var fuel = injector.get<Fuel>();
          var driver = injector.get<Driver>();
          
          return CarImpl(engine,fuel,driver);
        });
        
 // Use custom Factories by extending [Factory].
 injector.register(CustomFactory(() => Engine()));
    
// Register your dependencies / singletons in the  __main.dart__ file

Notice

If you have an issue with getting dependencies from the injector, check that imports of your dependencies classes are absolute.

Good: import 'package:<project_name>/some/package/<file_name>.dart';

Bad: import '../../some/package/<file_name>.dart';

Features and bugs

Please file feature requests and bugs at the issue tracker.

श्रेणियाँ

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

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