notifiable_iterables 0.0.1 notifiable_iterables: ^0.0.1 copied to clipboard
Provides iterables that implements the ChangeNotifier class.
notifiable_iterables #
Provides iterables that implements the ChangeNotifier
class.
GitHub: https://github.com/Cynnexis/notifiable_iterables
Getting Started #
Installation #
This package is not on pub.dev yet.
If you want to install it locally on your machine, follow the following steps:
- Clone this project wherever you want on your computer:
git clone https://github.com/Cynnexis/notifiable_iterables.git
- In your flutter project, add the following snippet in your
pubspec.yaml
:
If you have problems at the step, please check thedependencies: notifiable_iterables: path: path/to/notifiable_iterables
pubspec.yaml
of the example. - Open a terminal in your flutter project directory, and enter
pub get
.
Running the Example #
The example/
directory contains an Android Studio project that uses notifiable_iterables
.
To make it run, open the project using Android Studio to launch the configuration example.
If you don't have Android Studio, please open a terminal in the example
project directory, and execute the following lines:
# Get the dependencies
pub get
# Check that a device is connected to this computer
flutter devices
# Run the example
flutter run
Usage #
To use this library, you need to import it in your dart file:
import 'package:notifiable_iterables/notifiable_iterables.dart';
Then, you can use the following classes:
NotifiableList<E>
: A notifiable list. It has the same functions asList<E>
.NotifiableSet<E>
: A notifiable set. It has the same functions asSet<E>
.NotifiableMap<K, V>
: A notifiable map. It has the same functions asMap<K, V>
.
Those classes can be uses exactly like their iterable equivalent.
Example:
// Create a notifiable list
NotifiableList<int> list = NotifiableList<int>.of(<int>[0, 1, 2, 3]);
print(list[2].toString()); // prints "2"
// Add a listener
list.addListener(() => print("New list: $list"));
// Change the list
list[3] = 4; // Notify the listeners, the console will show the updated list
Build With #
Author #
- Valentin Berger (Cynnexis): developer
License #
This project is under the BSD License. Please see the LICENSE.txt file for more detail (it's a really fascinating story written in there!)