搜索插件、代码仓与 APP 分类

插件详情v3.2.2

quiver

Quiver 是一组用于 Dart 的实用程序库,可使使用许多 Dart 库更加轻松和方便,或添加额外功能。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
373万
喜欢数
665
Pub 分数
140

安装插件

flutter pub add quiver

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Quiver 是一组用于 Dart 的实用程序库,通过为核心 Dart 库提供便捷的扩展和额外功能来提升开发人员的生产力。它简化了常见的任务,如集合操作、哈希计算、相等性检查以及函数式编程模式。设计轻量且模块化,Quiver 支持多个平台,包括 Android、iOS、Web、macOS、Windows 和 Linux。该包由 Google 维护,并可通过 pub 无缝集成到 Flutter 项目中。非常适合希望使用可重用、经过充分测试的实用工具来简化代码的开发者。

适合场景

  • 简化收集操作
  • 实现自定义相等性和哈希
  • 增强函数式编程
  • 管理不可变数据结构
  • 编写简洁、可读的 Dart 代码
  • 通过实用函数提高可测试性

主要特点

  • 模块化实用工具包
  • 丰富的集合辅助工具
  • 哈希和相等性工具
  • 函数式编程工具
  • 跨平台兼容性
  • 文档齐全且经过测试

适合对象

  • 寻求代码简洁性的Dart开发者
  • 需要强大实用函数的项目
  • 致力于一致代码实践的团队
  • Flutter 应用需要增强的数据处理
  • 开发人员在处理不可变或复杂数据类型时

使用建议

  • 不是完整的框架——仅添加实用工具
  • 某些包可能需要单独导入
  • 仅限实用程序增强,不包括UI组件
  • 如果过度使用,可能会增加依赖范围
  • 根据项目需求有选择地使用最佳

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

A set of utility libraries for Dart that makes using many Dart libraries easier and more convenient, or adds additional functionality.

Build Status Coverage Status Pub

Documentation

API Docs are available.

Main Libraries

quiver.async

Utilities for working with Futures, Streams and async computations.

collect collects the completion events of an Iterable of Futures into a Stream.

enumerate and concat represent Stream versions of the same-named quiver.iterables methods.

StreamBuffer allows for the orderly reading of elements from a stream, such as a socket.

FutureStream turns a Future<Stream> into a Stream which emits the same events as the stream returned from the future.

StreamRouter splits a Stream into multiple streams based on a set of predicates.

CountdownTimer is a simple countdown timer that fires events in regular increments.

Metronome is a self-correcting alternative to Timer.periodic. It provides a simple, tracking periodic stream of DateTime events with optional anchor time.

stringFromByteStream constructs a string from a stream of byte lists.

quiver.cache

Cache is a semi-persistent, asynchronously accessed, mapping of keys to values. Caches are similar to Maps, except that the cache implementation might store values in a remote system, so all operations are asynchronous, and caches might have eviction policies.

MapCache is a Cache implementation backed by a Map.

quiver.check

checkArgument throws ArgumentError if the specified argument check expression is false.

checkListIndex throws RangeError if the specified index is out of bounds.

checkState throws StateError if the specified state check expression is false.

quiver.collection

listsEqual, mapsEqual and setsEqual check collections for equality.

indexOf finds the first index of an item satisfying a predicate.

LruMap is a map that removes the least recently used item when a threshold length is exceeded.

Multimap is an associative collection that maps keys to collections of values.

BiMap is a bidirectional map and provides an inverse view, allowing lookup of key by value.

TreeSet is a balanced binary tree that offers a bidirectional iterator, the ability to iterate from an arbitrary anchor, and 'nearest' search.

quiver.core

Optional is a way to represent optional values without allowing null.

hashObjects, hash2, hash3, and hash4 generate high-quality hashCodes for a list of objects, or 2, 3, or 4 arguments respectively.

quiver.iterables

concat, count, cycle, enumerate, merge, partition, range, and zip create, transform, or combine Iterables in different ways, similar to Python's itertools.

min, max, and extent retrieve the minimum and maximum elements from an iterable.

GeneratingIterable is an easy way to create lazy iterables that produce elements by calling a function. A common use-case is to traverse properties in an object graph, like the parent relationship in a tree.

InfiniteIterable is a base class for Iterables that throws on operations that require a finite length.

quiver.pattern

pattern.dart container utilities for work with Patterns and RegExps.

Glob implements glob patterns that are commonly used with filesystem paths.

matchesAny combines multiple Patterns into one, and allows for exclusions.

matchesFull returns true if a Pattern matches an entire String.

escapeRegex escapes special regex characters in a String so that it can be used as a literal match inside of a RegExp.

quiver.strings

isBlank checks if a string is null, empty or made of whitespace characters.

isNotBlank checks if a string is not null, and not blank.

isEmpty checks if a string is null or empty.

isNotEmpty checks if a string is not null and not empty.

equalsIgnoreCase checks if two strings are equal, ignoring case.

compareIgnoreCase compares two strings, ignoring case.

loop allows you to loop through characters in a string starting and ending at arbitrary indices. Out of bounds indices allow you to wrap around the string, supporting a number of use-cases, including:

  • Rotating: loop('lohel', -3, 2) => 'hello'
  • Repeating, like String's operator*, but with better character-level control, e.g.: loop('la ', 0, 8) => 'la la la' // no trailing space
  • Tailing: loop('/path/to/some/file.txt', -3) => 'txt'
  • Reversing: loop('top', 3, 0) => 'pot'

quiver.time

Clock provides points in time relative to the current point in time, for example: now, 2 days ago, 4 weeks from now, etc. For testability, use Clock rather than other ways of accessing time, like new DateTime(), so that you can use a fake time function in your tests to control time.

Now is a typedef for functions that return the current time in microseconds, since Clock deals in DateTime which only have millisecond accuracy.

aMicrosecond, aMillisecond, aSecond, aMinute, anHour, aDay, and aWeek are unit duration constants to allow writing for example:

  • aDay vs. const Duration(days: 1)
  • aSecond * 30 vs. const Duration(seconds: 30)

Testing Libraries

The Quiver testing libraries are intended to be used in testing code, not production code. It currently consists of fake implementations of some Quiver interfaces.

quiver.testing.async

FakeAsync enables testing of units which depend upon timers and microtasks. It supports fake advancements of time and the microtask queue, which cause fake timers and microtasks to be processed. A Clock is provided from which to read the current fake time. Faking synchronous or blocking time advancement is also supported.

quiver.testing.equality

areEqualityGroups is a matcher that supports testing operator== and hashCode implementations.

quiver.testing.time

FakeStopwatch is a Stopwatch that uses a provided now() function to get the current time.

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目