Skip to content

Commit

Permalink
Merge pull request #111 from vHanda/master
Browse files Browse the repository at this point in the history
Add a simple way to override the default inside padding
  • Loading branch information
ShwetaChauhan18 authored Nov 7, 2022
2 parents a620edb + 501d1d5 commit 30dbbb7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# [3.0.6](https://github.com/SimformSolutionsPvtLtd/flutter_credit_card/tree/3.0.6)

- Enhancement [#111](https://github.com/SimformSolutionsPvtLtd/flutter_credit_card/pull/111) Added Support for controlling the internal padding.

# [3.0.5](https://github.com/SimformSolutionsPvtLtd/flutter_credit_card/tree/3.0.5)

- New card brands (Elo/Hipercard) was added [#109](https://github.com/SimformSolutionsPvtLtd/flutter_credit_card/pull/109)
Expand Down
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 30dbbb7

Please sign in to comment.