settings_gen 1.0.3

  • Readme
  • Changelog
  • Installing
  • 50

pub package pub package

settings_gen #

Code generator for settings_manager built for use with SharedPreferences. This will add Streams and ValueNotifiers for each field.

$> cd $YOUR_PROJECT_DIR
\$> flutter packages pub run build_runner build

Example #

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:settings_manager/settings_manager.dart';
import 'package:shared_preferences/shared_preferences.dart';

part 'settings.g.dart';

class Settings = SettingsBase with _$Settings;

abstract class SettingsBase with SettingsStore {
  @BoolSetting(defaultValue: false)
  bool darkMode;

  @StringSetting(defaultValue: 'none')
  String userId;

  @IntSetting(defaultValue: 0)
  int counterValue;

  @DoubleSetting(defaultValue: 0)
  double radialValue;

  @StringListSetting(defaultValue: [])
  List<String> savedItems;
}

1.0.2 #

  • Added automatic generation of toString method with @StoreConfig annotation

Thanks to @hawkbee1

1.0.0 - 1.0.1 #

  • Ready for prime time!
  • Fixing version resolution

0.4.2 #

  • Upgraded the build_resolvers dependency to 1.3.2, which fixes issues with certain versions of Dart being unable to resolve dart:ui types.

0.4.1+2 #

  • Going back to original test_coverage package

0.4.1+1 #

  • README updates
  • Switching to Github Actions for all builds and publishing

0.4.1 #

There were a number of bugs with the previous implementation of the LibraryScopedNameFinder. This resolves them, as well as ensures that a single code path is followed whether or not the analyzed source code contains named imports, reducing the potential for future bugs.

The following bugs have been corrected when using named imports:

  • Missing type arguments on classes
  • Missing type arguments on function typedefs
  • Missing prefixes from imported typedefs
  • Missing prefixes from implicit type argument bounds

0.4.0 - 0.4.0+1 #

  • Upgraded our analyzer dependency's minimum version to 0.38.5 in order to workaround a bug where collection types would resolve to dynamic
  • Updated pubspec.yaml to not include the reference to the @store annotation. It has been removed.

0.3.13 #

  • Fixes the extraction of generic return-types which have nested generic type arguments, eg: Future<List<User>>
  • Also fixes the issue reported in #367

0.3.12 - 0.3.12+1 #

  • Removed the experimental use of @store annotation. It fails for some cases and has now been removed. We will explore other use cases with this annotation in future PRs.
  • Package updates
  • Added the Flutter Favorite logo

0.3.10+1 - 0.3.11 #

  • Package updates
  • Upgraded dependency version for the analyzer package

0.3.9+1 - 0.3.10 #

  • Alters the analyzer dependency to support a range — from the previously supported version (0.36.3), up to latest (0.39.0).
  • Adds support for library prefixes in all situations (import 'package:foo' as foo), so type names are prefixed in generated part files.

0.3.8 - 0.3.9+1 #

  • Fixes a minor issue where types in generated code would appear as dynamic when they shouldn't.
  • Added a version constant that matches the pubspec.yaml

0.3.7 #

  • This is mostly about providing better error reporting on classes that don't meet the necessary constraints.
    • A class using the SettingsStore mixin, must be marked abstract. This will be reported if not the case.
    • A class using the @store annotation, must be marked private. This will be reported if not the case.
  • Bit of refactoring to separate things out a bit.

0.3.6 #

  • Fixes the type resolution bug that prevented using types from packages like dart:ui
  • Fixes the type resolution of other public Store classes referenced in the @store based generation

Thanks to @shyndman for the tremendous work on this release.

0.3.5 #

  • Added the ability to create Store classes using the @store annotation. It can be added to a private class, which will result in a public generated class.

0.3.4 #

  • Refactored some tests that rely on source-text to not be based on hard-coded strings. These have been moved to a separate file for easier maintenance. The outputs resulting from the generator are also in a separate file. This allows scaling to more variations of source-text in the future.
  • Added checks to ensure @observable and @computed are used for the correct members of the class. These are reported as errors during the codegen process.
  • Upgraded test_coverage
  • Fixed a bunch of analyzer errors

0.3.1 - 0.3.3+1 #

  • Adding a conditional action-wrapper for field setters.
  • Increasing test coverage
  • Adapting to the API change in mobx 0.3.3
  • Formatting changes

0.3.0 - 0.3.0+1 #

  • Adapting to the API changes in mobx 0.3.0
  • README.md updates

0.2.1+2 #

  • Removing the code in /example folder and instead having a simple README.md in it.

0.2.1+1 #

  • README updates

0.2.1 #

  • Upgrading to use the 0.2.1 version of mobx, which makes it compatible with the latest beta/dev/master channels

0.2.0 #

  • A breaking change has been introduced to the use of the Store type. Previously it was meant to be used as an interface, which has now changed to a mixin.

0.0.2 - 0.1.3 #

  • Move all the codegen parts to separate templates
  • Documentation updates
  • Support for async actions
  • CircleCI integration improvements

0.0.1 - First Release #

  • Added support for @observable, @computed and @action

Use this package as a library

1. Depend on it

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


dependencies:
  settings_gen: ^1.0.3

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:settings_gen/settings_gen.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
14
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

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

  • Dart: 2.8.2
  • pana: 0.13.8-dev
  • Flutter: 1.17.1

Health suggestions

Fix lib/src/settings_gen_base.dart. (-1.99 points)

Analysis of lib/src/settings_gen_base.dart reported 4 hints:

line 19 col 64: 'typeSystem' is deprecated and shouldn't be used. Use LibraryElement.typeSystem.

line 49 col 13: 'type' is deprecated and shouldn't be used.

line 49 col 29: 'type' is deprecated and shouldn't be used.

line 49 col 34: 'instantiate' is deprecated and shouldn't be used. Use ClassElement.instantiate().

Fix lib/src/store_class_visitor.dart. (-0.50 points)

Analysis of lib/src/store_class_visitor.dart reported 1 hint:

line 8 col 8: Don't import implementation files from another package.

Maintenance issues and suggestions

No valid SDK. (-20 points)

The analysis could not detect a valid SDK that can use this package.

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

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
analyzer >=0.38.5 <0.40.0 0.39.10
build ^1.1.4 1.3.0
build_resolvers ^1.3.2 1.3.9
flutter 0.0.0
meta ^1.1.0 1.1.8
path ^1.6.2 1.7.0
settings_manager 1.0.3 1.0.3
source_gen ^0.9.4 0.9.5
Transitive dependencies
_fe_analyzer_shared 4.0.0
args 1.6.0
async 2.4.1
charcode 1.1.3
collection 1.14.12
convert 2.1.1
crypto 2.1.5
csslib 0.16.1
dart_style 1.3.6
glob 1.2.0
graphs 0.2.0
html 0.14.0+3
js 0.6.1+1
node_interop 1.1.1
node_io 1.1.1
package_config 1.9.3
pedantic 1.9.0
pub_semver 1.4.4
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
watcher 0.9.7+15
yaml 2.2.1
Dev dependencies
build_runner ^1.7.2
build_test ^0.10.9
logging ^0.11.3 0.11.4
mockito ^4.0.0
test ^1.9.4
test_coverage ^0.4.1