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.

mantle_annotations #

Pure-Dart annotations for Mantle code generation.

This package has no Flutter dependency, so both app/library code and the analyzer-side generators in mantle_gen can import it.

Install #

dependencies:
  mantle_annotations: ^1.1.0

See example/example.dart for a @MantleToken group.

Typically you also add mantle_gen as a dev_dependency and run dart run build_runner build.

Annotations #

@MantleToken #

Marks a class of size names (or static const values) for the Mantle token generator. Size-list classes extend a generated base and take BuildContext so values can use emOf:

import 'package:mantle_annotations/mantle_annotations.dart';

part 'app_theme.g.dart';

@MantleToken(['xs', 'sm', 'md', 'lg', 'xl'])
class AppSpacing extends _$AppSpacing {
  AppSpacing(BuildContext context)
    : super(xs: 10, sm: 12, md: 1.emOf(context), lg: 20, xl: 32);
}

Optional parameters:

Parameter Default Purpose
sizes [] Size names for a context-built scale
slot inferred Built-in theme slot (spacing, radius, breakpoints)
type dynamic Value type used in the static-const toMap()
name _$${classname} Generated base/mixin name (supports {classname})

@MantleAppTheme #

Marks a class that aggregates @MantleToken scales in the same library. After generation:

@MantleAppTheme()
class AppTheme = _$AppTheme with _$AppThemeMixin;

MantleProvider(theme: AppTheme(), child: app);
AppTheme.of(context).spacing.all.md;

License #

MIT. See LICENSE.

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