flutter_card_io
flutter_card_io copied to clipboard
Reloading automatically many times using FutureBuilder
I am using a FutureBuilder with the scan card method, but when I finish the scan, the scan card screen shows again, I accept the new scan, but scan card screen shows again, the cycle never finishes until I cancel the scan. This is a snippet of my code:
Future<bool> _scanCard() async {
bool ok = false;
Map<String, dynamic> result = await FlutterCardIo.scanCard({
"requireExpiry": true,
"scanExpiry": true,
"requireCVV": false,
"requirePostalCode": false,
"restrictPostalCodeToNumericOnly": false,
"requireCardHolderName": false,
"scanInstructions": R.s("scanCardTitle")
});
ok = true;
}
@override
Widget build(BuildContext context) {
return FutureBuilder(future: _scanCard(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
return _customBuilder(context);
}
else return CircularProgressIndicator();
});
}
I will be very thankful if anyone shares an idea or solution. Best regards.
@crcaicedo Will test and fix this, It's probably too late for you but might help others