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

Overview

Quiver

Quiver is 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

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 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.mirrors

getTypeName returns the name of a Type instance.

implements and classImplements determine if an instance or ClassMirror, respectively, implement the interface represented by a Type instance. They implement the behavior of is for mirrors, except for generics.

getMemberMirror searches though a ClassMirror and its class hierarchy for a member. This makes up for the fact that ClassMirror.members doesn't contain members from interfaces or superclasses.

Method wraps an InstanceMirror and Symbol to create a callable that invokes a method on the instance. It in effect closurizes a method reflectively.

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.

Comments
  • Add FakeClock

    Add FakeClock

    This is similar to:

    http://sinonjs.org/docs/#clock

    (I think this could replace CreateTimer and CreateTimerPeriodic, which IMO exposes too much of the internal implementation of whatever is taking it is a dependency.)

    enhancement 
    opened by seaneagan 50
  • Clarify what should be in quiver.async vs quiver.streams

    Clarify what should be in quiver.async vs quiver.streams

    quiver.streams was supposed to be a Stream equivalent of quiver.iterables, but it has things with no equivalent and/or that don't work on a Stream or collection of Streams (like how quiver.iterables works on ... Iterables) like collect and StreamBuffer. It's possible we want to move those to quiver.async.

    question 
    opened by justinfagnani 15
  • Deprecate Optional

    Deprecate Optional

    With the introduction of non-null by default in Dart SDK 2.12, existing users should migrate to non-nullable types. This type will be removed in Quiver 4.0.0.

    See: #666

    cleanup cla: yes nnbd 
    opened by cbracken 13
  • String Additions

    String Additions

    String capitalization. Index-based insertion, replacement, and removal. Similar implementation of C# String.Format(..) to allow for terse index-based string interpolation without needing to use a literal with '$var' at the time of interpolation.

    enhancement 
    opened by ghost 13
  • Add Optional.transformNullable.

    Add Optional.transformNullable.

    This lets callers chain maybe-present values through transformers with a nullable return value.

    The existing Optional.transform throws an ArgumentException if the transformer returns null. Would be great to have an API that returns absent() if the transformer returns null.

    I added this as a new function for backwards compatibility sake, but I'd argue that Optional.transform should have this behavior -- depends on what your policy is for breaking changes.

    Inspiration taken from Java 8's Optional#map:

    If a value is present, apply the provided mapping function to it, and if the result is non-null, return an Optional describing the result. Otherwise return an empty Optional.

    opened by mfiels 10
  • Strong-mode analysis errors prevent DDC compilation

    Strong-mode analysis errors prevent DDC compilation

    The following list of strong-mode errors prevent code that depend on package:quiver from being compiled with DDC.

    (ran dartanalyzer --strongfind lib -name '*.dart'| sort -u with SDK version 1.16.0-dev.0.0)

    [error] Base class introduces an invalid override. The type of DelegatingIterable.expand (((E) → Iterable<dynamic>) → Iterable<dynamic>) is not a subtype of Iterable<E>.expand (<T>((E) → Iterable<T>) → Iterable<T>). (./lib/src/collection/delegates/list.dart, line 29, col 34)
    [error] Base class introduces an invalid override. The type of DelegatingIterable.expand (((E) → Iterable<dynamic>) → Iterable<dynamic>) is not a subtype of Iterable<E>.expand (<T>((E) → Iterable<T>) → Iterable<T>). (./lib/src/collection/delegates/queue.dart, line 29, col 35)
    [error] Base class introduces an invalid override. The type of DelegatingIterable.expand (((E) → Iterable<dynamic>) → Iterable<dynamic>) is not a subtype of Iterable<E>.expand (<T>((E) → Iterable<T>) → Iterable<T>). (./lib/src/collection/delegates/set.dart, line 29, col 33)
    [error] Base class introduces an invalid override. The type of DelegatingIterable.fold ((dynamic, (dynamic, E) → dynamic) → dynamic) is not a subtype of Iterable<E>.fold (<T>(T, (T, E) → T) → T). (./lib/src/collection/delegates/list.dart, line 29, col 34)
    [error] Base class introduces an invalid override. The type of DelegatingIterable.fold ((dynamic, (dynamic, E) → dynamic) → dynamic) is not a subtype of Iterable<E>.fold (<T>(T, (T, E) → T) → T). (./lib/src/collection/delegates/queue.dart, line 29, col 35)
    [error] Base class introduces an invalid override. The type of DelegatingIterable.fold ((dynamic, (dynamic, E) → dynamic) → dynamic) is not a subtype of Iterable<E>.fold (<T>(T, (T, E) → T) → T). (./lib/src/collection/delegates/set.dart, line 29, col 33)
    [error] Base class introduces an invalid override. The type of DelegatingIterable.map (((E) → dynamic) → Iterable<dynamic>) is not a subtype of Iterable<E>.map (<T>((E) → T) → Iterable<T>). (./lib/src/collection/delegates/list.dart, line 29, col 34)
    [error] Base class introduces an invalid override. The type of DelegatingIterable.map (((E) → dynamic) → Iterable<dynamic>) is not a subtype of Iterable<E>.map (<T>((E) → T) → Iterable<T>). (./lib/src/collection/delegates/queue.dart, line 29, col 35)
    [error] Base class introduces an invalid override. The type of DelegatingIterable.map (((E) → dynamic) → Iterable<dynamic>) is not a subtype of Iterable<E>.map (<T>((E) → T) → Iterable<T>). (./lib/src/collection/delegates/set.dart, line 29, col 33)
    [error] Base class introduces an invalid override. The type of _WrappedIterable.expand (((V) → Iterable<dynamic>) → Iterable<dynamic>) is not a subtype of Iterable<V>.expand (<T>((V) → Iterable<T>) → Iterable<T>). (./lib/src/collection/multimap.dart, line 531, col 26)
    [error] Base class introduces an invalid override. The type of _WrappedIterable.expand (((V) → Iterable<dynamic>) → Iterable<dynamic>) is not a subtype of Iterable<V>.expand (<T>((V) → Iterable<T>) → Iterable<T>). (./lib/src/collection/multimap.dart, line 684, col 25)
    [error] Base class introduces an invalid override. The type of _WrappedIterable.fold ((dynamic, (dynamic, V) → dynamic) → dynamic) is not a subtype of Iterable<V>.fold (<T>(T, (T, V) → T) → T). (./lib/src/collection/multimap.dart, line 531, col 26)
    [error] Base class introduces an invalid override. The type of _WrappedIterable.fold ((dynamic, (dynamic, V) → dynamic) → dynamic) is not a subtype of Iterable<V>.fold (<T>(T, (T, V) → T) → T). (./lib/src/collection/multimap.dart, line 684, col 25)
    [error] Base class introduces an invalid override. The type of _WrappedIterable.map (((V) → dynamic) → Iterable<dynamic>) is not a subtype of Iterable<V>.map (<T>((V) → T) → Iterable<T>). (./lib/src/collection/multimap.dart, line 531, col 26)
    [error] Base class introduces an invalid override. The type of _WrappedIterable.map (((V) → dynamic) → Iterable<dynamic>) is not a subtype of Iterable<V>.map (<T>((V) → T) → Iterable<T>). (./lib/src/collection/multimap.dart, line 684, col 25)
    [error] Invalid override. The type of DelegatingIterable.expand (((E) → Iterable<dynamic>) → Iterable<dynamic>) is not a subtype of Iterable<E>.expand (<T>((E) → Iterable<T>) → Iterable<T>). (./lib/src/collection/delegates/iterable.dart, line 41, col 3)
    [error] Invalid override. The type of DelegatingIterable.fold ((dynamic, (dynamic, E) → dynamic) → dynamic) is not a subtype of Iterable<E>.fold (<T>(T, (T, E) → T) → T). (./lib/src/collection/delegates/iterable.dart, line 48, col 3)
    [error] Invalid override. The type of DelegatingIterable.map (((E) → dynamic) → Iterable<dynamic>) is not a subtype of Iterable<E>.map (<T>((E) → T) → Iterable<T>). (./lib/src/collection/delegates/iterable.dart, line 68, col 3)
    [error] Invalid override. The type of InfiniteIterable.fold ((dynamic, (dynamic, T) → dynamic) → bool) is not a subtype of Iterable<T>.fold (<T₀>(T₀, (T₀, T) → T₀) → T₀). (./lib/src/iterables/infinite_iterable.dart, line 34, col 3)
    [error] Invalid override. The type of LinkedLruHashMap.[] ((K) → V) is not a subtype of Map<K, V>.[] ((Object) → V). (./lib/src/collection/lru_map.dart, line 196, col 3)
    [error] Invalid override. The type of LinkedLruHashMap.containsKey ((K) → bool) is not a subtype of Map<K, V>.containsKey ((Object) → bool). (./lib/src/collection/lru_map.dart, line 105, col 3)
    [error] Invalid override. The type of LinkedLruHashMap.containsValue ((V) → bool) is not a subtype of Map<K, V>.containsValue ((Object) → bool). (./lib/src/collection/lru_map.dart, line 108, col 3)
    [error] Invalid override. The type of LinkedLruHashMap.remove ((K) → V) is not a subtype of Map<K, V>.remove ((Object) → V). (./lib/src/collection/lru_map.dart, line 225, col 3)
    [error] Invalid override. The type of StreamBuffer.addStream ((Stream<T>) → Future<dynamic>) is not a subtype of StreamConsumer<dynamic>.addStream ((Stream<dynamic>) → Future<dynamic>). (./lib/src/async/stream_buffer.dart, line 142, col 3)
    [error] Invalid override. The type of _WrappedIterable.expand (((V) → Iterable<dynamic>) → Iterable<dynamic>) is not a subtype of Iterable<V>.expand (<T>((V) → Iterable<T>) → Iterable<T>). (./lib/src/collection/multimap.dart, line 410, col 3)
    [error] Invalid override. The type of _WrappedIterable.fold ((dynamic, (dynamic, V) → dynamic) → dynamic) is not a subtype of Iterable<V>.fold (<T>(T, (T, V) → T) → T). (./lib/src/collection/multimap.dart, line 425, col 3)
    [error] Invalid override. The type of _WrappedIterable.map (((V) → dynamic) → Iterable<dynamic>) is not a subtype of Iterable<V>.map (<T>((V) → T) → Iterable<T>). (./lib/src/collection/multimap.dart, line 470, col 3)
    [error] Type check failed: _id ((dynamic) → dynamic) is not of type (dynamic) → K (./lib/src/collection/multimap.dart, line 161, col 13)
    [error] Type check failed: _id ((dynamic) → dynamic) is not of type (dynamic) → V (./lib/src/collection/multimap.dart, line 162, col 15)
    [hint] 'FakeTimer' is deprecated (./lib/testing/src/async/async.dart, line 36, col 3)
    [hint] 'padLeft' is deprecated (./lib/strings.dart, line 244, col 19)
    [hint] 'padRight' is deprecated (./lib/strings.dart, line 244, col 10)
    [hint] The value of the local variable 'run' is not used (./lib/testing/src/equality/equality.dart, line 97, col 14)
    [hint] The value of the local variable 'string' is not used (./lib/testing/src/runtime/checked_mode.dart, line 36, col 12)
    [warning] Missing concrete implementation of 'Iterable.expand', 'Iterable.fold' and 'Iterable.map' (./lib/src/collection/multimap.dart, line 531, col 7)
    [warning] Missing concrete implementation of 'Iterable.expand', 'Iterable.fold' and 'Iterable.map' (./lib/src/collection/multimap.dart, line 684, col 7)
    [warning] The getter '_left' is not defined for the class '_TreeNode<V>'. (./lib/src/collection/treeset.dart, line 151, col 47)
    [warning] The getter 'length' is not defined for the class 'Object'. (./lib/src/async/stream_buffer.dart, line 152, col 41)
    [warning] The method 'add' is not defined for the class 'Object'. (./lib/src/async/stream_router.dart, line 72, col 16)
    [warning] The method 'compareTo' is not defined for the class 'Object'. (./lib/src/collection/treeset.dart, line 32, col 32)
    [warning] The redirected constructor '({maximumSize: int}) → LinkedLruHashMap<dynamic, dynamic>' has incompatible parameters with '({maximumSize: int}) → LruMap<K, V>' (./lib/src/collection/lru_map.dart, line 32, col 39)
    [warning] The return type 'bool' is not assignable to 'T' as required by the method it is overriding from 'Iterable' (./lib/src/iterables/infinite_iterable.dart, line 34, col 8)
    [warning] Unsound implicit cast from (K, C) → void to (K, Iterable<V>) → void (./lib/src/collection/multimap.dart, line 352, col 64)
    [warning] Unsound implicit cast from (dynamic) → void to (Timer) → void (./lib/async.dart, line 53, col 34)
    [warning] Unsound implicit cast from Completer<dynamic> to Completer<List<T>> (./lib/src/async/stream_buffer.dart, line 137, col 54)
    [warning] Unsound implicit cast from Converter<List<int>, String> to StreamTransformer<List<int>, dynamic> (./lib/io.dart, line 28, col 27)
    [warning] Unsound implicit cast from Future<dynamic> to Future<List<T>> (./lib/src/async/stream_buffer.dart, line 138, col 12)
    [warning] Unsound implicit cast from Future<dynamic> to Future<Stream<T>> (./lib/src/async/future_stream.dart, line 42, col 15)
    [warning] Unsound implicit cast from List<dynamic> to List<T> (./lib/src/async/stream_buffer.dart, line 118, col 12)
    [warning] Unsound implicit cast from Map<K, Iterable<V>> to Map<dynamic, List<V>> (./lib/src/collection/multimap.dart, line 280, col 24)
    [warning] Unsound implicit cast from Map<dynamic, dynamic> to Map<String, List<dynamic>> (./lib/testing/src/equality/equality.dart, line 98, col 27)
    [warning] Unsound implicit cast from Map<dynamic, dynamic> to Map<String, List<dynamic>> (./lib/testing/src/equality/equality.dart, line 99, col 32)
    [warning] Unsound implicit cast from Object to V (./lib/src/collection/treeset.dart, line 441, col 29)
    [warning] Unsound implicit cast from Object to V (./lib/src/collection/treeset.dart, line 633, col 20)
    [warning] Unsound implicit cast from Object to V (./lib/src/collection/treeset.dart, line 693, col 28)
    [warning] Unsound implicit cast from Object to V (./lib/src/collection/treeset.dart, line 954, col 38)
    [warning] Unsound implicit cast from Object to V (./lib/src/collection/treeset.dart, line 960, col 51)
    [warning] Unsound implicit cast from Object to V (./lib/src/collection/treeset.dart, line 968, col 38)
    [warning] Unsound implicit cast from Object to V (./lib/src/collection/treeset.dart, line 974, col 51)
    [warning] Unsound implicit cast from StreamSubscription<dynamic> to StreamSubscription<DateTime> (./lib/src/async/metronome.dart, line 89, col 7)
    [warning] Unsound implicit cast from dynamic to (T) → T (./lib/src/iterables/generating_iterable.dart, line 57, col 66)
    [warning] Unsound implicit cast from dynamic to Iterable<Match> (./lib/pattern.dart, line 67, col 38)
    [warning] Unsound implicit cast from dynamic to Iterable<T> (./lib/src/iterables/cycle.dart, line 42, col 21)
    [warning] Unsound implicit cast from dynamic to Iterable<V> (./lib/src/collection/multimap.dart, line 225, col 12)
    [warning] Unsound implicit cast from dynamic to Iterator<T> (./lib/src/iterables/cycle.dart, line 43, col 21)
    [warning] Unsound implicit cast from dynamic to T (./lib/src/iterables/generating_iterable.dart, line 57, col 55)
    [warning] Unsound implicit cast from dynamic to T (./lib/src/iterables/generating_iterable.dart, line 74, col 16)
    [warning] Unsound implicit cast from dynamic to V (./lib/src/cache/map_cache.dart, line 41, col 23)
    [warning] Unsound implicit cast from dynamic to V (./lib/src/cache/map_cache.dart, line 42, col 18)
    [warning] Unsound implicit cast from dynamic to V (./lib/src/cache/map_cache.dart, line 45, col 21)
    [warning] Unsound implicit cast from dynamic to V (./lib/src/collection/treeset.dart, line 802, col 40)
    
    opened by ochafik 10
  • Add Interval class

    Add Interval class

    This still needs docs and a bit of formatting cleanup, but the tests are extensive, so it should be ready for general feedback.

    Main inspirations for this were:

    http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/collect/Range.html http://en.wikipedia.org/wiki/Interval_(mathematics)

    I put it in quiver.compare since I also want to add stuff from #60 there. quiver.comparables could also work, but that might not make as much sense if Interval or other functionality works with arbitrary Comparators instead of requing Comparables. quiver.math is another option.

    I deprecated quiver.iterables.extent(iterable) in favor of new Interval.span(iterable).

    enhancement 
    opened by seaneagan 10
  • Add quiver.streams with enumerate method

    Add quiver.streams with enumerate method

    I originally implemented this for a demo of one of my projects:

    https://github.com/seaneagan/unscripted/blob/master/example/cat.dart

    and thought it would make sense to add it back to quiver.

    If quiver.iterables and quiver.async both use IndexedValue it might make sense to move it to quiver.core, but I didn't do that here.

    opened by seaneagan 9
  • Add

    Add "base" library. Add checked mode tester.

    My first pull request, please take a look.

    Three things for discussion:

    • The "base" library / name. A place for code that looks like or deals with language built in features, e.g. utilities for Object, the "Optional" type.
    • Where to put the checked mode check. I'm suggesting that it fits under "should be part of the language", hence putting it in base. Another idea was a new library called "testing", but I worry that such a library will accumulate code that does not belong in production code, whereas this check might be needed anywhere.
    • Testing the checked mode check. This is awkward as the test needs to know whether checks are enabled ... it looks like the editor runs the tests with checked mode enabled, so that's what the test expects. Is there any way to control this? How are the tests expected to be run?

    Thanks!

    opened by davidmorgan 9
  • Slow down breaking releases?

    Slow down breaking releases?

    Quiver is big and it's used a little bit by a lot of packages.

    Handling each update is a pain across a lot of packages.

    Could we slow them down a bit? Chunk breaks into bigger, but less frequent updates?

    CC @cbracken

    opened by kevmoo 8
  • added #indexOf to collection.dart

    added #indexOf to collection.dart

    Here is an example use case: cs/piper///depot/google3/ads/awapps2/shared/ad_group_criterion/lib/ad_group_criterion_mutate_helper.dart?l=38

    There are many others.

    enhancement 
    opened by willyp564 8
  • Bump actions/checkout from 3.1.0 to 3.2.0

    Bump actions/checkout from 3.1.0 to 3.2.0

    Bumps actions/checkout from 3.1.0 to 3.2.0.

    Release notes

    Sourced from actions/checkout's releases.

    v3.2.0

    What's Changed

    New Contributors

    Full Changelog: https://github.com/actions/checkout/compare/v3...v3.2.0

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • FakeAsync is passing a test after throw UnimplementedError

    FakeAsync is passing a test after throw UnimplementedError

    Hello, this is my test.

    test('Join assembly post a join request in server', () {                            
      FakeAsync().run((async) async {                                                   
        final membersDao = MockAssemblyMembersDao();                                    
        final membersApiClient = MockAssemblyMembersApiClient();                        
        final assemblyRequestDao = MockAssemblyJoin RequestsDao();                      
        final userDao = MockUserDao();                                                  
        when(() => membersApiClient.postJoinRequest(any())).thenAnswer(                 
          (invocation) => Future(                                                       
            () => HttpResponse(                                                         
              '',                                                                       
              Response(                                                                 
                requestOptions: RequestOptions(                                         
                  path: '',                                                             
                ), // RequestOptions                                                    
                statusCode: 201), // Response                                           
            ), // HttpResponse                                                          
          ), // Future                                                                  
        );                                                                              
        final membersRepository = AssemblyMembersRepository(                            
          assemblyMembersDao: membersDao,                                               
          assemblyMembersApiClient: membersApiClient,                                   
          assemblyJoinRequestsDao: assemblyRequestDao,                                  
          userDao: userDao);                                                            
        var result = await membersRepository.postJoinRequest('uuid');                   
        expect(result, isA>());                                                         
      });                                                                               
    );
    

    And this is the not yet implemented method:

    Future<Either<RestFailure, Assembly>> postJoinRequest(String uuidCode) async {
      throw UnimplementedError();
    }
    

    The test unexpectedly pass instead to show me an error and mark itself red. image

    awaiting response 
    opened by omensight 1
  • day which is xth [weekDay] from yth [week] of zth [month] of a [year]

    day which is xth [weekDay] from yth [week] of zth [month] of a [year]

    return the day which is xth [weekDay] from yth [week] of zth [month] of a [year] eg. DateTime.Friday from the 2nd week of DateTime.July of the 2022 year.

    [weekDay] ranges from 1 to 7. 1 = Monday and 7 = Sunday. [week] ranges from 1 to 4 or 5 months depending upon the month. ranges from 1 to 12. 1 is January and 12 is December. the year in which you are calculating

    opened by stha-ums 0
  • More efficient `isBlank` check (probably)

    More efficient `isBlank` check (probably)

    Hi, thank you for the awesome library.

    I noticed that isBlank is implemented as:

    https://github.com/google/quiver-dart/blob/d9bf68e2e6d9c6b5d1bbbfb2e89e691833e6789f/lib/strings.dart#L19

    I am new to Dart (learning it for Flutter) and expect that trim will create a new String to check if it is blank. Is my assumption correct? I cannot confirm this in code since String is abstract, and I could not find an implementation of it (I think it's implemented like a native method in Java, though :smile: ).

    Would you accept a PR that avoids the new string creation by checking if each code point of the original string is whitespace?

    The implementation I have locally is the following:

    
    /// Set with whitespace character points.
    /// ```plaintext
    ///     0009..000D    ; White_Space # Cc   <control-0009>..<control-000D>
    ///     0020          ; White_Space # Zs   SPACE
    ///     [cut for brevity...] 
    ///     FEFF          ; BOM                ZERO WIDTH NO_BREAK SPACE
    /// ```
    const whitespaces = <int>{
      0x0009,
      0x000A,
      0x000B,
      0x000C,
      0x000D,
      0x0020,
      0x0085,
      0x00A0,
      0x1680,
      0x2000,
      0x2001,
      0x2002,
      0x2003,
      0x2004,
      0x2005,
      0x2006,
      0x2007,
      0x2008,
      0x2009,
      0x200A,
      0x2028,
      0x2029,
      0x202F,
      0x205F,
      0x3000,
      0xFEFF,
    };
    
    bool isBlank(String? val) {
      if (val == null) return true;
    
      return val.codeUnits.every((element) => whitespaces.contains(element));
    }
    
    

    Here are some incomplete tests (imports are from Flutter; thus, they would need a replacement from the tests package):

    void main() {
      test('Passing null to isBlank returns true', () {
        expect(isBlank(null), isTrue);
      });
    
      test('Passing non empty string to isBlank returns false', () {
        expect(isBlank('abc'), isFalse);
      });
    
      test('Passing empty string to isBlank returns true', () {
        expect(isBlank(''), isTrue);
      });
    
      test('Passing blank string to isBlank returns true', () {
        expect(isBlank(' '), isTrue);
      });
    }
    
    

    It's surely a bit long and verbose, but I don't think it's hard to understand. What do you think about it? One problem that might arise in the future will be if new codepoints in Unicode become whitespaces, which will require a code change in this library.

    opened by niktekusho 0
Releases(3.1.0)
Owner
Google
Google ❤️ Open Source
Google
🔍 👀 CLI utility to check last-visit of your CodeForces friends & much more, 🚀 powered by CodeForces API

JoJo ?? ?? CLI utility to check last-visit of your CodeForces friends & much more, ?? powered by CodeForces API Features Online Friends All Friends Pr

Tirth 5 Jul 20, 2020
The convenient enum of 256 colors for console

The convenient enum of 256 colors for console. Console Color gives the color code for the console an easily recognizable name.

Kato Shinya 1 Mar 2, 2022
Dependency Injection is a great design pattern that allows us to eliminate rigid dependencies between elements and it makes the application more flexible

GetX lib DI pattern Dependency Injection is a great design pattern that allows us to eliminate rigid dependencies between elements and it makes the ap

Trương Việt Hoàng 4 Feb 1, 2022
Fluro is a Flutter routing library that adds flexible routing options like wildcards, named parameters and clear route definitions.

Fluro is a Flutter routing library that adds flexible routing options like wildcards, named parameters and clear route definitions.

Luke Pighetti 3.5k Jan 4, 2023
Easy to use session wrapper that adds support to session storage and management in flutter.

flutter_session_manager Adds an easy to use wrapper to session management in flutter. Allows for easy session storage and management. The session pers

Eduardo Migueis 2 Feb 15, 2022
A simple Flutter / Dart Utility class for converting complex objects to uri and query string

A simple Flutter / Dart Utility class for converting complex or nested objects to uri and query strings you can follow the the article on how this cla

Opata Joshua 5 Sep 7, 2022
Uproot(uprt) is a multi-platform (Windows, MacOs, and Linux) command line utility written in Dart to convert a router's DHCP IP Reservations between routers

UPROOT Uproot(uprt) is a multi-platform (Windows, MacOs, and Linux) command line utility written in Dart to convert a router's DHCP IP Reservations be

GeekVisit 73 Jan 1, 2023
A Dart testing utility for asserting that some code emits a compilation error.

A Dart testing utility for asserting that some code emits a compilation error.

Remi Rousselet 32 Dec 11, 2022
A Pure Dart Utility library that checks for an Active Internet connection

This Code comes from https://github.com/komapeb/data_connection_checker * ?? Internet Connection Checker A Pure Dart Utility library that checks for a

Rounak Tadvi 61 Nov 25, 2022
A collection of flutter and dart libraries allowing you to consume complex external forms at runtime.

flutter_dynamic_forms A collection of flutter and dart libraries providing a solution for Server Driven UI in your Flutter application. Package Pub ex

Ondřej Kunc 193 Dec 20, 2022
This is app includes many app.

drawer A new Flutter application. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if th

rudani jemin 6 Oct 1, 2021
A generator to create config class from json files that support many environments

A generator to create config class from json files that support many environments. Motivation If you use a json file to config your applications, perp

Diego Cardenas 0 Oct 9, 2021
A flutter utility to easily create flavors in your flutter application

Flutter Flavorizr A flutter utility to easily create flavors in your flutter application Getting Started Let's start by setting up our environment in

Angelo Cassano 268 Jan 1, 2023
CLI utility to manage MC Server installations

CLI utility to manage MC server installations. Features Install required JDKs Download server files Generate start scripts (with optimized JVM flags)

Michael Rittmeister 14 Nov 18, 2022
Utility to process H264 profile-level-id values

h264_profile_level_id Dart utility to process H264 profile-level-id values based on Google's libwebrtc C++ code. API import 'package:h264_profile_leve

Ibragim Abbasov 2 Apr 22, 2022
A utility library to automate mobile emulators.

emulators A utility library to automate mobile emulators. Can be used to automate screenshots on multiple devices. Example project https://github.com/

Tim 21 Nov 13, 2022
An http request client, which supports Manageable Requests Cancellation, Request Policy (Timeout and Retry), Easier Multipart Requests, etc.

A wrapper around Dart's http package, which supports Manageable Requests Cancellation, Request Policy (Timeout and Retry), Easier Multipart Requests, Error Handling, etc.

Iandi Santulus 5 Oct 10, 2021
Utilities to make working with 'Duration's easier.

duration Utilities to make working with 'Duration's easier. NOTE: Use prettyDuration, prettySeconds, prettyMilliseconds instead of printDuration, prin

null 45 Sep 21, 2022
Rows lint contains a set of lint rules for dart projects used by projects at Rows GmbH

Rows lint contains a set of lint rules for dart projects used by projects at Rows GmbH

rows 6 Apr 12, 2022