Skip to content

Commit

Permalink
[FIX] flutter 2.0 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Origogi committed Apr 3, 2021
1 parent 0b4355e commit cd8dfc8
Show file tree
Hide file tree
Showing 17 changed files with 130 additions and 125 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,8 @@

### v2.2.0

Add initial autofocus parameter
Add initial autofocus parameter

### v2.3.0

Flutter 2.0 migration
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
alt="Platform" />
</a>
<a href="https://pub.dev/packages/credit_card_input_form">
<img src="https://img.shields.io/badge/pub-v2.2.0-red" />
<img src="https://img.shields.io/badge/pub-v2.3.0-red" />

</a>
<a href="https://github.com/Solido/awesome-flutter">
Expand Down Expand Up @@ -42,7 +42,7 @@ This package provides visually beautiful UX through animation of credit card inf

```dart
dependencies:
credit_card_input_form: ^2.2.0
credit_card_input_form: ^2.3.0
```

2. Import the package
Expand Down
46 changes: 23 additions & 23 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,49 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0-nullsafety"
version: "2.5.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety"
version: "2.1.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.2"
version: "1.1.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety"
version: "1.2.0"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety"
version: "1.1.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0-nullsafety.2"
version: "1.15.0"
credit_card_input_form:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "2.2.0"
version: "2.3.0"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -63,14 +63,14 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety"
version: "1.2.0"
flip_card:
dependency: transitive
description:
name: flip_card
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.4"
version: "0.5.0"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -87,35 +87,35 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10-nullsafety"
version: "0.12.10"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.2"
version: "1.3.0"
nested:
dependency: transitive
description:
name: nested
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.4"
version: "1.0.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety"
version: "1.8.0"
provider:
dependency: transitive
description:
name: provider
url: "https://pub.dartlang.org"
source: hosted
version: "4.3.2+2"
version: "5.0.0"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -127,56 +127,56 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety"
version: "1.8.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety"
version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety"
version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety"
version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety"
version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19-nullsafety"
version: "0.2.19"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.2"
version: "1.3.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.2"
version: "2.1.0"
sdks:
dart: ">=2.10.0-0.0.dev <2.10.0"
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.16.0"
2 changes: 1 addition & 1 deletion lib/components/card_name.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class CardName extends StatelessWidget {
@override
Widget build(BuildContext context) {
final defaultName =
Provider.of<Captions>(context).getCaption('NAME_SURNAME').toUpperCase();
Provider.of<Captions>(context).getCaption('NAME_SURNAME')!.toUpperCase();
final String name =
Provider.of<CardNameProvider>(context).cardName.toUpperCase();

Expand Down
2 changes: 1 addition & 1 deletion lib/components/card_sign.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:credit_card_input_form/constants/constanst.dart';

class CardSign extends StatelessWidget {
const CardSign({
Key key,
Key? key,
}) : super(key: key);

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/components/card_valid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CardValid extends StatelessWidget {
String inputCardValid = Provider.of<CardValidProvider>(context).cardValid;

var defaultCardValid = Provider.of<Captions>(context)
.getCaption('MM_YY')
.getCaption('MM_YY')!
.substring(inputCardValid.length);

inputCardValid = inputCardValid.replaceAll("/", "");
Expand Down
4 changes: 2 additions & 2 deletions lib/components/front_card_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class FrontCardView extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
captions.getCaption('CARDHOLDER_NAME').toUpperCase(),
captions.getCaption('CARDHOLDER_NAME')!.toUpperCase(),
style: kTextStyle,
),
SizedBox(
Expand All @@ -61,7 +61,7 @@ class FrontCardView extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
captions.getCaption('VALID_THRU').toUpperCase(),
captions.getCaption('VALID_THRU')!.toUpperCase(),
style: kTextStyle,
),
SizedBox(
Expand Down
34 changes: 17 additions & 17 deletions lib/components/input_view_pager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class _InputViewPagerState extends State<InputViewPager> {

Provider.of<StateProvider>(context).addListener(() {
int index = Provider.of<StateProvider>(context, listen: false)
.getCurrentState()
.getCurrentState()!
.index;

if (index < focusNodes.length) {
Expand Down Expand Up @@ -78,14 +78,14 @@ class _InputViewPagerState extends State<InputViewPager> {
}

class InputForm extends StatefulWidget {
final String title;
final int index;
final PageController pageController;
final FocusNode focusNode;
final String? title;
final int? index;
final PageController? pageController;
final FocusNode? focusNode;
final isAutoFocus;

InputForm(
{@required this.title,
{required this.title,
this.index,
this.pageController,
this.focusNode,
Expand All @@ -98,35 +98,35 @@ class InputForm extends StatefulWidget {
class _InputFormState extends State<InputForm> {
var opacicy = 0.3;

int maxLength;
TextInputType textInputType;
int? maxLength;
TextInputType? textInputType;
TextEditingController textController = TextEditingController();

void onChange() {
setState(() {
if (widget.index == widget.pageController.page.round()) {
if (widget.index == widget.pageController!.page!.round()) {
opacicy = 1;
} else {
opacicy = 0.3;
}
});
}

String value;
String? value;

@override
void initState() {
super.initState();

int index = Provider.of<StateProvider>(context, listen: false)
.getCurrentState()
.getCurrentState()!
.index;

if (widget.index == index) {
opacicy = 1;
}

widget.pageController.addListener(onChange);
widget.pageController!.addListener(onChange);

if (widget.index == InputState.NUMBER.index) {
maxLength = 19;
Expand All @@ -152,7 +152,7 @@ class _InputFormState extends State<InputForm> {

@override
void dispose() {
widget.pageController.removeListener(onChange);
widget.pageController!.removeListener(onChange);

super.dispose();
}
Expand All @@ -161,7 +161,7 @@ class _InputFormState extends State<InputForm> {

@override
Widget build(BuildContext context) {
String textValue = "";
String? textValue = "";

if (widget.index == InputState.NUMBER.index) {
textValue =
Expand All @@ -177,7 +177,7 @@ class _InputFormState extends State<InputForm> {
}

int index = Provider.of<StateProvider>(context, listen: false)
.getCurrentState()
.getCurrentState()!
.index;

return Opacity(
Expand All @@ -187,7 +187,7 @@ class _InputFormState extends State<InputForm> {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
widget.title,
widget.title!,
style: TextStyle(fontSize: 12, color: Colors.black38),
),
SizedBox(
Expand All @@ -200,7 +200,7 @@ class _InputFormState extends State<InputForm> {
..value = textController.value.copyWith(
text: textValue,
selection: TextSelection.fromPosition(
TextPosition(offset: textValue.length),
TextPosition(offset: textValue!.length),
),
),
focusNode: widget.focusNode,
Expand Down
6 changes: 3 additions & 3 deletions lib/components/reset_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class ResetButton extends StatefulWidget {
final Function onTap;
final Function? onTap;
final decoration;
final textStyle;

Expand All @@ -21,7 +21,7 @@ class _ResetButtonState extends State<ResetButton> {
final captions = Provider.of<Captions>(context);

return GestureDetector(
onTap: widget.onTap,
onTap: widget.onTap as void Function()?,
onTapDown: (_) {
setState(() {
pressed = true;
Expand All @@ -46,7 +46,7 @@ class _ResetButtonState extends State<ResetButton> {
Icons.refresh,
color: Colors.white,
),
Text(captions.getCaption('RESET'), style: widget.textStyle)
Text(captions.getCaption('RESET')!, style: widget.textStyle)
],
),
)),
Expand Down
Loading

0 comments on commit cd8dfc8

Please sign in to comment.