Skip to content

Commit

Permalink
Card has child instead of children parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
tilucasoli committed Oct 4, 2024
1 parent cc18c6f commit 027e29a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 38 deletions.
10 changes: 3 additions & 7 deletions packages/remix/lib/src/components/card/card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,19 @@ part 'card_widget.dart';
base class CardSpec extends Spec<CardSpec> with _$CardSpec, Diagnosticable {
final BoxSpec container;

final FlexSpec flex;

/// {@macro card_spec_of}
static const of = _$CardSpec.of;

static const from = _$CardSpec.from;

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<Widget> 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
Expand Down
18 changes: 0 additions & 18 deletions packages/remix/lib/src/components/card/card.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions packages/remix/lib/src/components/card/card_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ class CardStyle extends SpecStyle<CardSpecUtility> {
..padding.all(8),
];

final flexStyle = [
$.flex.chain
..mainAxisSize.min()
..direction.vertical(),
];

return Style.create([...containerStyle, ...flexStyle]);
return Style.create([...containerStyle]);
}
}
12 changes: 6 additions & 6 deletions packages/remix/lib/src/components/card/card_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Widget> children;
final Widget child;

/// Additional custom styling for the card.
///
Expand All @@ -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);
},
);
}
Expand All @@ -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<Widget> children;
final Widget child;

@override
Widget build(BuildContext context) {
return spec!.container(
child: spec!.flex(direction: Axis.vertical, children: children),
child: child,
);
}
}

0 comments on commit 027e29a

Please sign in to comment.