Skip to content

Commit 90380d2

Browse files
committed
Release 4.3.2.
1 parent 33f9d60 commit 90380d2

File tree

4 files changed

+74
-5
lines changed

4 files changed

+74
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 4.3.2
4+
5+
- Add an `example` folder with some example code.
6+
37
## 4.3.1
48

59
- Internal: cleanup for pedantic v1.9.0 lints.

example/example.dart

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright (c) 2020, Google Inc. Please see the AUTHORS file for details.
2+
// All rights reserved. Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
import 'package:built_collection/built_collection.dart';
6+
7+
void main() {
8+
// `built_collection` provides immutable equivalents of Dart SDK `List`,
9+
// `Set` and `Map`: `BuiltList`, `BuiltSet` and `BuiltMap`.
10+
11+
// The easiest way to create them is from collection literals using `build`:
12+
var builtList = [1, 2, 3].build();
13+
var builtSet = {1, 2, 3}.build();
14+
var builtMap = {1: 'one', 2: 'two', 3: 'three'}.build();
15+
16+
// `BuiltList` and `BuiltSet` can also be constructed from any `Iterable`.
17+
// The unnamed constructors act like the SDK `from` constructors, meaning
18+
// the elements are type checked at runtime.
19+
builtList = BuiltList([1, 2, 3]);
20+
builtSet = BuiltSet([1, 2, 3]);
21+
22+
// Alternatively, the `of` constructors match the type to the `Iterable` you
23+
// pass, and so do not need to check the type of elements.
24+
builtList = BuiltList.of([1, 2, 3]);
25+
builtSet = BuiltSet.of([1, 2, 3]);
26+
27+
// `BuiltMap` can be constructed from a `Map` or a `BuiltMap`.
28+
builtMap = BuiltMap({1: 'one', 2: 'two', 3: 'three'});
29+
30+
// Immutable collections can't be updated, but you can create new instances
31+
// based on existing ones. The most convenient way to do that is the
32+
// `rebuild` methods, which give you access to each collection type's
33+
// corresponding builder type.
34+
35+
// For example, to add some elements then sort:
36+
builtList = builtList.rebuild((b) => b
37+
..addAll([7, 6, 5])
38+
..sort());
39+
40+
// Generally, built collections match the SDK collections, except that the
41+
// API has been split in two: read only methods go on the `Built` collection
42+
// types, and mutating methods go on the corresponding `Builder` types.
43+
44+
// If you need to keep a mutable version of the collection around for a
45+
// while, for example to pass it to other methods, you can use `toBuilder`.
46+
// Then, later, the collection is made immutable again by calling `build`.
47+
var listBuilder = builtList.toBuilder();
48+
listBuilder.addAll([10, 9, 8]);
49+
// More changes could go here, including passing the builder to other
50+
// methods.
51+
builtList = listBuilder.build();
52+
53+
// Finally, `built_collection` also provides immutable versions of
54+
// `ListMultimap` and `SetMultimap` from `package:quiver`. For information
55+
// on these, and full details on all the APIs, please see the package
56+
// [dartdoc](https://pub.dev/documentation/built_collection/latest).
57+
}

example/pubspec.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: example
2+
version: 0.0.1
3+
description: >
4+
Example, not for publishing.
5+
homepage: https://github.com/google/built_collection.dart
6+
7+
environment:
8+
sdk: '>=2-0-0-dev <3.0.0'
9+
10+
dependency_overrides:
11+
built_collection:
12+
path: ..

pubspec.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
name: built_collection
2-
version: 4.3.1
2+
version: 4.3.2
33
description: >
44
Immutable collections based on the SDK collections. Each SDK collection class
55
is split into a new immutable collection class and a corresponding mutable
66
builder class.
7-
authors:
8-
- David Morgan <[email protected]>
9-
- Matan Lurey <[email protected]>
10-
- Philipp Schiffmann <[email protected]>
117
homepage: https://github.com/google/built_collection.dart
128

139
environment:

0 commit comments

Comments
 (0)