fancy_collection 0.1.0 copy "fancy_collection: ^0.1.0" to clipboard
fancy_collection: ^0.1.0 copied to clipboard

Observable List and Map implementations for Flutter that notify listeners about added, updated and removed entries, including changes in nested collections.

example/main.dart

// ignore_for_file: avoid_print

import 'package:fancy_collection/fancy_collection.dart';

void main() {
  final cart = FancyMap<String, dynamic>();

  cart.addListener(
    '*',
    FancyCollectionValueChangeListener(
      onCollectionEvent:
          (event) =>
              print('${event.type?.name.padRight(6)} ${event.attributePath}'),
    ),
  );

  cart['customer'] = {'name': 'Ada'};
  cart['items'] = <dynamic>[];

  cart.addListener(
    'items[*]',
    FancyCollectionValueChangeListener(
      listensFor: FancyCollectionEventType.add,
      onCollectionEvent: (event) => print('  -> new item: ${event.value}'),
    ),
  );

  final items = cart['items'] as FancyList;
  items.add('Keyboard');
  items.add('Mouse');
  items.removeLast();

  (cart['customer'] as FancyMap)['name'] = 'Grace';
  cart.remove('customer');
}
0
likes
160
points
366
downloads

Documentation

API reference

Publisher

verified publisherdualware.com

Weekly Downloads

Observable List and Map implementations for Flutter that notify listeners about added, updated and removed entries, including changes in nested collections.

Repository (GitHub)
View/report issues
Contributing

Topics

#collections #observable #state-management #listener

License

MIT (license)

Dependencies

flutter

More

Packages that depend on fancy_collection