app_component.dart 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * fluro
  3. * A Posse Production
  4. * http://goposse.com
  5. * Copyright (c) 2018 Posse Productions LLC. All rights reserved.
  6. * See LICENSE for distribution and usage details.
  7. */
  8. import '../../config/application.dart';
  9. import 'package:flutter/material.dart';
  10. import 'package:flutter/services.dart';
  11. import 'package:fluro/fluro.dart';
  12. import '../../config/routes.dart';
  13. import '../home/home_component.dart';
  14. class AppComponent extends StatefulWidget {
  15. @override
  16. State createState() {
  17. return new AppComponentState();
  18. }
  19. }
  20. class AppComponentState extends State<AppComponent> {
  21. static MethodChannel platform = const MethodChannel('channel:com.goposse.routersample/deeplink');
  22. AppComponentState() {
  23. final router = new Router();
  24. Routes.configureRoutes(router);
  25. Application.router = router;
  26. configureDeepLinker();
  27. print("Configured channel receiver in flutter ..");
  28. }
  29. void configureDeepLinker() {
  30. platform.setMethodCallHandler((MethodCall call) async {
  31. if (call.method == "linkReceived") {
  32. Map<String, dynamic> passedObjs = call.arguments;
  33. if (passedObjs != null) {
  34. var path = passedObjs["path"];
  35. Application.router.navigateTo(context, path);
  36. }
  37. }
  38. });
  39. }
  40. @override
  41. Widget build(BuildContext context) {
  42. return new MaterialApp(
  43. title: 'Flutter Demo',
  44. theme: new ThemeData(
  45. primarySwatch: Colors.blue,
  46. ),
  47. home: new HomeComponent(),
  48. );
  49. }
  50. }