diff --git a/CHANGELOG.md b/CHANGELOG.md index a2128e8..15cafb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## 3.0.2 - Jul 25, 2022 - Fixed [#73](https://github.com/SimformSolutionsPvtLtd/flutter_credit_card/issues/73) - Pass AutovalidateMode to CreditCardForm +- Fixed [#82](https://github.com/SimformSolutionsPvtLtd/flutter_credit_card/issues/82) - Added support to add network image as card background +- Fixed [#46](https://github.com/SimformSolutionsPvtLtd/flutter_credit_card/issues/46) - Card number Regex issue for safari and web ## 3.0.1 - Oct 12, 2021 diff --git a/README.md b/README.md index df7a238..3bf56ee 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ import 'package:flutter_credit_card/flutter_credit_card.dart'; cardBgColor: Colors.black, glassmorphismConfig: Glassmorphism.defaultConfig(), backgroundImage: 'assets/card_bg.png', + backgroundNetworkImage: 'image-url' obscureCardNumber: true, obscureCardCvv: true, isHolderNameVisible: false, diff --git a/analysis_options.yaml b/analysis_options.yaml index a140058..08f6304 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -50,8 +50,6 @@ linter: - always_require_non_null_named_parameters - always_specify_types - annotate_overrides - # - avoid_annotating_with_dynamic # conflicts with always_specify_types - - avoid_as # - avoid_bool_literals_in_conditional_expressions # not yet tested # - avoid_catches_without_on_clauses # we do this commonly # - avoid_catching_errors # we do this commonly @@ -149,7 +147,6 @@ linter: - recursive_getters - slash_for_doc_comments - sort_constructors_first - - sort_pub_dependencies - sort_unnamed_constructors_first # - super_goes_last # no longer needed w/ Dart 2 - test_types_in_equals diff --git a/example/lib/main.dart b/example/lib/main.dart index c8976b9..3cc00dc 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,7 +1,5 @@ import 'package:flutter/material.dart'; import 'package:flutter_credit_card/credit_card_brand.dart'; -import 'package:flutter_credit_card/credit_card_form.dart'; -import 'package:flutter_credit_card/credit_card_model.dart'; import 'package:flutter_credit_card/flutter_credit_card.dart'; void main() => runApp(MySample()); diff --git a/lib/credit_card_background.dart b/lib/credit_card_background.dart index 9e3622b..70e4942 100644 --- a/lib/credit_card_background.dart +++ b/lib/credit_card_background.dart @@ -9,14 +9,21 @@ class CardBackground extends StatelessWidget { const CardBackground({ Key? key, required this.backgroundGradientColor, - required this.backgroundImage, + this.backgroundImage, + this.backgroundNetworkImage, required this.child, this.width, this.height, this.glassmorphismConfig, - }) : super(key: key); + }) : assert( + (backgroundImage == null && backgroundNetworkImage == null) || + (backgroundImage == null && backgroundNetworkImage != null) || + (backgroundImage != null && backgroundNetworkImage == null), + "You can't use network image & asset image at same time for card background"), + super(key: key); final String? backgroundImage; + final String? backgroundNetworkImage; final Widget child; final Gradient backgroundGradientColor; final Glassmorphism? glassmorphismConfig; @@ -42,14 +49,22 @@ class CardBackground extends StatelessWidget { gradient: glassmorphismConfig != null ? glassmorphismConfig!.gradient : backgroundGradientColor, - image: backgroundImage != null + image: backgroundImage != null && backgroundImage!.isNotEmpty ? DecorationImage( image: ExactAssetImage( backgroundImage!, ), fit: BoxFit.fill, ) - : null, + : backgroundNetworkImage != null && + backgroundNetworkImage!.isNotEmpty + ? DecorationImage( + image: NetworkImage( + backgroundNetworkImage!, + ), + fit: BoxFit.fill, + ) + : null, ), width: width ?? screenWidth, height: height ?? diff --git a/lib/credit_card_brand.dart b/lib/credit_card_brand.dart index fca0de7..8288220 100644 --- a/lib/credit_card_brand.dart +++ b/lib/credit_card_brand.dart @@ -1,7 +1,7 @@ import 'package:flutter_credit_card/flutter_credit_card.dart'; class CreditCardBrand { - CardType? brandName; CreditCardBrand(this.brandName); + CardType? brandName; } \ No newline at end of file diff --git a/lib/credit_card_widget.dart b/lib/credit_card_widget.dart index b44e3b7..108ea61 100644 --- a/lib/credit_card_widget.dart +++ b/lib/credit_card_widget.dart @@ -539,8 +539,9 @@ class _CreditCardWidgetState extends State } Widget getCardTypeImage(CardType? cardType) { - final List customCardTypeIcon = getCustomCardTypeIcon(cardType!); - if(customCardTypeIcon.isNotEmpty){ + final List customCardTypeIcon = + getCustomCardTypeIcon(cardType!); + if (customCardTypeIcon.isNotEmpty) { return customCardTypeIcon.first.cardImage; } else { return Image.asset( @@ -552,12 +553,13 @@ class _CreditCardWidgetState extends State } } - // This method returns the icon for the visa card type if found - // else will return the empty container + // This method returns the icon for the visa card type if found + // else will return the empty container Widget getCardTypeIcon(String cardNumber) { Widget icon; final CardType ccType = detectCCType(cardNumber); - final List customCardTypeIcon = getCustomCardTypeIcon(ccType); + final List customCardTypeIcon = + getCustomCardTypeIcon(ccType); if (customCardTypeIcon.isNotEmpty) { icon = customCardTypeIcon.first.cardImage; isAmex = ccType == CardType.americanExpress; diff --git a/lib/flutter_credit_card.dart b/lib/flutter_credit_card.dart index a1d6efe..ebdd307 100644 --- a/lib/flutter_credit_card.dart +++ b/lib/flutter_credit_card.dart @@ -3,5 +3,5 @@ library flutter_credit_card; export 'credit_card_form.dart'; export 'credit_card_model.dart'; export 'credit_card_widget.dart'; -export 'glassmorphism_config.dart'; export 'custom_card_type_icon.dart'; +export 'glassmorphism_config.dart'; diff --git a/lib/glassmorphism_config.dart b/lib/glassmorphism_config.dart index 1dc954b..1d4dfb6 100644 --- a/lib/glassmorphism_config.dart +++ b/lib/glassmorphism_config.dart @@ -1,5 +1,3 @@ -import 'dart:ui'; - import 'package:flutter/material.dart'; class Glassmorphism { diff --git a/pubspec.yaml b/pubspec.yaml index 6fb2712..8ec15b9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -14,6 +14,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + flutter_lints: ^2.0.1 flutter: assets: diff --git a/test/localized_text_model_test.dart b/test/localized_text_model_test.dart index 37e87d5..0aa88fe 100644 --- a/test/localized_text_model_test.dart +++ b/test/localized_text_model_test.dart @@ -1,5 +1,5 @@ -import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_credit_card/localized_text_model.dart'; +import 'package:flutter_test/flutter_test.dart'; void main() { test('Object correctly instantiated with properties', () {