Skip to content

Commit

Permalink
Add a simple way to override the default inside padding
Browse files Browse the repository at this point in the history
  • Loading branch information
vHanda committed Oct 31, 2022
1 parent a620edb commit a2af017
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/credit_card_background.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class CardBackground extends StatelessWidget {
this.width,
this.height,
this.glassmorphismConfig,
required this.padding,
}) : assert(
(backgroundImage == null && backgroundNetworkImage == null) ||
(backgroundImage == null && backgroundNetworkImage != null) ||
Expand All @@ -29,6 +30,7 @@ class CardBackground extends StatelessWidget {
final Glassmorphism? glassmorphismConfig;
final double? width;
final double? height;
final double padding;

@override
Widget build(BuildContext context) {
Expand All @@ -43,7 +45,7 @@ class CardBackground extends StatelessWidget {
alignment: Alignment.center,
children: <Widget>[
Container(
margin: const EdgeInsets.all(AppConstants.creditCardPadding),
margin: EdgeInsets.all(padding),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
gradient: glassmorphismConfig != null
Expand All @@ -69,8 +71,7 @@ class CardBackground extends StatelessWidget {
width: width ?? screenWidth,
height: height ??
(orientation == Orientation.portrait
? (((width ?? screenWidth) -
(AppConstants.creditCardPadding * 2)) *
? (((width ?? screenWidth) - (padding * 2)) *
AppConstants.creditCardAspectRatio)
: screenHeight / 2),
child: ClipRRect(
Expand Down
5 changes: 5 additions & 0 deletions lib/credit_card_widget.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter_credit_card/constants.dart';

import 'credit_card_animation.dart';
import 'credit_card_background.dart';
Expand Down Expand Up @@ -44,6 +45,7 @@ class CreditCardWidget extends StatefulWidget {
this.isSwipeGestureEnabled = true,
this.customCardTypeIcons = const <CustomCardTypeIcon>[],
required this.onCreditCardWidgetChange,
this.padding = AppConstants.creditCardPadding,
this.chipColor})
: super(key: key);

Expand Down Expand Up @@ -74,6 +76,7 @@ class CreditCardWidget extends StatefulWidget {

final CardType? cardType;
final List<CustomCardTypeIcon> customCardTypeIcons;
final double padding;

@override
_CreditCardWidgetState createState() => _CreditCardWidgetState();
Expand Down Expand Up @@ -264,6 +267,7 @@ class _CreditCardWidgetState extends State<CreditCardWidget>
glassmorphismConfig: widget.glassmorphismConfig,
height: widget.height,
width: widget.width,
padding: widget.padding,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expand Down Expand Up @@ -388,6 +392,7 @@ class _CreditCardWidgetState extends State<CreditCardWidget>
glassmorphismConfig: widget.glassmorphismConfig,
height: widget.height,
width: widget.width,
padding: widget.padding,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
Expand Down

0 comments on commit a2af017

Please sign in to comment.