Formatting and dart analyze fixes
This commit is contained in:
parent
f23805a3a8
commit
1668ab8947
|
@ -68,7 +68,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(
|
const Text(
|
||||||
'Enter your card details below:',
|
'Enter your card details below:',
|
||||||
),
|
),
|
||||||
CardTextField(
|
CardTextField(
|
||||||
|
|
|
@ -37,7 +37,6 @@ class CardDetails {
|
||||||
int _lastCheckHash = 0;
|
int _lastCheckHash = 0;
|
||||||
CardProvider? provider;
|
CardProvider? provider;
|
||||||
|
|
||||||
|
|
||||||
/// Checks the validity of the `CardDetails` and returns the result.
|
/// Checks the validity of the `CardDetails` and returns the result.
|
||||||
ValidState get validState {
|
ValidState get validState {
|
||||||
checkIsValid();
|
checkIsValid();
|
||||||
|
@ -59,7 +58,7 @@ class CardDetails {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The maximum length of the INN (identifier)
|
/// The maximum length of the INN (identifier)
|
||||||
/// of a card provider.
|
/// of a card provider.
|
||||||
int get maxINNLength => 4;
|
int get maxINNLength => 4;
|
||||||
|
|
||||||
/// Validates each field of the `CardDetails` object in entry order,
|
/// Validates each field of the `CardDetails` object in entry order,
|
||||||
|
@ -265,11 +264,11 @@ enum CardProviderID {
|
||||||
|
|
||||||
/// Encapsulates criteria for Card Providers in the U.S.
|
/// Encapsulates criteria for Card Providers in the U.S.
|
||||||
/// Used by `CardDetails.detectCardProvider()` to determine
|
/// Used by `CardDetails.detectCardProvider()` to determine
|
||||||
/// a card's Provider.
|
/// a card's Provider.
|
||||||
class CardProvider {
|
class CardProvider {
|
||||||
CardProviderID id;
|
CardProviderID id;
|
||||||
List<int>? innValidNums;
|
List<int>? innValidNums;
|
||||||
List<_Range>? innValidRanges;
|
List<Range>? innValidRanges;
|
||||||
int cardLength;
|
int cardLength;
|
||||||
int cvcLength;
|
int cvcLength;
|
||||||
|
|
||||||
|
@ -289,12 +288,12 @@ class CardProvider {
|
||||||
|
|
||||||
/// Object for `CardProvider` to determine valid number ranges.
|
/// Object for `CardProvider` to determine valid number ranges.
|
||||||
/// A loose wrapper on a tuple, that provides assertion of
|
/// A loose wrapper on a tuple, that provides assertion of
|
||||||
/// valid inputs and the `isWithin()` helper function.
|
/// valid inputs and the `isWithin()` helper function.
|
||||||
class _Range {
|
class Range {
|
||||||
int high;
|
int high;
|
||||||
int low;
|
int low;
|
||||||
|
|
||||||
_Range({required this.low, required this.high}) {
|
Range({required this.low, required this.high}) {
|
||||||
assert(low <= high);
|
assert(low <= high);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,7 +327,7 @@ List<CardProvider> _providers = [
|
||||||
cardLength: 16,
|
cardLength: 16,
|
||||||
cvcLength: 3,
|
cvcLength: 3,
|
||||||
innValidNums: [60, 65],
|
innValidNums: [60, 65],
|
||||||
innValidRanges: [_Range(low: 644, high: 649)],
|
innValidRanges: [Range(low: 644, high: 649)],
|
||||||
),
|
),
|
||||||
CardProvider(
|
CardProvider(
|
||||||
id: CardProviderID.jcb,
|
id: CardProviderID.jcb,
|
||||||
|
@ -340,7 +339,7 @@ List<CardProvider> _providers = [
|
||||||
id: CardProviderID.mastercard,
|
id: CardProviderID.mastercard,
|
||||||
cardLength: 16,
|
cardLength: 16,
|
||||||
cvcLength: 3,
|
cvcLength: 3,
|
||||||
innValidRanges: [_Range(low: 22, high: 27), _Range(low: 51, high: 55)],
|
innValidRanges: [Range(low: 22, high: 27), Range(low: 51, high: 55)],
|
||||||
),
|
),
|
||||||
CardProvider(
|
CardProvider(
|
||||||
id: CardProviderID.visa,
|
id: CardProviderID.visa,
|
||||||
|
|
|
@ -31,8 +31,9 @@ class CardTextField extends StatefulWidget {
|
||||||
|
|
||||||
final InputDecoration? inputDecoration; // TODO unapplied style
|
final InputDecoration? inputDecoration; // TODO unapplied style
|
||||||
final BoxDecoration? boxDecoration; // TODO unapplied style
|
final BoxDecoration? boxDecoration; // TODO unapplied style
|
||||||
final BoxDecoration? errorBoxDecoration; // TODO unapplied style
|
final BoxDecoration? errorBoxDecoration; // TODO unapplied style
|
||||||
final double width;
|
final double width;
|
||||||
|
|
||||||
/// Callback that returns the completed CardDetails object
|
/// Callback that returns the completed CardDetails object
|
||||||
final void Function(CardDetails) onCardDetailsComplete;
|
final void Function(CardDetails) onCardDetailsComplete;
|
||||||
final double? height;
|
final double? height;
|
||||||
|
@ -403,7 +404,7 @@ class CardTextFieldState extends State<CardTextField> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Used when `_isWideFormat == false`, scrolls
|
/// Used when `_isWideFormat == false`, scrolls
|
||||||
/// the `_horizontalScrollController` to a given offset
|
/// the `_horizontalScrollController` to a given offset
|
||||||
void _scrollRow(CardEntryStep step) {
|
void _scrollRow(CardEntryStep step) {
|
||||||
const dur = Duration(milliseconds: 150);
|
const dur = Duration(milliseconds: 150);
|
||||||
const cur = Curves.easeOut;
|
const cur = Curves.easeOut;
|
||||||
|
@ -515,7 +516,7 @@ class CardNumberInputFormatter implements TextInputFormatter {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Formatter that adds a backslash '/' character in between
|
/// Formatter that adds a backslash '/' character in between
|
||||||
/// the month and the year for the expiration date.
|
/// the month and the year for the expiration date.
|
||||||
class CardExpirationFormatter implements TextInputFormatter {
|
class CardExpirationFormatter implements TextInputFormatter {
|
||||||
@override
|
@override
|
||||||
TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
|
TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user