https://github.com/melbournedeveloper/fixed_collections
Dart collections that you can't modify
https://github.com/melbournedeveloper/fixed_collections
Last synced: 5 months ago
JSON representation
Dart collections that you can't modify
- Host: GitHub
- URL: https://github.com/melbournedeveloper/fixed_collections
- Owner: MelbourneDeveloper
- License: bsd-3-clause
- Created: 2022-07-27T01:06:38.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-09-29T04:57:39.000Z (over 3 years ago)
- Last Synced: 2025-02-06T01:51:23.238Z (about 1 year ago)
- Language: Dart
- Size: 39.1 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# fixed_collections
This library contains fixed (immutable) collections. You pass an `Iterable`, `Set` or `Map` into the constructor and get a collection you cannot modify. More importantly, all the members that modify the list are deprecated, so you get a warning or error at compile time. Use this library with the `deprecated_member_use_from_same_package` [code analysis option](https://dart.dev/guides/language/analysis-options).
## Why Use This Library?
The collections in this library are normal `Lists`, `Sets` and `Maps`, unlike other immutable collections. They implement the interfaces for these. You can pass them around in your app and pass them to external functions that accept these collections as parameters, but if your code mutates the list, you will see warnings.

## Errors
Turn on the rule `deprecated_member_use_from_same_package` by adding it to your `analysis_options.yaml` file. Or, use the [austerity](https://pub.dev/packages/austerity) package to make your Dart experience much more strict.
```yaml
analyzer:
errors:
deprecated_member_use_from_same_package: error
```
If you want a less severe warning, you can use `warning` instead of `error`.
```yaml
analyzer:
errors:
deprecated_member_use_from_same_package: warning
```
Read more about customizing analysis errors [here](https://dart.dev/guides/language/analysis-options#customizing-analysis-rules).