singleton_class_annotation 0.1.0 copy "singleton_class_annotation: ^0.1.0" to clipboard
singleton_class_annotation: ^0.1.0 copied to clipboard

discontinued
outdated

A `@SingletoneClass` annotation indicating a class will be a singlton. `singleton_class_generator` package will generate a singleton class.

singleton_class #

Annotation package to create a singleton style class. This package is for @SingletonClass() annotaion which indicates that a class is a singleton.

Usage #

Install #

Add this lines in your pubspec.yaml and run flutter pub get.

dependencies:
  singleton_class:

dev_dependencies:
  build_runner:
  singleton_class_generator:

Example #

import 'package:singleton_class/singleton_class.dart';

part 'main.g.dart'; /// singleton_class_generator will automatically generate this.

/// All the class annotated as a `@SingletonClass()` will have
/// a singleton class which has a `Singleton`-prefixed name.
@SingletonClass()
class TestClass {
  printer() {
    print(this.hashCode);
  }
}

main() {
    /// `Singleton`-prefixed singleton style `TestClass`.
    /// All the other method or members inside `TestClass` works as expected.
    /// You can get a singleton instance using `getInstance()` method
    /// or default constructor.
    /// Current version supports non-args constructor only.
  var instance = SingletonTestClass.getInstance();
  var instance2 = SingletonTestClass();

  instance.printer();
  instance2.printer();
}

Run build_runner.

flutter pub run build_runner watch
0
likes
0
pub points
0%
popularity

Publisher

verified publishergihwan.com

A `@SingletoneClass` annotation indicating a class will be a singlton. `singleton_class_generator` package will generate a singleton class.

Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on singleton_class_annotation