From 53e1d0ed487e5178de50e4cc3279923925fe8ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nando=20Sch=C3=A4r?= Date: Tue, 28 Apr 2026 09:56:26 +0200 Subject: [PATCH 1/2] feat: add shadow builder --- README.md | 1 + build.yaml | 7 + design-system.schema.json | 48 ++++++ example/example.md | 12 ++ example/lib/app.design-system.json | 12 ++ example/lib/app.shadows.dart | 48 ++++++ lib/builder.dart | 6 + lib/src/builder/shadow_builder.dart | 176 +++++++++++++++++++++ lib/src/config/config.dart | 12 ++ lib/src/config/shadow.dart | 93 +++++++++++ test_dart/builder/shadow_builder_test.dart | 155 ++++++++++++++++++ test_dart/config/config_test.dart | 26 +++ 12 files changed, 596 insertions(+) create mode 100644 example/lib/app.shadows.dart create mode 100644 lib/src/builder/shadow_builder.dart create mode 100644 lib/src/config/shadow.dart create mode 100644 test_dart/builder/shadow_builder_test.dart diff --git a/README.md b/README.md index f0544fd..b6060a1 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ The generator creates the following elements: - Colors - Border Widths and helper functions to create borders - Border Radii +- Shadows and helper functions to create box shadows - Spatials (spacing) - Screensizes (Breakpoints) and a responsive helper function - Text Styles (Typography) diff --git a/build.yaml b/build.yaml index 1d376df..98c05f8 100644 --- a/build.yaml +++ b/build.yaml @@ -54,3 +54,10 @@ builders: build_extensions: { '.design-system.json': ['.icon_sizes.dart'] } auto_apply: root_package build_to: source + + shadows: + import: 'package:design_system_generator/builder.dart' + builder_factories: ['shadowBuilder'] + build_extensions: { '.design-system.json': ['.shadows.dart'] } + auto_apply: root_package + build_to: source diff --git a/design-system.schema.json b/design-system.schema.json index 655d5f3..4301e04 100644 --- a/design-system.schema.json +++ b/design-system.schema.json @@ -133,6 +133,25 @@ }, { "const": false } ] + }, + "shadows": { + "title": "Shadows", + "description": "A map of box shadow definitions.", + "oneOf": [ + { + "type": "object", + "minProperties": 0, + "additionalProperties": false, + "patternProperties": { + "^[a-zA-Z][a-zA-Z0-9]*$": { + "$ref": "#/$defs/shadow" + } + } + }, + { + "const": false + } + ] } }, "$defs": { @@ -210,6 +229,35 @@ } } }, + "shadow": { + "title": "Shadow", + "description": "A box shadow definition.", + "type": "object", + "required": ["blurRadius", "spreadRadius", "offset"], + "additionalProperties": false, + "properties": { + "blurRadius": { + "type": "number", + "minimum": 0 + }, + "spreadRadius": { + "type": "number" + }, + "offset": { + "type": "object", + "required": ["dx", "dy"], + "additionalProperties": false, + "properties": { + "dx": { + "type": "number" + }, + "dy": { + "type": "number" + } + } + } + } + }, "iconSizes": { "title": "Icon sizes", "description": "A definition of the icon sizes in px.", diff --git a/example/example.md b/example/example.md index 4245f1f..1852157 100644 --- a/example/example.md +++ b/example/example.md @@ -48,6 +48,18 @@ Note that colors are in the format `#RRGGBB` or `#RRGGBBAA` (with alpha). "normal": 8, "full": 9999 }, + "shadows": { + "small": { + "blurRadius": 4, + "spreadRadius": 0, + "offset": { "dx": 0, "dy": 2 } + }, + "large": { + "blurRadius": 12, + "spreadRadius": -2, + "offset": { "dx": 0, "dy": 8 } + } + }, "typography": { "root": { "family": "Arial", diff --git a/example/lib/app.design-system.json b/example/lib/app.design-system.json index e13b803..3d75d5c 100644 --- a/example/lib/app.design-system.json +++ b/example/lib/app.design-system.json @@ -33,6 +33,18 @@ "normal": 8, "full": 9999 }, + "shadows": { + "small": { + "blurRadius": 4, + "spreadRadius": 0, + "offset": { "dx": 0, "dy": 2 } + }, + "large": { + "blurRadius": 12, + "spreadRadius": -2, + "offset": { "dx": 0, "dy": 8 } + } + }, "typography": { "root": { "family": "Arial", diff --git a/example/lib/app.shadows.dart b/example/lib/app.shadows.dart new file mode 100644 index 0000000..72e9a1b --- /dev/null +++ b/example/lib/app.shadows.dart @@ -0,0 +1,48 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// +// ************************************************************************** +// Design System Generator - shadows +// ************************************************************************* + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:flutter/widgets.dart' as _i1; + +import './app.colors.dart' as _i2; + +abstract final class AppShadows { + /// large (blur: 12.0px, spread: -2.0px, offset: 0.0/8.0) + static _i1.BoxShadow large({_i2.AppColor color = _i2.AppColor.black}) => + AppShadow.large.boxShadow(color: color); + + /// small (blur: 4.0px, spread: 0.0px, offset: 0.0/2.0) + static _i1.BoxShadow small({_i2.AppColor color = _i2.AppColor.black}) => + AppShadow.small.boxShadow(color: color); +} + +enum AppShadow { + /// large (blur: 12.0px, spread: -2.0px, offset: 0.0/8.0) + large(12.0, -2.0, _i1.Offset(0.0, 8.0)), + + /// small (blur: 4.0px, spread: 0.0px, offset: 0.0/2.0) + small(4.0, 0.0, _i1.Offset(0.0, 2.0)); + + const AppShadow(this.blurRadius, this.spreadRadius, this.offset); + + final double blurRadius; + + final double spreadRadius; + + final _i1.Offset offset; + + _i1.BoxShadow boxShadow({_i2.AppColor color = _i2.AppColor.black}) => + _i1.BoxShadow( + color: color.color, + blurRadius: blurRadius, + spreadRadius: spreadRadius, + offset: offset, + ); + + List<_i1.BoxShadow> asList({_i2.AppColor color = _i2.AppColor.black}) => [ + boxShadow(color: color), + ]; +} diff --git a/lib/builder.dart b/lib/builder.dart index b9062cc..a59dc70 100644 --- a/lib/builder.dart +++ b/lib/builder.dart @@ -6,6 +6,7 @@ import 'src/builder/color_builder.dart'; import 'src/builder/icon_size_builder.dart'; import 'src/builder/radius_builder.dart'; import 'src/builder/screen_builder.dart'; +import 'src/builder/shadow_builder.dart'; import 'src/builder/spatial_builder.dart'; import 'src/builder/typography_builder.dart'; @@ -48,3 +49,8 @@ Builder screenBuilder(BuilderOptions options) => ScreenBuilder(); /// /// This builder generates icon size-related design tokens. Builder iconSizeBuilder(BuilderOptions options) => IconSizeBuilder(); + +/// Creates a [ShadowBuilder] instance. +/// +/// This builder generates box shadow-related design tokens. +Builder shadowBuilder(BuilderOptions options) => ShadowBuilder(); diff --git a/lib/src/builder/shadow_builder.dart b/lib/src/builder/shadow_builder.dart new file mode 100644 index 0000000..b1c0e25 --- /dev/null +++ b/lib/src/builder/shadow_builder.dart @@ -0,0 +1,176 @@ +import 'package:code_builder/code_builder.dart'; + +import '../config/config.dart'; +import 'base_builder.dart'; + +/// A builder that generates shadow-related design system code. +final class ShadowBuilder extends DesignSystemBuilder { + /// Creates a [ShadowBuilder] instance. + ShadowBuilder() : super('shadows'); + + @override + Library buildLibrary(DesignSystemConfig config) { + if (config.shadows.isEmpty) { + return Library(); + } + + final boxShadowRef = refer('BoxShadow', 'package:flutter/widgets.dart'); + final offsetRef = refer('Offset', 'package:flutter/widgets.dart'); + final colorRef = refer('AppColor', './${config.name}.colors.dart'); + + return Library( + (b) => b + ..body.add( + Class( + (b) => b + ..name = 'AppShadows' + ..modifier = ClassModifier.final$ + ..abstract = true + ..methods.addAll( + config.shadows.map( + (shadow) => Method( + (b) => b + ..name = shadow.validName + ..static = true + ..returns = boxShadowRef + ..docs.addAll([ + '/// ${shadow.validName} (blur: ${shadow.blurRadius}px, spread: ${shadow.spreadRadius}px, offset: ${shadow.offsetDx}/${shadow.offsetDy})', + ]) + ..optionalParameters.add( + Parameter( + (b) => b + ..name = 'color' + ..type = colorRef + ..named = true + ..defaultTo = colorRef.property('black').code, + ), + ) + ..lambda = true + ..body = refer('AppShadow') + .property(shadow.validName) + .property('boxShadow') + .call([], {'color': refer('color')}) + .code, + ), + ), + ), + ), + ) + ..body.add( + Enum( + (b) => b + ..name = 'AppShadow' + ..fields.addAll([ + Field( + (b) => b + ..modifier = FieldModifier.final$ + ..name = 'blurRadius' + ..type = refer('double'), + ), + Field( + (b) => b + ..modifier = FieldModifier.final$ + ..name = 'spreadRadius' + ..type = refer('double'), + ), + Field( + (b) => b + ..modifier = FieldModifier.final$ + ..name = 'offset' + ..type = offsetRef, + ), + ]) + ..constructors.add( + Constructor( + (b) => b + ..constant = true + ..requiredParameters.addAll([ + Parameter( + (b) => b + ..name = 'blurRadius' + ..toThis = true, + ), + Parameter( + (b) => b + ..name = 'spreadRadius' + ..toThis = true, + ), + Parameter( + (b) => b + ..name = 'offset' + ..toThis = true, + ), + ]), + ), + ) + ..methods.add( + Method( + (b) => b + ..name = 'boxShadow' + ..returns = boxShadowRef + ..optionalParameters.add( + Parameter( + (b) => b + ..name = 'color' + ..type = colorRef + ..named = true + ..defaultTo = colorRef.property('black').code, + ), + ) + ..lambda = true + ..body = boxShadowRef.newInstance([], { + 'color': refer('color').property('color'), + 'blurRadius': refer('blurRadius'), + 'spreadRadius': refer('spreadRadius'), + 'offset': refer('offset'), + }).code, + ), + ) + ..methods.add( + Method( + (b) => b + ..name = 'asList' + ..returns = TypeReference( + (b) => b + ..symbol = 'List' + ..types.add(boxShadowRef), + ) + ..optionalParameters.add( + Parameter( + (b) => b + ..name = 'color' + ..type = colorRef + ..named = true + ..defaultTo = colorRef.property('black').code, + ), + ) + ..lambda = true + ..body = literalList([ + refer('boxShadow').call([], {'color': refer('color')}), + ]).code, + ), + ) + ..values.addAll( + config.shadows.map( + (shadow) => EnumValue( + (b) => b + ..name = shadow.validName + ..docs.addAll([ + '/// ${shadow.validName} (blur: ${shadow.blurRadius}px, spread: ${shadow.spreadRadius}px, offset: ${shadow.offsetDx}/${shadow.offsetDy})', + ]) + ..arguments.addAll([ + literalNum(shadow.blurRadius), + literalNum(shadow.spreadRadius), + offsetRef.newInstance([ + literalNum(shadow.offsetDx), + literalNum(shadow.offsetDy), + ]), + ]), + ), + ), + ), + ), + ), + ); + } +} diff --git a/lib/src/config/config.dart b/lib/src/config/config.dart index e5a5319..89fea42 100644 --- a/lib/src/config/config.dart +++ b/lib/src/config/config.dart @@ -3,6 +3,7 @@ import 'color.dart'; import 'icon_size.dart'; import 'radius.dart'; import 'screen.dart'; +import 'shadow.dart'; import 'spatial.dart'; import 'typography.dart'; @@ -26,6 +27,9 @@ class DesignSystemConfig { /// The list of border radii in the design system. final List radii; + /// The list of shadows in the design system. + final List shadows; + /// The list of text styles in the design system. final List typography; @@ -40,6 +44,7 @@ class DesignSystemConfig { required this.spatials, required this.borderWidths, required this.radii, + required this.shadows, required this.typography, required this.iconSizes, }); @@ -82,6 +87,13 @@ class DesignSystemConfig { growable: false, )..sort((a, b) => a.radius.compareTo(b.radius))), }, + shadows: switch (json['shadows']) { + bool() => [], + null => DesignSystemShadow.defaultValue, + final dynamic data => (DesignSystemShadow.parse( + data, + ).toList(growable: false)..sort((a, b) => a.name.compareTo(b.name))), + }, typography: switch (json['typography']) { bool() => [], null => DesignSystemTextStyle.defaultValue, diff --git a/lib/src/config/shadow.dart b/lib/src/config/shadow.dart new file mode 100644 index 0000000..61d1a61 --- /dev/null +++ b/lib/src/config/shadow.dart @@ -0,0 +1,93 @@ +/// Represents a box shadow in the design system. +class DesignSystemShadow { + /// The name of the shadow. + final String name; + + /// The blur radius of the shadow. + final double blurRadius; + + /// The spread radius of the shadow. + final double spreadRadius; + + /// The horizontal shadow offset. + final double offsetDx; + + /// The vertical shadow offset. + final double offsetDy; + + /// Creates a [DesignSystemShadow] instance. + const DesignSystemShadow( + this.name, + this.blurRadius, + this.spreadRadius, + this.offsetDx, + this.offsetDy, + ); + + /// The default list of shadows. + static const List defaultValue = []; + + /// Parses a map of shadows into an iterable of [DesignSystemShadow]. + static Iterable parse( + Map shadows, + ) sync* { + for (final e in shadows.entries) { + if (e.value is! Map) { + yield DesignSystemShadow(e.key, 0, 0, 0, 0); + continue; + } + + final shadow = e.value as Map; + final offset = shadow['offset']; + + yield DesignSystemShadow( + e.key, + _toDouble(shadow['blurRadius']), + _toDouble(shadow['spreadRadius']), + offset is Map ? _toDouble(offset['dx']) : 0, + offset is Map ? _toDouble(offset['dy']) : 0, + ); + } + } + + static double _toDouble(dynamic value) { + if (value is double) { + return value; + } + + if (value is int) { + return value.toDouble(); + } + + return 0; + } + + @override + String toString() => + 'Shadow $name: blur=${blurRadius}px spread=${spreadRadius}px offset=($offsetDx, $offsetDy)'; + + /// Checks if the shadow name is valid. + bool get isValid => name.startsWith(RegExp(r'^[a-zA-Z][a-zA-Z0-9]*$')); + + /// Returns a valid name for the shadow. + String get validName => isValid ? name : 'shadow$name'; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is DesignSystemShadow && + runtimeType == other.runtimeType && + name == other.name && + blurRadius == other.blurRadius && + spreadRadius == other.spreadRadius && + offsetDx == other.offsetDx && + offsetDy == other.offsetDy; + + @override + int get hashCode => + name.hashCode ^ + blurRadius.hashCode ^ + spreadRadius.hashCode ^ + offsetDx.hashCode ^ + offsetDy.hashCode; +} diff --git a/test_dart/builder/shadow_builder_test.dart b/test_dart/builder/shadow_builder_test.dart new file mode 100644 index 0000000..f78e369 --- /dev/null +++ b/test_dart/builder/shadow_builder_test.dart @@ -0,0 +1,155 @@ +import 'package:build_test/build_test.dart'; +import 'package:design_system_generator/src/builder/shadow_builder.dart'; +import 'package:test/test.dart'; + +void main() { + group('ShadowBuilder', () { + for (final (name, inputs, outputs) in _cases) { + test( + 'should generate correct code ($name).', + () => testBuilder( + ShadowBuilder(), + inputs, + outputs: outputs, + rootPackage: 'design_system_generator', + ), + ); + } + }); +} + +final _cases = <(String, Map, Map)>[ + ('empty input', {}, {}), + ('no design system', {'a|lib/design_system.dart': ''}, {}), + ( + 'valid shadows', + { + 'a|lib/a.design-system.json': '''{ + "shadows": { + "small": { + "blurRadius": 4, + "spreadRadius": 0, + "offset": { "dx": 0, "dy": 2 } + }, + "large": { + "blurRadius": 12, + "spreadRadius": -2, + "offset": { "dx": 0, "dy": 8 } + } + } + }''', + }, + { + 'a|lib/a.shadows.dart': ''' +// GENERATED CODE - DO NOT MODIFY BY HAND +// +// ************************************************************************** +// Design System Generator - shadows +// ************************************************************************* + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:flutter/widgets.dart' as _i1; + +import './a.colors.dart' as _i2; + +abstract final class AppShadows { + /// large (blur: 12.0px, spread: -2.0px, offset: 0.0/8.0) + static _i1.BoxShadow large({_i2.AppColor color = _i2.AppColor.black}) => + AppShadow.large.boxShadow(color: color); + + /// small (blur: 4.0px, spread: 0.0px, offset: 0.0/2.0) + static _i1.BoxShadow small({_i2.AppColor color = _i2.AppColor.black}) => + AppShadow.small.boxShadow(color: color); +} + +enum AppShadow { + /// large (blur: 12.0px, spread: -2.0px, offset: 0.0/8.0) + large(12.0, -2.0, _i1.Offset(0.0, 8.0)), + + /// small (blur: 4.0px, spread: 0.0px, offset: 0.0/2.0) + small(4.0, 0.0, _i1.Offset(0.0, 2.0)); + + const AppShadow(this.blurRadius, this.spreadRadius, this.offset); + + final double blurRadius; + + final double spreadRadius; + + final _i1.Offset offset; + + _i1.BoxShadow boxShadow({_i2.AppColor color = _i2.AppColor.black}) => + _i1.BoxShadow( + color: color.color, + blurRadius: blurRadius, + spreadRadius: spreadRadius, + offset: offset, + ); + + List<_i1.BoxShadow> asList({_i2.AppColor color = _i2.AppColor.black}) => [ + boxShadow(color: color), + ]; +} +''', + }, + ), + ( + 'invalid shadow names', + { + 'a|lib/a.design-system.json': '''{ + "shadows": { + "123": { + "blurRadius": 4, + "spreadRadius": 0, + "offset": { "dx": 0, "dy": 2 } + } + } + }''', + }, + { + 'a|lib/a.shadows.dart': ''' +// GENERATED CODE - DO NOT MODIFY BY HAND +// +// ************************************************************************** +// Design System Generator - shadows +// ************************************************************************* + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:flutter/widgets.dart' as _i1; + +import './a.colors.dart' as _i2; + +abstract final class AppShadows { + /// shadow123 (blur: 4.0px, spread: 0.0px, offset: 0.0/2.0) + static _i1.BoxShadow shadow123({_i2.AppColor color = _i2.AppColor.black}) => + AppShadow.shadow123.boxShadow(color: color); +} + +enum AppShadow { + /// shadow123 (blur: 4.0px, spread: 0.0px, offset: 0.0/2.0) + shadow123(4.0, 0.0, _i1.Offset(0.0, 2.0)); + + const AppShadow(this.blurRadius, this.spreadRadius, this.offset); + + final double blurRadius; + + final double spreadRadius; + + final _i1.Offset offset; + + _i1.BoxShadow boxShadow({_i2.AppColor color = _i2.AppColor.black}) => + _i1.BoxShadow( + color: color.color, + blurRadius: blurRadius, + spreadRadius: spreadRadius, + offset: offset, + ); + + List<_i1.BoxShadow> asList({_i2.AppColor color = _i2.AppColor.black}) => [ + boxShadow(color: color), + ]; +} +''', + }, + ), + ('disabled', {'a|lib/a.design-system.json': '{"shadows": false}'}, {}), +]; diff --git a/test_dart/config/config_test.dart b/test_dart/config/config_test.dart index d312f88..1db9644 100644 --- a/test_dart/config/config_test.dart +++ b/test_dart/config/config_test.dart @@ -4,6 +4,7 @@ import 'package:design_system_generator/src/config/config.dart'; import 'package:design_system_generator/src/config/icon_size.dart'; import 'package:design_system_generator/src/config/radius.dart'; import 'package:design_system_generator/src/config/screen.dart'; +import 'package:design_system_generator/src/config/shadow.dart'; import 'package:design_system_generator/src/config/spatial.dart'; import 'package:design_system_generator/src/config/typography.dart'; import 'package:test/test.dart'; @@ -16,6 +17,7 @@ void main() { 'screens': false, 'spacings': false, 'borderRadius': false, + 'shadows': false, 'typography': false, }, 'App'); @@ -23,6 +25,7 @@ void main() { expect(config.screens, isEmpty); expect(config.spatials, isEmpty); expect(config.radii, isEmpty); + expect(config.shadows, isEmpty); expect(config.typography, isEmpty); }); @@ -34,6 +37,7 @@ void main() { expect(config.spatials, DesignSystemSpatial.defaultValue); expect(config.borderWidths, DesignSystemBorderWidth.defaultValue); expect(config.radii, DesignSystemBorderRadius.defaultValue); + expect(config.shadows, DesignSystemShadow.defaultValue); expect(config.typography, DesignSystemTextStyle.defaultValue); expect(config.iconSizes, DesignSystemIconSize.defaultValue); }); @@ -84,6 +88,28 @@ void main() { ]); }); + test('should correctly parse shadows.', () { + final config = DesignSystemConfig.fromJson({ + 'shadows': { + 'small': { + 'blurRadius': 4, + 'spreadRadius': 0, + 'offset': {'dx': 0, 'dy': 2}, + }, + 'large': { + 'blurRadius': 12, + 'spreadRadius': -2, + 'offset': {'dx': 0, 'dy': 8}, + }, + }, + }, 'App'); + + expect(config.shadows, [ + DesignSystemShadow('large', 12, -2, 0, 8), + DesignSystemShadow('small', 4, 0, 0, 2), + ]); + }); + test('should correctly parse colors.', () { final config = DesignSystemConfig.fromJson({ 'colors': { From 4f525a71fddd179c6c995472d7b1e5e8b1607e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nando=20Sch=C3=A4r?= Date: Tue, 28 Apr 2026 10:20:35 +0200 Subject: [PATCH 2/2] fix: update color references from AppColor to Color in shadow builder and tests --- lib/src/builder/shadow_builder.dart | 11 ++++----- test_dart/builder/shadow_builder_test.dart | 26 +++++++++++++--------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/lib/src/builder/shadow_builder.dart b/lib/src/builder/shadow_builder.dart index b1c0e25..08c71aa 100644 --- a/lib/src/builder/shadow_builder.dart +++ b/lib/src/builder/shadow_builder.dart @@ -16,7 +16,8 @@ final class ShadowBuilder extends DesignSystemBuilder { final boxShadowRef = refer('BoxShadow', 'package:flutter/widgets.dart'); final offsetRef = refer('Offset', 'package:flutter/widgets.dart'); - final colorRef = refer('AppColor', './${config.name}.colors.dart'); + final colorRef = refer('Color', 'dart:ui'); + final colorsRef = refer('AppColors', './${config.name}.colors.dart'); return Library( (b) => b @@ -42,7 +43,7 @@ final class ShadowBuilder extends DesignSystemBuilder { ..name = 'color' ..type = colorRef ..named = true - ..defaultTo = colorRef.property('black').code, + ..defaultTo = colorsRef.property('black').code, ), ) ..lambda = true @@ -114,12 +115,12 @@ final class ShadowBuilder extends DesignSystemBuilder { ..name = 'color' ..type = colorRef ..named = true - ..defaultTo = colorRef.property('black').code, + ..defaultTo = colorsRef.property('black').code, ), ) ..lambda = true ..body = boxShadowRef.newInstance([], { - 'color': refer('color').property('color'), + 'color': refer('color'), 'blurRadius': refer('blurRadius'), 'spreadRadius': refer('spreadRadius'), 'offset': refer('offset'), @@ -141,7 +142,7 @@ final class ShadowBuilder extends DesignSystemBuilder { ..name = 'color' ..type = colorRef ..named = true - ..defaultTo = colorRef.property('black').code, + ..defaultTo = colorsRef.property('black').code, ), ) ..lambda = true diff --git a/test_dart/builder/shadow_builder_test.dart b/test_dart/builder/shadow_builder_test.dart index f78e369..ccde6f1 100644 --- a/test_dart/builder/shadow_builder_test.dart +++ b/test_dart/builder/shadow_builder_test.dart @@ -48,17 +48,19 @@ final _cases = <(String, Map, Map)>[ // ************************************************************************* // ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:ui' as _i2; + import 'package:flutter/widgets.dart' as _i1; -import './a.colors.dart' as _i2; +import './a.colors.dart' as _i3; abstract final class AppShadows { /// large (blur: 12.0px, spread: -2.0px, offset: 0.0/8.0) - static _i1.BoxShadow large({_i2.AppColor color = _i2.AppColor.black}) => + static _i1.BoxShadow large({_i2.Color color = _i3.AppColors.black}) => AppShadow.large.boxShadow(color: color); /// small (blur: 4.0px, spread: 0.0px, offset: 0.0/2.0) - static _i1.BoxShadow small({_i2.AppColor color = _i2.AppColor.black}) => + static _i1.BoxShadow small({_i2.Color color = _i3.AppColors.black}) => AppShadow.small.boxShadow(color: color); } @@ -77,15 +79,15 @@ enum AppShadow { final _i1.Offset offset; - _i1.BoxShadow boxShadow({_i2.AppColor color = _i2.AppColor.black}) => + _i1.BoxShadow boxShadow({_i2.Color color = _i3.AppColors.black}) => _i1.BoxShadow( - color: color.color, + color: color, blurRadius: blurRadius, spreadRadius: spreadRadius, offset: offset, ); - List<_i1.BoxShadow> asList({_i2.AppColor color = _i2.AppColor.black}) => [ + List<_i1.BoxShadow> asList({_i2.Color color = _i3.AppColors.black}) => [ boxShadow(color: color), ]; } @@ -114,13 +116,15 @@ enum AppShadow { // ************************************************************************* // ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:ui' as _i2; + import 'package:flutter/widgets.dart' as _i1; -import './a.colors.dart' as _i2; +import './a.colors.dart' as _i3; abstract final class AppShadows { /// shadow123 (blur: 4.0px, spread: 0.0px, offset: 0.0/2.0) - static _i1.BoxShadow shadow123({_i2.AppColor color = _i2.AppColor.black}) => + static _i1.BoxShadow shadow123({_i2.Color color = _i3.AppColors.black}) => AppShadow.shadow123.boxShadow(color: color); } @@ -136,15 +140,15 @@ enum AppShadow { final _i1.Offset offset; - _i1.BoxShadow boxShadow({_i2.AppColor color = _i2.AppColor.black}) => + _i1.BoxShadow boxShadow({_i2.Color color = _i3.AppColors.black}) => _i1.BoxShadow( - color: color.color, + color: color, blurRadius: blurRadius, spreadRadius: spreadRadius, offset: offset, ); - List<_i1.BoxShadow> asList({_i2.AppColor color = _i2.AppColor.black}) => [ + List<_i1.BoxShadow> asList({_i2.Color color = _i3.AppColors.black}) => [ boxShadow(color: color), ]; }