app.dart 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * router
  3. * A Posse Production
  4. * http://goposse.com
  5. * Copyright (c) 2017 Posse Productions LLC. All rights reserved.
  6. * See LICENSE for distribution and usage details.
  7. */
  8. import 'package:flutter/material.dart';
  9. import 'package:flutter/services.dart';
  10. import 'package:router/router.dart';
  11. import 'package:router_example/config/application.dart';
  12. import 'package:router_example/config/route_handlers.dart';
  13. import 'package:router_example/screens/home_screen.dart';
  14. class App extends StatelessWidget {
  15. static const platform = const MethodChannel('channel:com.goposse.routerdemo/deeplink');
  16. App() {
  17. Router router = new Router();
  18. router.define("/demo", handler: showDemoHandler);
  19. Application.router = router;
  20. configureDeepLinker();
  21. }
  22. @override
  23. Widget build(BuildContext context) {
  24. return new MaterialApp(
  25. title: 'Flutter Demo',
  26. theme: new ThemeData(
  27. primarySwatch: Colors.blue,
  28. ),
  29. home: new HomeScreen(),
  30. );
  31. }
  32. void configureDeepLinker() {
  33. platform.setMethodCallHandler((MethodCall call) async {
  34. if (call.method == "linkReceived") {
  35. String path = call.arguments;
  36. if (path != null) {
  37. print("got path: $path");
  38. }
  39. }
  40. });
  41. }
  42. }