qbcps_flutter 1.0.0 icon indicating copy to clipboard operation
qbcps_flutter: ^1.0.0 copied to clipboard

A collection of utility classes for testing and offline development.

example/qbcps_flutter_example.dart

import 'package:qbcps_flutter/qbcps_flutter.dart';
import 'package:tuple/tuple.dart';

/// Example code showing how to use [MapDB]

void main() {
  var stringDatabase = MapDB<String, String>();

  stringDatabase.getChangeStream().listen((Tuple2<String, String?> data) {
    print(
        'Change stream just reported that key: ${data.item1} was assigned value: ${data.item2}');
  });

  stringDatabase.getChangesForKey('A_Key').listen((String? value) {
    print('Change stream for key `A_Key` reports value: `$value`');
  });

  var oldValue = stringDatabase.put('A_Key', 'A_value');
  print("The freshly created MapDB contained '$oldValue' for key 'A_Key'");

  var freshlySetValue = stringDatabase.get('A_Key');
  print("Fetched value $freshlySetValue for key 'A_Key'");

  // both change streams will emit a data event for this
  stringDatabase.put('A_Key', 'A_second_value');

  // only the database change stream (not the change stream for key 'A_Key') will emit data for this
  stringDatabase.put('B_Key', 'B_value');

  stringDatabase.delete('A_Key');
}
2
likes
140
pub points
50%
popularity

Publisher

unverified uploader

A collection of utility classes for testing and offline development.

Repository (GitHub)

Documentation

API reference

License

Icon for licenses.MIT (LICENSE)

Dependencies

tuple

More

Packages that depend on qbcps_flutter