zone_local 0.2.0-nullsafety.1 copy "zone_local: ^0.2.0-nullsafety.1" to clipboard
zone_local: ^0.2.0-nullsafety.1 copied to clipboard

discontinued
outdated

A simple, type-safe package for declaring static variables (for configuration, etc.) that can have zone-scoped values.

Pub Package Github Actions CI

Introduction #

A simple, type-safe package for declaring static variables that may have zone-scoped values. These are similar to ThreadLocal values in programming languages such as Java.

See explanation of zones at dartlang.org.

Getting Started #

1.Add dependency #

In pubspec.yaml:

dependencies:
  zone_local: ^0.2.0-nullsafety.0

2.Usage #

import 'package:zone_local/zone_local.dart';

final ZoneLocal<String> greeting = new ZoneLocal<String>(
  defaultValue: 'Hello!',
);

void main() {
  // This zone sees the default value.
  print(greeting.value); // Hello!

  // Fork a zone that will see a different value when the zoneLocal is accessed.
  final zone = greeting.forkZoneWithValue('Hi!');
  zone.run(() {
    print(greeting.value); // Hi!
  });
}
0
likes
110
pub points
6%
popularity

Publisher

unverified uploader

A simple, type-safe package for declaring static variables (for configuration, etc.) that can have zone-scoped values.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

meta

More

Packages that depend on zone_local