dart2_constant 1.0.2+dart2

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 53

This package is a polyfill for the core library constant names that are changing from Dart 1 to Dart 2.

In Dart 1, all core library constants were in SCREAMING_CAPS. In Dart 2, they're being changed to camelCase. This package makes it possible for packages to support both Dart 1 and Dart 2 by providing camelCase constants that work on all versions of Dart.

This package has a library for each library dart: library that contained constants in Dart 1. These libraries contain only constants, using the Dart 2 names. They should be imported using a prefix so as to avoid colliding with core library names:

import 'package:dart2_constant/convert.dart' as convert;

String decodeUtf8(List<int> bytes) => convert.utf8.decode(bytes);

Note that this even supports constants that haven't yet migrated in the core libraries, such as those in dart:io and dart:html. These are provided for compatibility with future SDK changes.

How It Works

Each version of dart2_constant has two releases, one tagged +dart1 that's only compatible SDKs that have old-style constants and one tagged +dart2 that's only compatible with SDKs that have new-style constants. As long as you depend on dart2_constant, pub's version solver will make sure your users get a version of it that works for them.

See Also

The dart2_fix package can be used to automatically migrate constant references from Dart 1 style to Dart 2 style. It doesn't currently support migrating to dart2_constant references, though.

1.0.2

  • Widen SDK constraint to include 2.0.0.

1.0.1

  • Fix the homepage URL.

1.0.0

  • Initial version.

Use this package as a library

1. Depend on it

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


dependencies:
  dart2_constant: ^1.0.2+dart2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:dart2_constant/async.dart';
import 'package:dart2_constant/convert.dart';
import 'package:dart2_constant/core.dart';
import 'package:dart2_constant/developer.dart';
import 'package:dart2_constant/html.dart';
import 'package:dart2_constant/io.dart';
import 'package:dart2_constant/isolate.dart';
import 'package:dart2_constant/math.dart';
import 'package:dart2_constant/svg.dart';
import 'package:dart2_constant/typed_data.dart';
import 'package:dart2_constant/web_gl.dart';
import 'package:dart2_constant/web_sql.dart';
  
Version Uploaded Documentation Archive
1.0.2+dart2 Aug 3, 2018 Go to the documentation of dart2_constant 1.0.2+dart2 Download dart2_constant 1.0.2+dart2 archive
1.0.1+dart2 Apr 3, 2018 Go to the documentation of dart2_constant 1.0.1+dart2 Download dart2_constant 1.0.1+dart2 archive
1.0.1+dart1 Apr 3, 2018 Go to the documentation of dart2_constant 1.0.1+dart1 Download dart2_constant 1.0.1+dart1 archive
1.0.0+dart2 Apr 2, 2018 Go to the documentation of dart2_constant 1.0.0+dart2 Download dart2_constant 1.0.0+dart2 archive
1.0.0+dart1 Apr 2, 2018 Go to the documentation of dart2_constant 1.0.0+dart1 Download dart2_constant 1.0.0+dart1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
87
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
50
Overall:
Weighted score of the above. [more]
53
Learn more about scoring.

We analyzed this package on Oct 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.4

Platforms

Detected platforms: unsure

Error(s) prevent platform classification:

Error(s) in lib/web_gl.dart: Const variables must be initialized with a constant value.

Health issues and suggestions

Fix lib/web_gl.dart. (-100 points)

Analysis of lib/web_gl.dart failed with 1842 errors, including:

line 7 col 26: Const variables must be initialized with a constant value.

line 7 col 33: The getter 'ACTIVE_ATTRIBUTES' isn't defined for the class 'web_gl'.

line 8 col 23: Const variables must be initialized with a constant value.

line 8 col 30: The getter 'ACTIVE_TEXTURE' isn't defined for the class 'web_gl'.

line 9 col 24: Const variables must be initialized with a constant value.

Fix lib/io.dart. (-50.68 points)

Analysis of lib/io.dart reported 141 hints, including:

line 7 col 17: 'ZLIB' is deprecated and shouldn't be used.

line 8 col 17: 'GZIP' is deprecated and shouldn't be used.

line 11 col 46: 'MIN_WINDOW_BITS' is deprecated and shouldn't be used.

line 12 col 46: 'MAX_WINDOW_BITS' is deprecated and shouldn't be used.

line 13 col 50: 'DEFAULT_WINDOW_BITS' is deprecated and shouldn't be used.

Fix lib/html.dart. (-4.89 points)

Analysis of lib/html.dart reported 10 hints, including:

line 215 col 31: 'XPathResult' is deprecated and shouldn't be used.

line 216 col 44: 'XPathResult' is deprecated and shouldn't be used.

line 217 col 35: 'XPathResult' is deprecated and shouldn't be used.

line 218 col 44: 'XPathResult' is deprecated and shouldn't be used.

line 219 col 34: 'XPathResult' is deprecated and shouldn't be used.

Fix lib/core.dart. (-0.50 points)

Analysis of lib/core.dart reported 1 hint:

line 31 col 16: Name types using UpperCamelCase.

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Error(s) prevent platform classification:

Error(s) in lib/web_gl.dart: Const variables must be initialized with a constant value.

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use dart2_constant.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.34.0 <3.0.0
Dev dependencies
analyzer >=0.30.0 <0.33.0
args ^1.0.0
dart_style ^1.0.0
path ^1.0.0