|
1 | | - |
| 1 | + |
2 | 2 |
|
3 | 3 | # Flutter Credit Card |
4 | 4 |
|
|
7 | 7 |
|
8 | 8 | A Flutter package allows you to easily implement the Credit card's UI easily with the Card detection. |
9 | 9 |
|
10 | | -## Preview |
11 | | - |
12 | | -<table> |
13 | | - <tr> |
14 | | - <td align="center"> |
15 | | - <figure> |
16 | | - <figcaption><b>Glassmorphism and Card Background</b></figcaption> |
17 | | - <hr/> |
18 | | - <img src="https://raw.githubusercontent.com/SimformSolutionsPvtLtd/flutter_credit_card/master/readme_assets/preview.gif" alt="The example app showing credit card widget" width="227"/> |
19 | | - </figure> |
20 | | - </td> |
21 | | - </tr> |
22 | | -<tr><td></td></tr> |
23 | | - <tr> |
24 | | - <td align="center"> |
25 | | - <figure> |
26 | | - <figcaption><b>Floating Card on Mobile</b></figcaption> |
27 | | - <hr/> |
28 | | - <img src="https://raw.githubusercontent.com/SimformSolutionsPvtLtd/flutter_credit_card/master/readme_assets/credit_card_float_preview.gif" alt="The example app showing card floating animation in mobile" width="227"/> |
29 | | - </figure> |
30 | | - </td> |
31 | | - </tr> |
32 | | -<tr><td></td></tr> |
33 | | - <tr> |
34 | | - <td align="center"> |
35 | | - <figure> |
36 | | - <figcaption><b>Floating Card on Web</b></figcaption> |
37 | | - <hr/> |
38 | | - <img src="https://raw.githubusercontent.com/SimformSolutionsPvtLtd/flutter_credit_card/master/readme_assets/credit_card_float_cursor_preview.gif" alt="The example app showing card floating animation in web" width="227"/> |
39 | | - </figure> |
40 | | - </td> |
41 | | - </tr> |
42 | | -</table> |
43 | | - |
44 | | -## Migration guide for Version 4.x.x |
45 | | -- The `themeColor`, `textColor`, and `cursorColor` properties have been removed from `CreditCardForm` due to changes in how it detects and applies application themes. Please check out the example app to learn how to apply those using `Theme`. |
46 | | -- The `cardNumberDecoration`, `expiryDateDecoration`, `cvvCodeDecoration`, and `cardHolderDecoration` properties are moved to the newly added `InputDecoration` class that also has `textStyle` properties for all the textFields of the `CreditCardForm`. |
47 | | - |
48 | | - |
49 | | -## Installing |
50 | | - |
51 | | -1. Add dependency to `pubspec.yaml` |
52 | | - |
53 | | - Get the latest version from the 'Installing' tab on [pub.dev](https://pub.dev/packages/flutter_credit_card/install) |
54 | | - |
55 | | -```dart |
56 | | -dependencies: |
57 | | - flutter_credit_card: <latest_version> |
58 | | -``` |
59 | | - |
60 | | -2. Import the package |
61 | | -```dart |
62 | | -import 'package:flutter_credit_card/flutter_credit_card.dart'; |
63 | | -``` |
64 | | - |
65 | | -3. Adding CreditCardWidget |
| 10 | +_Check out other amazing open-source [Flutter libraries](https://simform-flutter-packages.web.app) and [Mobile libraries](https://github.com/SimformSolutionsPvtLtd/Awesome-Mobile-Libraries) developed by Simform Solutions!_ |
66 | 11 |
|
67 | | -*With required parameters* |
68 | | -```dart |
69 | | - CreditCardWidget( |
70 | | - cardNumber: cardNumber, |
71 | | - expiryDate: expiryDate, |
72 | | - cardHolderName: cardHolderName, |
73 | | - cvvCode: cvvCode, |
74 | | - showBackView: isCvvFocused, //true when you want to show cvv(back) view |
75 | | - onCreditCardWidgetChange: (CreditCardBrand brand) {}, // Callback for anytime credit card brand is changed |
76 | | - ), |
77 | | -``` |
78 | | - |
79 | | -*With optional parameters* |
80 | | -```dart |
81 | | - CreditCardWidget( |
82 | | - cardNumber: cardNumber, |
83 | | - expiryDate: expiryDate, |
84 | | - cardHolderName: cardHolderName, |
85 | | - cvvCode: cvvCode, |
86 | | - showBackView: isCvvFocused, |
87 | | - onCreditCardWidgetChange: (CreditCardBrand brand) {}, |
88 | | - bankName: 'Name of the Bank', |
89 | | - cardBgColor: Colors.black87, |
90 | | - glassmorphismConfig: Glassmorphism.defaultConfig(), |
91 | | - enableFloatingCard: true, |
92 | | - floatingConfig: FloatingConfig( |
93 | | - isGlareEnabled: true, |
94 | | - isShadowEnabled: true, |
95 | | - shadowConfig: FloatingShadowConfig(), |
96 | | - ), |
97 | | - backgroundImage: 'assets/card_bg.png', |
98 | | - backgroundNetworkImage: 'https://www.xyz.com/card_bg.png', |
99 | | - labelValidThru: 'VALID\nTHRU', |
100 | | - obscureCardNumber: true, |
101 | | - obscureInitialCardNumber: false, |
102 | | - obscureCardCvv: true, |
103 | | - labelCardHolder: 'CARD HOLDER', |
104 | | - labelValidThru: 'VALID\nTHRU', |
105 | | - cardType: CardType.mastercard, |
106 | | - isHolderNameVisible: false, |
107 | | - height: 175, |
108 | | - textStyle: TextStyle(color: Colors.yellowAccent), |
109 | | - width: MediaQuery.of(context).size.width, |
110 | | - isChipVisible: true, |
111 | | - isSwipeGestureEnabled: true, |
112 | | - animationDuration: Duration(milliseconds: 1000), |
113 | | - frontCardBorder: Border.all(color: Colors.grey), |
114 | | - backCardBorder: Border.all(color: Colors.grey), |
115 | | - chipColor: Colors.red, |
116 | | - padding: 16, |
117 | | - customCardTypeIcons: <CustomCardTypeIcons>[ |
118 | | - CustomCardTypeIcons( |
119 | | - cardType: CardType.mastercard, |
120 | | - cardImage: Image.asset( |
121 | | - 'assets/mastercard.png', |
122 | | - height: 48, |
123 | | - width: 48, |
124 | | - ), |
125 | | - ), |
126 | | - ], |
127 | | - ), |
128 | | -``` |
| 12 | +## Preview |
129 | 13 |
|
130 | | -*Glassmorphism UI* |
| 14 | + |
131 | 15 |
|
132 | | - + Default configuration |
133 | | -```dart |
134 | | - CreditCardWidget( |
135 | | - glassmorphismConfig: Glassmorphism.defaultConfig(), |
136 | | - ); |
137 | | -``` |
| 16 | +## Features |
138 | 17 |
|
139 | | - + Custom configuration |
140 | | -```dart |
141 | | - CreditCardWidget( |
142 | | - glassmorphismConfig: Glassmorphism( |
143 | | - blurX: 10.0, |
144 | | - blurY: 10.0, |
145 | | - gradient: LinearGradient( |
146 | | - begin: Alignment.topLeft, |
147 | | - end: Alignment.bottomRight, |
148 | | - colors: <Color>[ |
149 | | - Colors.grey.withAlpha(20), |
150 | | - Colors.white.withAlpha(20), |
151 | | - ], |
152 | | - stops: const <double>[ |
153 | | - 0.3, |
154 | | - 0, |
155 | | - ], |
156 | | - ), |
157 | | - ), |
158 | | - ), |
159 | | -``` |
| 18 | +- Beautiful credit card UI with customizable designs |
| 19 | +- Glassmorphism effect for modern card appearance |
| 20 | +- Floating card animation effect for both mobile and web |
| 21 | +- Card flip animation to show front and back views |
| 22 | +- Support for different card types (Visa, Mastercard, etc.) |
| 23 | +- Form validation for card details |
| 24 | +- Customizable input fields and decoration |
160 | 25 |
|
161 | | -*Floating Card* |
162 | 26 |
|
163 | | -+ Default Configuration |
164 | | -```dart |
165 | | - CreditCardWidget( |
166 | | - enableFloatingCard: true, |
167 | | - ); |
168 | | -``` |
| 27 | +## Documentation |
169 | 28 |
|
170 | | -+ Custom Configuration |
171 | | -```dart |
172 | | - CreditCardWidget( |
173 | | - enableFloatingCard: true, |
174 | | - floatingConfig: FloatingConfig( |
175 | | - isGlareEnabled: true, |
176 | | - isShadowEnabled: true, |
177 | | - shadowConfig: FloatingShadowConfig( |
178 | | - offset: Offset(10, 10), |
179 | | - color: Colors.black84, |
180 | | - blurRadius: 15, |
181 | | - ), |
182 | | - ), |
183 | | - ); |
184 | | -``` |
185 | | -> NOTE: Currently the floating card animation is not supported on mobile platform browsers. |
| 29 | +Visit our [documentation](https://simform-flutter-packages.web.app/creditCard) site for all implementation details, usage instructions, code examples, and advanced features. |
186 | 30 |
|
187 | | -4. Adding CreditCardForm |
| 31 | +## Installation |
188 | 32 |
|
189 | | -```dart |
190 | | - CreditCardForm( |
191 | | - formKey: formKey, // Required |
192 | | - cardNumber: cardNumber, // Required |
193 | | - expiryDate: expiryDate, // Required |
194 | | - cardHolderName: cardHolderName, // Required |
195 | | - cvvCode: cvvCode, // Required |
196 | | - cardNumberKey: cardNumberKey, |
197 | | - cvvCodeKey: cvvCodeKey, |
198 | | - expiryDateKey: expiryDateKey, |
199 | | - cardHolderKey: cardHolderKey, |
200 | | - onCreditCardModelChange: (CreditCardModel data) {}, // Required |
201 | | - obscureCvv: true, |
202 | | - obscureNumber: true, |
203 | | - isHolderNameVisible: true, |
204 | | - isCardNumberVisible: true, |
205 | | - isExpiryDateVisible: true, |
206 | | - enableCvv: true, |
207 | | - cvvValidationMessage: 'Please input a valid CVV', |
208 | | - dateValidationMessage: 'Please input a valid date', |
209 | | - numberValidationMessage: 'Please input a valid number', |
210 | | - cardNumberValidator: (String? cardNumber){}, |
211 | | - expiryDateValidator: (String? expiryDate){}, |
212 | | - cvvValidator: (String? cvv){}, |
213 | | - cardHolderValidator: (String? cardHolderName){}, |
214 | | - isCardHolderNameUpperCase: true, |
215 | | - onFormComplete: () { |
216 | | - // callback to execute at the end of filling card data |
217 | | - }, |
218 | | - autovalidateMode: AutovalidateMode.always, |
219 | | - disableCardNumberAutoFillHints: false, |
220 | | - inputConfiguration: const InputConfiguration( |
221 | | - cardNumberDecoration: InputDecoration( |
222 | | - border: OutlineInputBorder(), |
223 | | - labelText: 'Number', |
224 | | - hintText: 'XXXX XXXX XXXX XXXX', |
225 | | - ), |
226 | | - expiryDateDecoration: InputDecoration( |
227 | | - border: OutlineInputBorder(), |
228 | | - labelText: 'Expired Date', |
229 | | - hintText: 'XX/XX', |
230 | | - ), |
231 | | - cvvCodeDecoration: InputDecoration( |
232 | | - border: OutlineInputBorder(), |
233 | | - labelText: 'CVV', |
234 | | - hintText: 'XXX', |
235 | | - ), |
236 | | - cardHolderDecoration: InputDecoration( |
237 | | - border: OutlineInputBorder(), |
238 | | - labelText: 'Card Holder', |
239 | | - ), |
240 | | - cardNumberTextStyle: TextStyle( |
241 | | - fontSize: 10, |
242 | | - color: Colors.black, |
243 | | - ), |
244 | | - cardHolderTextStyle: TextStyle( |
245 | | - fontSize: 10, |
246 | | - color: Colors.black, |
247 | | - ), |
248 | | - expiryDateTextStyle: TextStyle( |
249 | | - fontSize: 10, |
250 | | - color: Colors.black, |
251 | | - ), |
252 | | - cvvCodeTextStyle: TextStyle( |
253 | | - fontSize: 10, |
254 | | - color: Colors.black, |
255 | | - ), |
256 | | - ), |
257 | | - ), |
| 33 | +```yaml |
| 34 | +dependencies: |
| 35 | + flutter_credit_card: <latest_version> |
258 | 36 | ``` |
259 | 37 |
|
260 | | -## How to use |
261 | | -Check out the **example** app in the [example](example) directory or the 'Example' tab on pub.dartlang.org for a more complete example. |
262 | | - |
263 | 38 | ## Credit |
264 | 39 |
|
265 | 40 | - This package's flip animation is inspired from this [Dribbble](https://dribbble.com/shots/2187649-Credit-card-Checkout-flow-AMEX) art. |
266 | 41 | - This package's float animation is inspired from the [Motion](https://pub.dev/packages/motion) flutter package. |
267 | 42 |
|
268 | | -## Main Contributors |
269 | | - |
270 | | -<table> |
271 | | - <tr> |
272 | | - <td align="center"><a href="https://github.com/vatsaltanna"><img src="https://avatars.githubusercontent.com/u/25323183?s=100" width="100px;" alt=""/><br /><sub><b>Vatsal Tanna</b></sub></a></td> |
273 | | - <td align="center"><a href="https://github.com/SanketKachhela"><img src="https://avatars.githubusercontent.com/u/20923896?s=100" width="100px;" alt=""/><br /><sub><b>Sanket Kachchela</b></sub></a></td> |
274 | | - <td align="center"><a href="https://github.com/kavantrivedi"><img src="https://avatars.githubusercontent.com/u/97207242?s=100" width="100px;" alt=""/><br /><sub><b>Kavan Trivedi</b></sub></a></td> |
275 | | - <td align="center"><a href="https://github.com/Ujas-Majithiya"><img src="https://avatars.githubusercontent.com/u/56400956?v=4" width="100px;" alt=""/><br /><sub><b>Ujas Majithiya</b></sub></a></td> |
276 | | - <td align="center"><a href="https://github.com/aditya-chavda"><img src="https://avatars.githubusercontent.com/u/41247722?v=4" width="100px;" alt=""/><br /><sub><b>Aditya Chavda</b></sub></a></td> |
277 | | - <td align="center"><a href="https://github.com/Flamingloon"><img src="https://avatars.githubusercontent.com/u/81063988?v=4" width="100px;" alt=""/><br /><sub><b>Sahil Totala</b></sub></a></td> |
278 | | - </tr> |
279 | | -</table> |
280 | | - |
281 | | -## Awesome Mobile Libraries |
282 | | -- Check out our other available [awesome mobile libraries](https://github.com/SimformSolutionsPvtLtd/Awesome-Mobile-Libraries) |
| 43 | +## Support |
283 | 44 |
|
284 | | -## Note |
285 | | -We have updated license of flutter_credit_card from BSD 2-Clause "Simplified" to MIT. |
| 45 | +For questions, issues, or feature requests, [create an issue](https://github.com/SimformSolutionsPvtLtd/flutter_credit_card/issues) on GitHub or reach out via the GitHub Discussions tab. We're happy to help and encourage community contributions. |
| 46 | +To contribute documentation updates specifically, please make changes to the doc/documentation.md file and submit a pull request. |
286 | 47 |
|
287 | 48 | ## License |
288 | 49 |
|
289 | | -``` |
290 | | -MIT License |
291 | | -
|
292 | | -Copyright (c) 2021 Simform Solutions |
293 | | -
|
294 | | -Permission is hereby granted, free of charge, to any person obtaining a copy |
295 | | -of this software and associated documentation files (the "Software"), to deal |
296 | | -in the Software without restriction, including without limitation the rights |
297 | | -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
298 | | -copies of the Software, and to permit persons to whom the Software is |
299 | | -furnished to do so, subject to the following conditions: |
300 | | -
|
301 | | -The above copyright notice and this permission notice shall be included in all |
302 | | -copies or substantial portions of the Software. |
303 | | -
|
304 | | -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
305 | | -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
306 | | -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
307 | | -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
308 | | -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
309 | | -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
310 | | -SOFTWARE. |
311 | | -``` |
| 50 | +This project is licensed under the MIT License - see the [LICENSE](https://simform-flutter-packages.web.app/creditCard/license) file for details. |
0 commit comments