velix 0.91.2 copy "velix: ^0.91.2" to clipboard
velix: ^0.91.2 copied to clipboard

flutter foundation library. This core library contains basic functionality, mainly the meta-data organization and its related code generator used by the different addons.

example/main.dart

import 'package:velix/reflectable/reflectable.dart';

import 'main.types.g.dart';

@Dataclass()
class Money {
  // instance data

  @Attribute(type: "maxLength 7")
  final String currency;
  @Attribute(type: "greaterThan 0")
  final int value;

  const Money({required this.currency, required this.value});
}

void main() {
  // register types

  registerTypes();
  
  // create some data
  
  var price = Money(currency: "EUR", value: 1);
  
  var type = TypeDescriptor.forType<Money>();

  // call getters

  var currency = type.get(price, "currency");
  var value = type.get(price, "value");

  // call constructor

  var result = type.constructor!(currency: currency, value: -1);

  try {
    type.validate(result);
  }
  catch(e) {
    print(e);
  }
}
3
likes
110
points
1.11k
downloads

Publisher

unverified uploader

Weekly Downloads

flutter foundation library. This core library contains basic functionality, mainly the meta-data organization and its related code generator used by the different addons.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

analyzer, async, build, flutter, glob, path, source_gen, stack_trace

More

Packages that depend on velix