hybrid 0.0.5 hybrid: ^0.0.5 copied to clipboard
A hybrid project for android, ios and flutter.
import 'package:flutter/services.dart';
import 'package:flutter/material.dart';
import 'package:hybrid/hybrid.dart';
import 'package:hybrid/store.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(MyAppWrapper());
}
final routeChannelName = "com.deplay.one.hybrid/route";
class MyAppWrapper extends StatefulWidget {
final BasicMessageChannel<String> _routeChannel =
BasicMessageChannel<String>(routeChannelName, StringCodec());
@override
MyAppWrapperState createState() => MyAppWrapperState(_routeChannel);
}
class MyAppWrapperState extends State<MyAppWrapper> {
BasicMessageChannel<String> routeChannel;
String bundleApiUrl = "";
MyAppWrapperState(this.routeChannel) {
initRouteChannel();
}
initRouteChannel() async {
routeChannel.setMessageHandler((String route) {
bundleApiUrl = route;
return Future<String>.value(bundleApiUrl);
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Flutter Test App",
home: Hybrid(
store: store,
bundleApiUrl: bundleApiUrl,
// bundleApiUrl: Platform.isAndroid
// ? "http://192.168.2.216:3000/api/bundleJson" // "http://10.0.2.2:3000/api/bundleJson" //
// : "http://deplay.test:3000/api/bundleJson",
indexKey: "home"));
}
}