From 7f498fbf8f91a7267bbbf5d8ef9c924bfa43fe28 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62367544+tilucasoli@users.noreply.github.com> Date: Fri, 4 Oct 2024 17:50:09 -0300 Subject: [PATCH] Card has child instead of children parameter --- .../remix/lib/src/components/card/card.dart | 10 +++------- .../remix/lib/src/components/card/card.g.dart | 18 ------------------ .../lib/src/components/card/card_style.dart | 8 +------- .../lib/src/components/card/card_widget.dart | 12 ++++++------ 4 files changed, 10 insertions(+), 38 deletions(-) diff --git a/packages/remix/lib/src/components/card/card.dart b/packages/remix/lib/src/components/card/card.dart index 7bf85cb5a..eab016e73 100644 --- a/packages/remix/lib/src/components/card/card.dart +++ b/packages/remix/lib/src/components/card/card.dart @@ -16,8 +16,6 @@ part 'card_widget.dart'; base class CardSpec extends Spec with _$CardSpec, Diagnosticable { final BoxSpec container; - final FlexSpec flex; - /// {@macro card_spec_of} static const of = _$CardSpec.of; @@ -25,14 +23,12 @@ base class CardSpec extends Spec with _$CardSpec, Diagnosticable { const CardSpec({ BoxSpec? container, - FlexSpec? flex, super.modifiers, super.animated, - }) : container = container ?? const BoxSpec(), - flex = flex ?? const FlexSpec(); + }) : container = container ?? const BoxSpec(); - Widget call({Key? key, required List children}) { - return CardSpecWidget(key: key, spec: this, children: children); + Widget call({Key? key, required Widget child}) { + return CardSpecWidget(key: key, spec: this, child: child); } @override diff --git a/packages/remix/lib/src/components/card/card.g.dart b/packages/remix/lib/src/components/card/card.g.dart index a1ce8ab5e..fbf4b463f 100644 --- a/packages/remix/lib/src/components/card/card.g.dart +++ b/packages/remix/lib/src/components/card/card.g.dart @@ -34,13 +34,11 @@ mixin _$CardSpec on Spec { @override CardSpec copyWith({ BoxSpec? container, - FlexSpec? flex, WidgetModifiersData? modifiers, AnimatedData? animated, }) { return CardSpec( container: container ?? _$this.container, - flex: flex ?? _$this.flex, modifiers: modifiers ?? _$this.modifiers, animated: animated ?? _$this.animated, ); @@ -58,7 +56,6 @@ mixin _$CardSpec on Spec { /// interpolation method: /// /// - [BoxSpec.lerp] for [container]. - /// - [FlexSpec.lerp] for [flex]. /// For [modifiers] and [animated], the interpolation is performed using a step function. /// If [t] is less than 0.5, the value from the current [CardSpec] is used. Otherwise, the value @@ -72,7 +69,6 @@ mixin _$CardSpec on Spec { return CardSpec( container: _$this.container.lerp(other.container, t), - flex: _$this.flex.lerp(other.flex, t), modifiers: other.modifiers, animated: t < 0.5 ? _$this.animated : other.animated, ); @@ -85,7 +81,6 @@ mixin _$CardSpec on Spec { @override List get props => [ _$this.container, - _$this.flex, _$this.modifiers, _$this.animated, ]; @@ -95,8 +90,6 @@ mixin _$CardSpec on Spec { void _debugFillProperties(DiagnosticPropertiesBuilder properties) { properties.add( DiagnosticsProperty('container', _$this.container, defaultValue: null)); - properties - .add(DiagnosticsProperty('flex', _$this.flex, defaultValue: null)); properties.add( DiagnosticsProperty('modifiers', _$this.modifiers, defaultValue: null)); properties.add( @@ -114,11 +107,9 @@ mixin _$CardSpec on Spec { base class CardSpecAttribute extends SpecAttribute with Diagnosticable { final BoxSpecAttribute? container; - final FlexSpecAttribute? flex; const CardSpecAttribute({ this.container, - this.flex, super.modifiers, super.animated, }); @@ -135,7 +126,6 @@ base class CardSpecAttribute extends SpecAttribute CardSpec resolve(MixData mix) { return CardSpec( container: container?.resolve(mix), - flex: flex?.resolve(mix), modifiers: modifiers?.resolve(mix), animated: animated?.resolve(mix) ?? mix.animation, ); @@ -155,7 +145,6 @@ base class CardSpecAttribute extends SpecAttribute return CardSpecAttribute( container: container?.merge(other.container) ?? other.container, - flex: flex?.merge(other.flex) ?? other.flex, modifiers: modifiers?.merge(other.modifiers) ?? other.modifiers, animated: animated?.merge(other.animated) ?? other.animated, ); @@ -168,7 +157,6 @@ base class CardSpecAttribute extends SpecAttribute @override List get props => [ container, - flex, modifiers, animated, ]; @@ -178,7 +166,6 @@ base class CardSpecAttribute extends SpecAttribute super.debugFillProperties(properties); properties .add(DiagnosticsProperty('container', container, defaultValue: null)); - properties.add(DiagnosticsProperty('flex', flex, defaultValue: null)); properties .add(DiagnosticsProperty('modifiers', modifiers, defaultValue: null)); properties @@ -195,9 +182,6 @@ class CardSpecUtility /// Utility for defining [CardSpecAttribute.container] late final container = BoxSpecUtility((v) => only(container: v)); - /// Utility for defining [CardSpecAttribute.flex] - late final flex = FlexSpecUtility((v) => only(flex: v)); - /// Utility for defining [CardSpecAttribute.modifiers] late final wrap = SpecModifierUtility((v) => only(modifiers: v)); @@ -216,13 +200,11 @@ class CardSpecUtility @override T only({ BoxSpecAttribute? container, - FlexSpecAttribute? flex, WidgetModifiersDataDto? modifiers, AnimatedDataDto? animated, }) { return builder(CardSpecAttribute( container: container, - flex: flex, modifiers: modifiers, animated: animated, )); diff --git a/packages/remix/lib/src/components/card/card_style.dart b/packages/remix/lib/src/components/card/card_style.dart index bcc484632..b3145d2dd 100644 --- a/packages/remix/lib/src/components/card/card_style.dart +++ b/packages/remix/lib/src/components/card/card_style.dart @@ -15,13 +15,7 @@ class CardStyle extends SpecStyle { ..padding.all(8), ]; - final flexStyle = [ - $.flex.chain - ..mainAxisSize.min() - ..direction.vertical(), - ]; - - return Style.create([...containerStyle, ...flexStyle]); + return Style.create([...containerStyle]); } } diff --git a/packages/remix/lib/src/components/card/card_widget.dart b/packages/remix/lib/src/components/card/card_widget.dart index 62eef8afc..e81458991 100644 --- a/packages/remix/lib/src/components/card/card_widget.dart +++ b/packages/remix/lib/src/components/card/card_widget.dart @@ -3,13 +3,13 @@ part of 'card.dart'; class Card extends StatelessWidget { const Card({ super.key, - required this.children, + required this.child, this.style, this.variants = const [], }); /// The list of child widgets to be displayed inside the card. - final List children; + final Widget child; /// Additional custom styling for the card. /// @@ -28,7 +28,7 @@ class Card extends StatelessWidget { builder: (context) { final spec = CardSpec.of(context); - return CardSpecWidget(spec: spec, children: children); + return CardSpecWidget(spec: spec, child: child); }, ); } @@ -38,16 +38,16 @@ class CardSpecWidget extends StatelessWidget { const CardSpecWidget({ super.key, required this.spec, - required this.children, + required this.child, }); final CardSpec? spec; - final List children; + final Widget child; @override Widget build(BuildContext context) { return spec!.container( - child: spec!.flex(direction: Axis.vertical, children: children), + child: child, ); } }