Skip to content

Commit ed3166e

Browse files
authored
feat: added disableShowingCardLogo property (#10)
1 parent f42c441 commit ed3166e

File tree

6 files changed

+26
-7
lines changed

6 files changed

+26
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [1.0.6] 🛠️
6+
7+
### Feature
8+
9+
- 📝 Added `disableShowingCardLogo:` property to hide the card logo
510

611
## [1.0.5] 🛠️
712

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ CreditCardUi(
150150
),
151151
```
152152

153+
If you want to disable the card logo you can pass `disableShowingCardLogo: true`, but this property was introduced after v1.0.6
154+
153155
#### Additional Customizations
154156
To further customize the card, you can add a background image by using the `backgroundDecorationImage` property. Additionally, you can include a logo for the card provider using the `cardProviderLogo` property. This logo can be positioned on either the left or the right side of the card using the `cardProviderLogoPosition` property.
155157

example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class MyHomePage extends StatelessWidget {
3434
body: const Center(
3535
child: CreditCardUi(
3636
cardHolderFullName: 'John Doe',
37-
cardNumber: '1234567812345678',
37+
cardNumber: '4123456781234567',
3838
validFrom: '01/23',
3939
validThru: '01/28',
4040
topLeftColor: Colors.blue,

lib/src/u_credit_card.dart

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class CreditCardUi extends StatelessWidget {
5656
this.cardProviderLogo,
5757
this.cardProviderLogoPosition = CardProviderLogoPosition.right,
5858
this.backgroundDecorationImage,
59+
this.disableShowingCardLogo = false,
5960
});
6061

6162
/// Full Name of the Card Holder
@@ -126,6 +127,9 @@ class CreditCardUi extends StatelessWidget {
126127
/// Set Background image, can support both asset and network image
127128
final DecorationImage? backgroundDecorationImage;
128129

130+
/// Disable card type logo, just set to `true`
131+
final bool disableShowingCardLogo;
132+
129133
@override
130134
Widget build(BuildContext context) {
131135
final cardNumberMasked = CreditCardHelper.maskCreditCardNumber(
@@ -147,6 +151,17 @@ class CreditCardUi extends StatelessWidget {
147151
topLeftColor,
148152
);
149153

154+
Widget cardLogoWidget;
155+
final cardLogoString = CreditCardHelper.getCardLogo(cardNumberMasked);
156+
if (disableShowingCardLogo || cardLogoString.isEmpty) {
157+
cardLogoWidget = const SizedBox.shrink();
158+
} else {
159+
cardLogoWidget = Image.asset(
160+
CreditCardHelper.getCardLogo(cardNumberMasked),
161+
package: UiConstants.packageName,
162+
);
163+
}
164+
150165
return Transform.scale(
151166
scale: scale,
152167
child: SizedBox(
@@ -207,10 +222,7 @@ class CreditCardUi extends StatelessWidget {
207222
duration: UiConstants.animationDuration,
208223
child: Container(
209224
key: ValueKey(cardNumberMasked),
210-
child: Image.asset(
211-
CreditCardHelper.getCardLogo(cardNumberMasked),
212-
package: UiConstants.packageName,
213-
),
225+
child: cardLogoWidget,
214226
),
215227
),
216228
),

lib/src/utils/credit_card_helper.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class CreditCardHelper {
8888
case CreditCardType.discover:
8989
return Assets.discoverLogo;
9090
case CreditCardType.other:
91-
return Assets.visaLogo;
91+
return '';
9292
}
9393
}
9494
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: u_credit_card
22
description: uCreditCard - Easy to use beautiful Card UI Flutter Package.
3-
version: 1.0.5
3+
version: 1.0.6
44
homepage: 'https://github.com/utpal-barman/u-credit-card-flutter'
55

66
environment:

0 commit comments

Comments
 (0)