property_wrapper 0.0.2

  • Readme
  • Changelog
  • Installing
  • 53

Property Wrapper #

Autogenerate code when a global or class variable of a property wrapper type is declared.

Property Wrapper Declaration #

Add property_wrapper as a dependency:
  property_wrapper: ^1.0.0
install ProprtyWrapper:

With pub:

pub get

With flutter:

flutter pub get
Annotate property wrapper class:

To generates code when the variable is global:

${code to generate}
@sealed class ${className}<T> {

To generates code when the variable is a class property:

${code to generate}
@sealed class ${className}<T> {

Property wrappers have one generic type for the value type that they hold.

Specify the code to generate with the parameter of the annotation

In the code to generate, the following markup may be used. These are replaced with the following:

  • ${class} - The name of the containing class. only available for ClassMemberPropertyWrapper.
  • ${private} - If the variable name starts with two _, ${private} is replaced with _, else it is removed.
  • ${name.camelCase} - The name of the variable in camel case.
  • ${name.pascalCase} - The name of the variable in pascal case.
  • ${name.snakeCase} - The name of the variable in snake case.
  • ${type} - The generic type of the variable.
Common usages of markup:

Extend the containing class to add members:

extension StatusEffectable${type}Extension on ${type} {

Extend to an exsisting class to add members:

extension ${private}${name.pascalCase}ZoneExtension on Zone {

Add getter

${type} get ${private}${name.camelCase} => ZoneLocal.get(_${private}${name.camelCase});

Property Value Usage #

Add property_wrapper_generator and build_runner as dev_dependencies
  build_runner: ^1.0.0
  property_wrapper_generator: ^1.0.0
install dependencies:

With pub:

pub get

With flutter:

flutter pub get
Add a part file

dart part '${part}.g.dart';

Declare the variable

If the generated code is to be public:

final _variable  = Type<int>();

If the generated code is to be private:

final __variable  = Type<int>();
Run build_runner to generate the part file.

With pub:

pub run build_runner build

With flutter:

flutter pub run build_runner build

1.0.0 #

  • Initial open-source release of property_wrapper.

Use this package as a library

1. Depend on it

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

  property_wrapper: ^0.0.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:property_wrapper/property_wrapper.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.13

Health issues and suggestions

Document public APIs. (-1 points)

7 out of 7 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and property_wrapper.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
pedantic ^1.9.0 1.9.1
Transitive dependencies
meta 1.2.1