mix_generator 0.4.0 copy "mix_generator: ^0.4.0" to clipboard
mix_generator: ^0.4.0 copied to clipboard

A code generator for Mix, an expressive way to effortlessly build design systems in Flutter.

example/README.md

Example #

// ignore_for_file: prefer_relative_imports,avoid-importing-entrypoint-exports, camel_case_types
import 'package:flutter/material.dart';
import 'package:mix/mix.dart';
import 'package:mix_annotations/mix_annotations.dart';

part 'box_spec.g.dart';

const _constraints = MixableFieldUtility(
  type: BoxConstraints,
  properties: [
    (path: 'minWidth', alias: 'minWidth'),
    (path: 'maxWidth', alias: 'maxWidth'),
    (path: 'minHeight', alias: 'minHeight'),
    (path: 'maxHeight', alias: 'maxHeight'),
  ],
);

const _foreground = MixableFieldUtility(type: BoxDecoration);
const _boxDecor = MixableFieldUtility(
  type: BoxDecoration,
  properties: [
    (path: 'color', alias: 'color'),
    (path: 'border', alias: 'border'),
    (path: 'border.directional', alias: 'borderDirectional'),
    (path: 'borderRadius', alias: 'borderRadius'),
    (path: 'borderRadius.directional', alias: 'borderRadiusDirectional'),
    (path: 'gradient', alias: 'gradient'),
    (path: 'gradient.sweep', alias: 'sweepGradient'),
    (path: 'gradient.radial', alias: 'radialGradient'),
    (path: 'gradient.linear', alias: 'linearGradient'),
    (path: 'boxShadows', alias: 'shadows'),
    (path: 'boxShadow', alias: 'shadow'),
    (path: 'elevation', alias: 'elevation'),
  ],
);

const _shapeDecor = MixableFieldUtility(
  alias: 'shapeDecoration',
  type: ShapeDecoration,
);

@MixableSpec()
final class BoxSpec extends Spec<BoxSpec> with _$BoxSpec {
  /// {@macro box_spec_of}
  static const of = _$BoxSpec.of;

  static const from = _$BoxSpec.from;

  /// Aligns the child within the box.
  final AlignmentGeometry? alignment;

  /// Adds empty space inside the box.
  final EdgeInsetsGeometry? padding;

  /// Adds empty space around the box.
  final EdgeInsetsGeometry? margin;

  /// Applies additional constraints to the child.
  @MixableField(utilities: [_constraints])
  final BoxConstraints? constraints;

  /// Paints a decoration behind the child.
  @MixableField(utilities: [_boxDecor, _shapeDecor])
  final Decoration? decoration;

  /// Paints a decoration in front of the child.
  @MixableField(utilities: [_foreground])
  final Decoration? foregroundDecoration;

  /// Applies a transformation matrix before painting the box.
  final Matrix4? transform;

  /// Aligns the origin of the coordinate system for the [transform].
  final AlignmentGeometry? transformAlignment;

  /// Defines the clip behavior for the box
  /// when [BoxConstraints] has a negative minimum extent.
  final Clip? clipBehavior;

  /// Specifies the width of the box.
  final double? width;

  /// Specifies the height of the box.
  final double? height;

  const BoxSpec({
    this.alignment,
    this.padding,
    this.margin,
    this.constraints,
    this.decoration,
    this.foregroundDecoration,
    this.transform,
    this.transformAlignment,
    this.clipBehavior,
    this.width,
    this.height,
    super.animated,
  });
}
1
likes
130
points
554
downloads

Publisher

verified publisherleoafarias.com

Weekly Downloads

A code generator for Mix, an expressive way to effortlessly build design systems in Flutter.

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

analyzer, build, build_config, collection, dart_style, logging, mix_annotations, path, source_gen

More

Packages that depend on mix_generator