nfc plugin improvement.

merge-update-with-lab-changes
Sikander Saleem 4 years ago
parent 2fd0fd3f85
commit 2a92478d01

@ -28,7 +28,7 @@ apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android { android {
compileSdkVersion 30 compileSdkVersion 31
sourceSets { sourceSets {
main.java.srcDirs += 'src/main/kotlin' main.java.srcDirs += 'src/main/kotlin'
@ -111,8 +111,7 @@ dependencies {
implementation "com.opentok.android:opentok-android-sdk:2.19.1" implementation "com.opentok.android:opentok-android-sdk:2.19.1"
implementation 'com.facebook.stetho:stetho:1.5.1'
compile 'com.facebook.stetho:stetho:1.5.1'
implementation 'com.facebook.stetho:stetho-urlconnection:1.5.1' implementation 'com.facebook.stetho:stetho-urlconnection:1.5.1'

@ -13,7 +13,7 @@
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" /> <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/> <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.RECORD_AUDIO" />
@ -22,18 +22,24 @@
<uses-permission android:name="android.permission.READ_CALENDAR" /> <uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" /> <uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-feature android:name="android.hardware.location.network" android:required="false" />
<uses-feature android:name="android.hardware.location.gps" android:required="false" /> <uses-feature
<uses-permission android:name="com.huawei.appmarket.service.commondata.permission.GET_COMMON_DATA"/> android:name="android.hardware.location.network"
android:required="false" />
<uses-feature
android:name="android.hardware.location.gps"
android:required="false" />
<uses-permission android:name="com.huawei.appmarket.service.commondata.permission.GET_COMMON_DATA" />
<!-- Wifi Permissions--> <!-- Wifi Permissions-->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<!-- Detect Reboot Permission --> <!-- Detect Reboot Permission -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<queries> <queries>
<intent> <intent>
<action android:name="android.speech.RecognitionService" /> <action android:name="android.speech.RecognitionService" />
@ -42,10 +48,10 @@
<application <application
android:name=".Application" android:name=".Application"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:usesCleartextTraffic="true" android:label="Dr. Alhabib"
android:showOnLockScreen="true"
android:screenOrientation="sensorPortrait" android:screenOrientation="sensorPortrait"
android:label="Dr. Alhabib"> android:showOnLockScreen="true"
android:usesCleartextTraffic="true">
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
@ -81,31 +87,44 @@
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver"> <receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/> <action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/> <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
</intent-filter> </intent-filter>
</receiver> </receiver>
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" /> <receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
<!-- Geofencing --> <!-- Geofencing -->
<service android:name=".geofence.intent_receivers.GeofenceTransitionsJobIntentService" android:exported="true" android:permission="android.permission.BIND_JOB_SERVICE" /> <service
<receiver android:name=".geofence.intent_receivers.GeofenceBroadcastReceiver" android:enabled="true" android:exported="true" /> android:name=".geofence.intent_receivers.GeofenceTransitionsJobIntentService"
<receiver android:name=".geofence.intent_receivers.GeofencingRebootBroadcastReceiver" android:enabled="true"> android:exported="true"
android:permission="android.permission.BIND_JOB_SERVICE" />
<receiver
android:name=".geofence.intent_receivers.GeofenceBroadcastReceiver"
android:enabled="true"
android:exported="true" />
<receiver
android:name=".geofence.intent_receivers.GeofencingRebootBroadcastReceiver"
android:enabled="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/> <action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/> <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
</intent-filter> </intent-filter>
</receiver> </receiver>
<receiver android:name=".geofence.intent_receivers.LocationProviderChangeReceiver"> <receiver android:name=".geofence.intent_receivers.LocationProviderChangeReceiver">
<intent-filter> <intent-filter>
<action android:name="android.location.PROVIDERS_CHANGED"/> <action android:name="android.location.PROVIDERS_CHANGED" />
</intent-filter> </intent-filter>
</receiver> </receiver>
<service android:name=".geofence.intent_receivers.ReregisterGeofenceJobService" android:permission="android.permission.BIND_JOB_SERVICE" />
<service
android:name=".geofence.intent_receivers.ReregisterGeofenceJobService"
android:permission="android.permission.BIND_JOB_SERVICE" />
<!-- Geofencing --> <!-- Geofencing -->
<meta-data android:name="com.google.android.geo.API_KEY" <meta-data
android:value="AIzaSyCyDbWUM9d_sBUGIE8PcuShzPaqO08NSC8"/> android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyCyDbWUM9d_sBUGIE8PcuShzPaqO08NSC8" />
<!-- Don't delete the meta-data below. <!-- Don't delete the meta-data below.
@ -115,6 +134,7 @@
android:value="2" /> android:value="2" />
</application> </application>
z
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" /> <uses-permission android:name="android.permission.USE_FINGERPRINT" />
@ -122,5 +142,4 @@
<uses-permission android:name="android.permission.WRITE_CALENDAR" /> <uses-permission android:name="android.permission.WRITE_CALENDAR" />
</manifest> </manifest>

@ -1,5 +1,5 @@
buildscript { buildscript {
ext.kotlin_version = '1.3.50' ext.kotlin_version = '1.6.0'
repositories { repositories {
google() google()
jcenter() jcenter()
@ -11,10 +11,11 @@ buildscript {
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.5.4' classpath 'com.android.tools.build:gradle:7.0.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.8' classpath 'com.google.gms:google-services:4.3.8'
classpath 'com.huawei.agconnect:agcp:1.4.2.301' classpath 'com.huawei.agconnect:agcp:1.5.2.300'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.12'
} }
} }
@ -26,7 +27,7 @@ allprojects {
maven { maven {
url 'https://developer.huawei.com/repo/' url 'https://developer.huawei.com/repo/'
} }
maven{ maven {
url "https://artifactory.ess-dev.com/artifactory/gradle-dev-local" url "https://artifactory.ess-dev.com/artifactory/gradle-dev-local"
} }
} }

@ -1,4 +1,4 @@
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx2048m
android.enableR8=true android.enableR8=true
android.useAndroidX=true android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip

@ -201,7 +201,7 @@ class _BookConfirmState extends State<BookConfirm> {
disabledTextColor: Colors.white, disabledTextColor: Colors.white,
disabledColor: new Color(0xFFbcc2c4), disabledColor: new Color(0xFFbcc2c4),
onPressed: () async { onPressed: () async {
if (!await this.sharedPref.getBool(IS_LIVECARE_APPOINTMENT)) { if (!(await this.sharedPref.getBool(IS_LIVECARE_APPOINTMENT)??false)) {
insertAppointment(context, widget.doctor); insertAppointment(context, widget.doctor);
} else { } else {
insertLiveCareScheduledAppointment(context, widget.doctor); insertLiveCareScheduledAppointment(context, widget.doctor);

@ -17,7 +17,7 @@ import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart';
import 'package:diplomaticquarterapp/widgets/nfc/nfc_reader_sheet.dart'; import 'package:diplomaticquarterapp/widgets/nfc/nfc_reader_sheet.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:nfc_in_flutter/nfc_in_flutter.dart'; import 'package:flutter_nfc_kit/flutter_nfc_kit.dart';
class QRCode extends StatefulWidget { class QRCode extends StatefulWidget {
PatientShareResponse patientShareResponse; PatientShareResponse patientShareResponse;
@ -42,11 +42,11 @@ class _QRCodeState extends State<QRCode> {
_bytes = base64.decode(widget.appoQR.split(',').last); _bytes = base64.decode(widget.appoQR.split(',').last);
widget.authUser = new AuthenticatedUser(); widget.authUser = new AuthenticatedUser();
NFC.isNDEFSupported.then((supported) {
setState(() { FlutterNfcKit.nfcAvailability.then((value) {
_supportsNFC = true; _supportsNFC = (value == NFCAvailability.available);
});
}); });
super.initState(); super.initState();
} }

@ -94,14 +94,13 @@ class _ClickListDialogState extends State<ClickListDialog> {
return InkWell( return InkWell(
onTap: () { onTap: () {
widget.onSelection(tempClinicsList[index]); widget.onSelection(tempClinicsList[index]);
}, },
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Expanded(child: Text(tempClinicsList[index].clinicDescription)), Expanded(child: Text(tempClinicsList[index].clinicDescription.trim())),
tempClinicsList[index].isLiveCareClinicAndOnline tempClinicsList[index].isLiveCareClinicAndOnline
? SvgPicture.asset( ? SvgPicture.asset(
'assets/images/new-design/video_icon_green_right.svg', 'assets/images/new-design/video_icon_green_right.svg',

@ -33,7 +33,6 @@ class PrescriptionReminderDialog extends StatefulWidget {
} }
class _ReminderDialogState extends State<PrescriptionReminderDialog> { class _ReminderDialogState extends State<PrescriptionReminderDialog> {
final CalendarPlugin _myPlugin = CalendarPlugin();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

@ -6,7 +6,6 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
class PaymentDialog extends StatefulWidget { class PaymentDialog extends StatefulWidget {
AppoitmentAllHistoryResultList appo; AppoitmentAllHistoryResultList appo;
@ -23,96 +22,90 @@ class PaymentDialog extends StatefulWidget {
class _PaymentDialogState extends State<PaymentDialog> { class _PaymentDialogState extends State<PaymentDialog> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Dialog(
child: Dialog( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)), child: Container(
child: Container( //height: 550.0,
height: 550.0, width: 450.0,
width: 450.0, padding: EdgeInsets.all(21),
child: Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: <Widget>[ child: Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: <Widget>[
Container( Text(
margin: EdgeInsets.fromLTRB(20.0, 20.0, 20.0, 5.0), TranslationBase.of(context).invoiceDetails,
child: Text(TranslationBase.of(context).invoiceDetails, style: TextStyle(fontSize: 25.0, fontWeight: FontWeight.w600)), style: TextStyle(
), fontSize: 24.0,
Container( fontWeight: FontWeight.w600,
margin: EdgeInsets.fromLTRB(20.0, 5.0, 20.0, 0.0), letterSpacing: -1.14,
child: Text(widget.appo.doctorTitle + " " + widget.appo.doctorNameObj, style: TextStyle(color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600)), color: Color(0xff2B353E),
),
Container(
margin: EdgeInsets.fromLTRB(20.0, 5.0, 20.0, 0.0),
child: Text(getDate(widget.appo.appointmentDate), style: getTextStyle()),
),
Container(
margin: EdgeInsets.fromLTRB(20.0, 5.0, 20.0, 0.0),
child: Text(widget.appo.projectName, style: getTextStyle()),
),
Divider(
color: Colors.grey,
),
Container(
margin: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 5.0),
child: Table(
children: [
TableRow(decoration: BoxDecoration(), children: [
TableCell(child: _getNormalText(TranslationBase.of(context).patientShareToDo)),
TableCell(child: _getNormalText(widget.patientShareResponse.patientShare.toString())),
]),
TableRow(children: [
TableCell(child: _getNormalText(TranslationBase.of(context).patientTaxToDo)),
TableCell(child: _getNormalText(widget.patientShareResponse.patientTaxAmount.toString())),
]),
TableRow(children: [
TableCell(child: _getNormalText(TranslationBase.of(context).patientShareTotalToDo)),
TableCell(child: _getNormalText(widget.patientShareResponse.patientShareWithTax.toString())),
]),
],
),
),
Divider(
color: Colors.grey,
),
Container(
margin: EdgeInsets.fromLTRB(20.0, 20.0, 20.0, 5.0),
child: Text(TranslationBase.of(context).YouCanPayByTheFollowingOptions, style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w600)),
), ),
Container(margin: EdgeInsets.fromLTRB(20.0, 5.0, 20.0, 5.0), child: getPaymentMethods()), ),
Container( Text(widget.appo.doctorTitle + " " + widget.appo.doctorNameObj, style: TextStyle(color: Color(0xff2E303A), fontSize: 16.0, fontWeight: FontWeight.w600,letterSpacing: -0.64)),
margin: EdgeInsets.fromLTRB(20.0, 30.0, 20.0, 15.0), Text(getDate(widget.appo.appointmentDate), style: getTextStyle()),
child: Text(TranslationBase.of(context).appoPaymentConfirm, style: TextStyle(fontSize: 14.0, color: CustomColors.accentColor, fontWeight: FontWeight.w600)), Text(widget.appo.projectName, style: getTextStyle()),
Divider(
color: Colors.grey,
),
Table(
children: [
TableRow(decoration: BoxDecoration(), children: [
TableCell(child: _getNormalText(TranslationBase.of(context).patientShareToDo)),
TableCell(child: _getNormalText(widget.patientShareResponse.patientShare.toString())),
]),
TableRow(children: [
TableCell(child: _getNormalText(TranslationBase.of(context).patientTaxToDo)),
TableCell(child: _getNormalText(widget.patientShareResponse.patientTaxAmount.toString())),
]),
TableRow(children: [
TableCell(child: _getNormalText(TranslationBase.of(context).patientShareTotalToDo)),
TableCell(child: _getNormalText(widget.patientShareResponse.patientShareWithTax.toString())),
]),
],
),
Divider(color: Colors.grey),
Text(
TranslationBase.of(context).YouCanPayByTheFollowingOptions,
style: TextStyle(
fontSize: 14.0,
fontWeight: FontWeight.w600,
color: Color(0xff2E303A),
), ),
Container( ),
alignment: Alignment.center, getPaymentMethods(),
height: 40.0, SizedBox(height: 12),
margin: EdgeInsets.only(left: 20.0, right: 20.0, top: 20.0), Text(
child: Flex( TranslationBase.of(context).appoPaymentConfirm,
direction: Axis.horizontal, style: TextStyle(fontSize: 14.0, color: CustomColors.accentColor, fontWeight: FontWeight.w600, letterSpacing: -0.56),
children: <Widget>[ ),
Expanded( SizedBox(height: 12),
child: DefaultButton( Container(
TranslationBase.of(context).cancel_nocaps, alignment: Alignment.center,
() { child: Row(
Navigator.pop(context, null); // direction: Axis.horizontal,
}, children: <Widget>[
color: CustomColors.accentColor, Expanded(
textColor: Colors.white, child: DefaultButton(
), TranslationBase.of(context).cancel_nocaps,
() {
Navigator.pop(context, null);
},
color: CustomColors.accentColor,
textColor: Colors.white,
), ),
mWidth(10.0), ),
Expanded( mWidth(10.0),
child: DefaultButton( Expanded(
TranslationBase.of(context).confirm, child: DefaultButton(
() { TranslationBase.of(context).confirm,
Navigator.pop(context, widget.patientShareResponse); () {
}, Navigator.pop(context, widget.patientShareResponse);
color: CustomColors.green, },
textColor: Colors.white, color: CustomColors.green,
), textColor: Colors.white,
), ),
], ),
), ],
), ),
]), ),
), ]),
), ),
); );
} }
@ -120,21 +113,17 @@ class _PaymentDialogState extends State<PaymentDialog> {
_getNormalText(text) { _getNormalText(text) {
return Container( return Container(
margin: EdgeInsets.only(top: 10.0, right: 10.0), margin: EdgeInsets.only(top: 10.0, right: 10.0),
child: Text(text, style: TextStyle(fontSize: 13, letterSpacing: 0.5, color: Colors.black)), child: Text(text, style: TextStyle(fontSize: 13, letterSpacing: 0.5, color: Color(0xff2E303A))),
); );
} }
TextStyle getTextStyle() { TextStyle getTextStyle() {
return TextStyle(color: Colors.grey[700], fontSize: 13.0, fontWeight: FontWeight.w600); return TextStyle(color: Color(0xff575757), fontSize: 13.0, fontWeight: FontWeight.w600);
} }
String getDate(String date) { String getDate(String date) {
DateTime dateObj = DateUtil.convertStringToDate(date); DateTime dateObj = DateUtil.convertStringToDate(date);
return DateUtil.getDayMonthYearDateFormatted(dateObj) + return DateUtil.getDayMonthYearDateFormatted(dateObj) + " " + dateObj.hour.toString() + ":" + getMinute(dateObj);
" " +
dateObj.hour.toString() +
":" +
getMinute(dateObj);
} }
String getMinute(DateTime dateObj) { String getMinute(DateTime dateObj) {

@ -340,11 +340,6 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
if (!isPageNavigated) { if (!isPageNavigated) {
isPageNavigated = true; isPageNavigated = true;
Navigator.push(context, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: LandingPage.incomingCallData))).then((value) { Navigator.push(context, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: LandingPage.incomingCallData))).then((value) {
Future.delayed(Duration(seconds: 5), () { Future.delayed(Duration(seconds: 5), () {
isPageNavigated = false; isPageNavigated = false;

@ -1,7 +1,5 @@
import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:nfc_in_flutter/nfc_in_flutter.dart'; import 'package:flutter_nfc_kit/flutter_nfc_kit.dart';
void showNfcReader(BuildContext context, {Function onNcfScan}) { void showNfcReader(BuildContext context, {Function onNcfScan}) {
showModalBottomSheet( showModalBottomSheet(
@ -9,8 +7,7 @@ void showNfcReader(BuildContext context, {Function onNcfScan}) {
enableDrag: false, enableDrag: false,
isDismissible: false, isDismissible: false,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(topLeft: Radius.circular(12), topRight: Radius.circular(12)),
topLeft: Radius.circular(12), topRight: Radius.circular(12)),
), ),
backgroundColor: Colors.white, backgroundColor: Colors.white,
builder: (context) { builder: (context) {
@ -30,7 +27,6 @@ class NfcLayout extends StatefulWidget {
} }
class _NfcLayoutState extends State<NfcLayout> { class _NfcLayoutState extends State<NfcLayout> {
StreamSubscription<NDEFMessage> _stream;
bool _reading = false; bool _reading = false;
Widget mainWidget; Widget mainWidget;
String nfcId; String nfcId;
@ -38,47 +34,28 @@ class _NfcLayoutState extends State<NfcLayout> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
readNFC();
}
setState(() { void readNFC() async {
// _reading = true; FlutterNfcKit.poll(timeout: Duration(seconds: 10), androidPlatformSound: false, iosMultipleTagMessage: "Multiple tags found!").then((value) async {
// Start reading using NFC.readNDEF() setState(() {
_stream = NFC _reading = true;
.readNDEF( mainWidget = doneNfc();
once: false,
throwOnUserCancel: false,
readerMode: NFCDispatchReaderMode())
.listen((NDEFMessage message) {
setState(() {
_reading = true;
mainWidget = doneNfc();
});
Future.delayed(const Duration(milliseconds: 500), () {
_stream?.cancel();
widget.onNcfScan(nfcId);
Navigator.pop(context);
});
print("read NDEF id: ${message.id}");
print("NFC Record "+message.payload);
print("NFC Record Lenght "+message.records.length.toString());
print("NFC Record "+message.records.first.id);
print("NFC Record "+message.records.first.payload);
print("NFC Record "+message.records.first.data);
print("NFC Record "+message.records.first.type);
// widget.onNcfScan(message.id);
nfcId = message.id;
}, onError: (e) {
// Check error handling guide below
}); });
Future.delayed(const Duration(milliseconds: 500), () async {
await FlutterNfcKit.finish();
widget.onNcfScan(nfcId);
Navigator.pop(context);
});
nfcId = value.id;
}); });
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
(mainWidget == null && !_reading) (mainWidget == null && !_reading) ? mainWidget = scanNfc() : mainWidget = doneNfc();
? mainWidget = scanNfc() return AnimatedSwitcher(duration: Duration(milliseconds: 500), child: mainWidget);
: mainWidget = doneNfc();
return AnimatedSwitcher(
duration: Duration(milliseconds: 500), child: mainWidget);
} }
Widget scanNfc() { Widget scanNfc() {
@ -125,7 +102,7 @@ class _NfcLayoutState extends State<NfcLayout> {
), ),
child: RaisedButton( child: RaisedButton(
onPressed: () { onPressed: () {
_stream?.cancel(); // _stream?.cancel();
Navigator.pop(context); Navigator.pop(context);
}, },
elevation: 0, elevation: 0,
@ -189,7 +166,7 @@ class _NfcLayoutState extends State<NfcLayout> {
// Navigator.pop(context); // Navigator.pop(context);
// }, // },
onPressed: null, onPressed: null,
elevation: 0, elevation: 0,
child: Text("DONE"), child: Text("DONE"),
), ),
), ),

@ -128,7 +128,7 @@ dependencies:
flutter_local_notifications: ^9.1.4 flutter_local_notifications: ^9.1.4
#device_calendar #device_calendar
device_calendar: ^3.1.0 device_calendar: ^4.0.1
#Handle Geolocation #Handle Geolocation
geolocator: ^7.7.1 geolocator: ^7.7.1
@ -158,7 +158,8 @@ dependencies:
wifi: ^0.1.5 wifi: ^0.1.5
vibration: ^1.7.3 vibration: ^1.7.3
nfc_in_flutter: ^2.0.5
flutter_nfc_kit: ^3.2.0
speech_to_text: speech_to_text:
path: speech_to_text path: speech_to_text
@ -178,8 +179,7 @@ dependencies:
flutter_material_pickers: ^3.1.2 flutter_material_pickers: ^3.1.2
flutter_staggered_grid_view: ^0.4.1 flutter_staggered_grid_view: ^0.4.1
flutter_hms_gms_availability: ^2.0.0 flutter_hms_gms_availability: ^2.0.0
huawei_location: huawei_location: ^6.0.0+302
path: ./hms-plugins/flutter-hms-location
# Marker Animation # Marker Animation
flutter_animarker: ^3.2.0 flutter_animarker: ^3.2.0

Loading…
Cancel
Save