takeInitialTag method
The tag whose intent launched the app, if the app was launched by a tap.
Consumed by the first call: a second call returns null, so a widget rebuild cannot process the same tag twice. Set onTagFromIntent before calling this to catch tags that arrive while the app is already running.
Android 17 stopped dispatching NFC intents to a stopped app, so this returns null
after a force-stop, and on a fresh install, until the user has opened the app once. The
receiving activity also has to declare android.permission.DISPATCH_NFC_MESSAGE from
API 37, and the user can switch the app off the tag-scan allowlist from API 36 --
checkTagIntentSetup reports both, and neither raises an error on its own.
Implementation
Future<NfcTag?> takeInitialTag() async {
final tag = await androidApi.takeInitialTag();
return tag == null ? null : NfcTag(tag);
}