Created
August 7, 2018 20:05
-
-
Save diegoveloper/784afa1e492de1df42426c60d22d1d1b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class _MyHomeWidgetState extends State<_MyHomeWidget> with WidgetsBindingObserver{ | |
. | |
. | |
. | |
@override | |
void initState() { | |
super.initState(); | |
WidgetsBinding.instance.addObserver(this); | |
} | |
@override | |
void didChangeAppLifecycleState(AppLifecycleState state) { | |
if (state == AppLifecycleState.resumed) { | |
_retrieveDynamicLink(); | |
} | |
} | |
Future<void> _retrieveDynamicLink() async { | |
final PendingDynamicLinkData data = await FirebaseDynamicLinks.instance.retrieveDynamicLink(); | |
final Uri deepLink = data?.link; | |
if (deepLink != null) { | |
Navigator.pushNamed(context, deepLink.path); // '/helloworld' | |
} | |
} | |
. | |
. | |
. | |
@override | |
void dispose() { | |
WidgetsBinding.instance.removeObserver(this); | |
super.dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment