zone_local 0.1.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 97

Pub Package Github Actions CI

Introduction #

What's a zone? See explanation of zones at dartlang.org.

If you are declaring a static variable, this package gives you:

  • Type-safe zone-scoped mutability
  • Helpful methods for forking zones

Getting Started #

In pubspec.yaml:

dependencies:
  zone_local: ^0.1.2

In main.dart:

import 'package:zone_local/zone_local.dart';

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

void main() {
  print(greeting.value);
  
  // Run a function in a forked zone that sees value "Hi!"
  greeting.forkZoneWithValue("Hi!").run(() {
    print(greeting.value);
  });
}

0.1.2 #

  • Improved documentation
  • Fixed analyzer warnings

example/zone_local.dart

import 'package:zone_local/zone_local.dart';

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

void main() {
  print(greeting.value);

  // Run a function in a forked zone that sees value "Hi!"
  greeting.forkZoneWithValue('Hi!').run(() {
    print(greeting.value);
  });
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  zone_local: ^0.1.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:zone_local/zone_local.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
93
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
97
Learn more about scoring.

We analyzed this package on Apr 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
Dev dependencies
meta ^1.1.0
pedantic ^1.9.0
test ^1.8.0