fluro/example/lib/components/app/app_component.dart

60 lines
1.4 KiB
Dart
Raw Normal View History

/*
* fluro
* A Posse Production
* http://goposse.com
* Copyright (c) 2018 Posse Productions LLC. All rights reserved.
* See LICENSE for distribution and usage details.
*/
import '../../config/application.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:fluro/fluro.dart';
2017-10-06 16:35:51 -04:00
import '../../config/routes.dart';
import '../home/home_component.dart';
class AppComponent extends StatefulWidget {
@override
State createState() {
return new AppComponentState();
}
}
class AppComponentState extends State<AppComponent> {
static MethodChannel platform = const MethodChannel('channel:com.goposse.routersample/deeplink');
AppComponentState() {
final router = new Router();
Routes.configureRoutes(router);
Application.router = router;
configureDeepLinker();
print("Configured channel receiver in flutter ..");
}
void configureDeepLinker() {
platform.setMethodCallHandler((MethodCall call) async {
if (call.method == "linkReceived") {
Map<String, dynamic> passedObjs = call.arguments;
if (passedObjs != null) {
var path = passedObjs["path"];
Application.router.navigateTo(context, path);
}
}
});
}
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new HomeComponent(),
);
}
}