property_wrapper_generator 0.0.2

  • Readme
  • Changelog
  • Installing
  • 46

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:
dependencies:
  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:

@TopLevelPropertyWrapper(r'''
${code to generate}
''')
@sealed class ${className}<T> {
...
}

To generates code when the variable is a class property:

@ClassMemberPropertyWrapper(r'''
${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
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:


dependencies:
  property_wrapper_generator: ^0.0.2

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:property_wrapper_generator/builder.dart';
import 'package:property_wrapper_generator/class_member_property_wrapper_generator.dart';
import 'package:property_wrapper_generator/top_level_property_wrapper_generator.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
1
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
46
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.14

Analysis suggestions

Package not compatible with SDK flutter

Because it is not compatible with any of the supported runtimes: flutter-native, flutter-web

Package not compatible with runtime flutter-native on android

Because:

  • package:property_wrapper_generator/builder.dart that imports:
  • package:source_gen/source_gen.dart that imports:
  • package:source_gen/src/type_checker.dart that imports:
  • dart:mirrors

Package not compatible with runtime flutter-native on ios

Because:

  • package:property_wrapper_generator/builder.dart that imports:
  • package:source_gen/source_gen.dart that imports:
  • package:source_gen/src/type_checker.dart that imports:
  • dart:mirrors

Package not compatible with runtime flutter-native on linux

Because:

  • package:property_wrapper_generator/builder.dart that imports:
  • package:source_gen/source_gen.dart that imports:
  • package:source_gen/src/type_checker.dart that imports:
  • dart:mirrors

Package not compatible with runtime flutter-native on macos

Because:

  • package:property_wrapper_generator/builder.dart that imports:
  • package:source_gen/source_gen.dart that imports:
  • package:source_gen/src/type_checker.dart that imports:
  • dart:mirrors

Package not compatible with runtime flutter-native on windows

Because:

  • package:property_wrapper_generator/builder.dart that imports:
  • package:source_gen/source_gen.dart that imports:
  • package:source_gen/src/type_checker.dart that imports:
  • dart:mirrors

Package not compatible with runtime flutter-web on web

Because:

  • package:property_wrapper_generator/builder.dart that imports:
  • package:source_gen/source_gen.dart that imports:
  • package:source_gen/src/utils.dart that imports:
  • package:build/build.dart that imports:
  • package:build/src/generate/run_post_process_builder.dart that imports:
  • package:build/src/builder/post_process_builder.dart that imports:
  • package:build/src/builder/builder.dart that imports:
  • package:build/src/builder/build_step.dart that imports:
  • package:build/src/asset/reader.dart that imports:
  • package:glob/glob.dart that imports:
  • package:glob/src/list_tree.dart that imports:
  • package:glob/src/io.dart that imports:
  • package:glob/src/io_export.dart that imports:
  • dart:io

Package not compatible with runtime js

Because:

  • package:property_wrapper_generator/builder.dart that imports:
  • package:source_gen/source_gen.dart that imports:
  • package:source_gen/src/utils.dart that imports:
  • package:build/build.dart that imports:
  • package:build/src/generate/run_post_process_builder.dart that imports:
  • package:build/src/builder/post_process_builder.dart that imports:
  • package:build/src/builder/builder.dart that imports:
  • package:build/src/builder/build_step.dart that imports:
  • package:build/src/asset/reader.dart that imports:
  • package:glob/glob.dart that imports:
  • package:glob/src/list_tree.dart that imports:
  • package:glob/src/io.dart that imports:
  • package:glob/src/io_export.dart that imports:
  • dart:io

Package not compatible with runtime native-aot

Because:

  • package:property_wrapper_generator/builder.dart that imports:
  • package:source_gen/source_gen.dart that imports:
  • package:source_gen/src/type_checker.dart that imports:
  • dart:mirrors

Health suggestions

Format lib/builder.dart.

Run dartfmt to format lib/builder.dart.

Format lib/class_member_property_wrapper_generator.dart.

Run dartfmt to format lib/class_member_property_wrapper_generator.dart.

Format lib/top_level_property_wrapper_generator.dart.

Run dartfmt to format lib/top_level_property_wrapper_generator.dart.

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_generator.dart. Packages with multiple examples should provide example/README.md.

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.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
build ^1.0.0 1.3.0
pedantic ^1.9.0 1.9.2
property_wrapper ^0.0.2 0.0.2
recase ^3.0.0 3.0.0
source_gen ^0.9.0 0.9.6
Transitive dependencies
_fe_analyzer_shared 5.0.0
analyzer 0.39.12
args 1.6.0
async 2.4.2
charcode 1.1.3
collection 1.14.13 1.15.0-nullsafety
convert 2.1.1
crypto 2.1.5
csslib 0.16.1
dart_style 1.3.6
glob 1.2.0
html 0.14.0+3
js 0.6.2
logging 0.11.4
meta 1.2.2 1.3.0-nullsafety
node_interop 1.1.1
node_io 1.1.1
package_config 1.9.3
path 1.7.0
pub_semver 1.4.4
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.2.0 1.3.0-nullsafety
watcher 0.9.7+15
yaml 2.2.1
Dev dependencies
build_runner ^1.0.0
build_test ^0.10.3