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

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

sorted

जटिल ऑब्जेक्ट की सूचियों को आसानी से सॉर्ट करें। सरल लेकिन शक्तिशाली एक्सटेंशन मेथड।

AndroidiOSWebmacOSWindowsLinux
30-दिन डाउनलोड
393
लाइक
31
Pub अंक
140

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

flutter pub add sorted

पैकेज अवलोकन

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

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

उपयोग

  • नाम या उम्र के आधार पर उपयोगकर्ता डेटा को क्रमबद्ध करें
  • मूल्य या रेटिंग के अनुसार उत्पाद सूचियों को क्रमबद्ध करना
  • API प्रतिक्रिया सरणी को व्यवस्थित करना
  • UI में डायनामिक सूची क्रमबद्धता का प्रबंधन
  • जटिल ऑब्जेक्ट सॉर्टिंग तर्क को सरल बनाना

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

  • उपयोग में आसान विस्तार विधि
  • बहु-क्षेत्र वर्गीकरण का समर्थन करता है
  • आरोही और अवरोही क्रम का हैंडल करता है
  • न्यूनतम बॉयलरप्लेट
  • किसी भी ऑब्जेक्ट प्रकार के साथ काम करता है
  • क्रॉस-प्लेटफॉर्म संगतता

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

  • स्पष्ट वर्गीकरण सिंटैक्स की तलाश में विकासकर्ता
  • अक्सर सॉर्ट किए जाने वाली सूची वाले प्रोजेक्ट
  • डायनामिक डेटा प्रदर्शन वाले Flutter ऐप्स
  • कोड पठनीयता को प्राथमिकता देने वाली टीमें
  • डार्ट विकासकर्ता हाथ से तुलना कार्यक्रम लॉजिक से बचते हैं

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

  • Dart 2.12+ की आवश्यकता है
  • फ़ील्ड नाम के लिए कोई रनटाइम प्रकार सुरक्षा नहीं है
  • मूल छानविरे के पैटर्न तक सीमित
  • अत्यधिक जटिल वर्गीकरण नियमों के लिए उपयुक्त नहीं
  • मूल फ़ील्ड्स के आगे कस्टम तुलना फ़ंक्शन का समर्थन नहीं करता है

मूल README

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

sorted

Package on pub.dev Test suite

Sort lists of complex objects with ease. Simple but powerful extension method.

auctions.sorted([
    SortedOrdered<Auction, AuctionStatus>(
        (action) => auction.buyerContext.status,
        [AuctionStatus.live, AuctionStatus.won, AuctionStatus.lost],
    ),
    SortedComparable<Auction, DateTime>((auction) => auction.endedAt),
    SortedComparable<Auction, DateTime>(
        (auction) => auction.endedAt,
        invert: true,
    )
]);

Usage

Add the package to your pubspec.yaml:

dependencies:
  sorted: <newest version>

Import the package:

import 'package:sorted/sorted.dart';

Call sorted extension method on any list and pass sorting rules of your choice. Order matters, so if first rule considers two items equal, next one will decide and so on.

Sorting rules

All rules have an optional named argument invert which inverts the sorting order.

SortedOrdered
SortedOrdered<Auction, AuctionStatus>(
  (auction) => auction.buyerContext.status,
  [AuctionStatus.live, AuctionStatus.won, AuctionStatus.lost],
)

Sorts items by the mapped property value in an order passed as a second argument. In this example, live auctions will be first, then won, and then lost.

SortedGroupOrdered
SortedOrdered<Road, RoadType>(
  (road) => road.type,
  [
    [RoadType.nationalHighway, RoadType.stateHighway],
    [RoadType.district],
    [RoadType.dirt],
  ],
)

Sorts items by the mapped property value in the order of order groups, but all values withing a certain group are considered equal.

SortedComparable
SortedComparable<User, String>((user) => user.lastName)

Sorts items by the mapped property value using Comparable.compare which is basically a.compareTo(b). Sorts strings alphabetically, numbers ascending, etc.

SortedComparator
SortedComparator<Auction, String>(
  (auction) => auction.buyerContext.status,
  (a, b) =>  /* your custom compare function */,
)

Sorts items by the mapped property value using a custom comparator provided as a second argument.

श्रेणियाँ

निर्भरताएँ

निर्भरता सूची 1 आइटम

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

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

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