mantle_annotations 1.1.0 copy "mantle_annotations: ^1.1.0" to clipboard
mantle_annotations: ^1.1.0 copied to clipboard

Pure-Dart annotations for Mantle code generation. Shared by app code and mantle_gen without pulling in Flutter.

example/example.dart

import 'package:mantle_annotations/mantle_annotations.dart';

/// Token group consumed by `mantle_gen`.
///
/// Add `mantle_gen` as a dev dependency and run
/// `dart run build_runner build` to emit `_$AppSpacing`. Mix in or extend
/// that base and pass named values from a `BuildContext` constructor.
@MantleToken(['xs', 'sm', 'md', 'lg', 'xl'])
class AppSpacing {
  /// Builds spacing from a `BuildContext` after generation.
  AppSpacing(Object _);
}

/// Static-const groups still emit a `toMap()` mixin.
@MantleToken.consts(type: int)
abstract final class Palette {
  static const red = 0xFFFF0000;
  static const blue = 0xFF0000FF;
}

void main() {
  final values = <String, int>{
    'red': Palette.red,
    'blue': Palette.blue,
  };
  assert(values.length == 2, 'palette should list both colors');
}
0
likes
160
points
100
downloads

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

Pure-Dart annotations for Mantle code generation. Shared by app code and mantle_gen without pulling in Flutter.

Homepage
Repository (GitHub)
View/report issues

Topics

#annotations #codegen #design-system #theme #flutter

License

MIT (license)

More

Packages that depend on mantle_annotations