hybrid 0.0.5 copy "hybrid: ^0.0.5" to clipboard
hybrid: ^0.0.5 copied to clipboard

A hybrid project for android, ios and flutter.

example/lib/main.dart

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"));
  }
}
0
likes
20
pub points
0%
popularity

Publisher

unverified uploader

A hybrid project for android, ios and flutter.

Homepage

License

unknown (LICENSE)

Dependencies

dio, dva_dart, dva_flutter, flutter

More

Packages that depend on hybrid