Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added configurable padding #133

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/src/golden_test_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ class FlutterGoldenTestAdapter extends GoldenTestAdapter {
maxHeight: constraints.maxHeight,
child: Center(
key: childKey,
child: widget,
child: Padding(
padding: goldenTestTheme.padding,
child: widget,
),
),
),
);
Expand Down
8 changes: 8 additions & 0 deletions lib/src/golden_test_theme.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:alchemist/src/golden_test_group.dart';
import 'package:alchemist/src/golden_test_scenario.dart';
import 'package:flutter/material.dart';

/// {@template golden_test_theme}
Expand All @@ -12,6 +13,7 @@ class GoldenTestTheme extends ThemeExtension<GoldenTestTheme> {
GoldenTestTheme({
required this.backgroundColor,
required this.borderColor,
this.padding = EdgeInsets.zero,
});

/// The standard theme for golden tests, used when no other theme is provided.
Expand All @@ -30,14 +32,19 @@ class GoldenTestTheme extends ThemeExtension<GoldenTestTheme> {
/// The border color used to separate scenarios in a [GoldenTestGroup].
final Color borderColor;

/// The padding that is used to wrap a [GoldenTestScenario]
final EdgeInsetsGeometry padding;
vanlooverenkoen marked this conversation as resolved.
Show resolved Hide resolved

@override
ThemeExtension<GoldenTestTheme> copyWith({
Color? backgroundColor,
Color? borderColor,
EdgeInsetsGeometry? padding,
}) {
return GoldenTestTheme(
backgroundColor: backgroundColor ?? this.backgroundColor,
borderColor: borderColor ?? this.borderColor,
padding: padding ?? this.padding,
);
}

Expand All @@ -53,6 +60,7 @@ class GoldenTestTheme extends ThemeExtension<GoldenTestTheme> {
backgroundColor: Color.lerp(backgroundColor, other.backgroundColor, t) ??
backgroundColor,
borderColor: Color.lerp(borderColor, other.borderColor, t) ?? borderColor,
padding: padding,
vanlooverenkoen marked this conversation as resolved.
Show resolved Hide resolved
);
}
}
1 change: 1 addition & 0 deletions test/src/golden_test_theme_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
goldenTestTheme: GoldenTestTheme(
backgroundColor: Colors.green,
borderColor: const Color(0xFF000000),
padding: EdgeInsets.zero,

Check notice on line 68 in test/src/golden_test_theme_test.dart

View workflow job for this annotation

GitHub Actions / analyze

The value of the argument is redundant because it matches the default value.

Try removing the argument. See https://dart.dev/lints/avoid_redundant_argument_values to learn more about this problem.
),
);

Expand Down
Loading