Created
August 7, 2018 19:43
-
-
Save diegoveloper/91c7486a19def61e0e031324b2934402 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
void main() { | |
runApp(new MaterialApp( | |
title: 'Dynamic Links Example', | |
routes: <String, WidgetBuilder>{ | |
'/': (BuildContext context) => new MyHomeWidget(), // Default home route | |
'/helloworld': (BuildContext context) => new MyHelloWorldWidget(), | |
}, | |
)); | |
} | |
class _MyHomeWidgetState extends State<_MyHomeWidget> { | |
. | |
. | |
. | |
@override | |
void initState() { | |
super.initState(); | |
_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' | |
} | |
} | |
. | |
. | |
. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment