0 purchases
bifrost
Bifrost #
Bifrost is a plugin which enables easy embedding of your Flutter application into your existing native apps.
Requirements #
Flutter 2.0.0+ on stable channel
iOS 10.0+ Xcode 12.0+ Swift 5+
Android minSdkVersion 16 Kotlin 1.3.50+
Getting Started #
Flutter #
Add a dependency in your Flutter project
dependencies:
bifrost: ^0.1.0
copied to clipboard
Initialize Bifrost on your MaterialApp or CupertinoApp
@override
Widget build(BuildContext context) {
return MaterialApp(
builder: Bifrost.init(),
routes: routes,
theme: theme,
);
}
copied to clipboard
Invoke a method of the native layer, from your Flutter code
final appVersion = await BifrostChannels.common.invokeMethod('getAppVersion');
copied to clipboard
Send notification to native app
BifrostChannels.notification.invokeMethod('doSomething', arguments);
copied to clipboard
Android #
Start Bifrost Flutter Engine in your application class and also add the common MethodCallHandler
class App : Application() {
override fun onCreate() {
super.onCreate()
// start flutter engine
Bifrost.startFlutterEngine(this, CommonHandler())
}
// application common handler
private class CommonHandler : MethodChannel.MethodCallHandler {
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
when (call.method) {
"getAppVersion" -> result.success(BuildConfig.VERSION_NAME)
}
}
}
}
copied to clipboard
Start a new activity by passing an initial route
val intent = BifrostFlutterActivity.createIntent(this, "/greetings", arguments)
startActivity(intent)
copied to clipboard
Create a new fragment instance by passing an initial route
val fragment = BifrostFlutterFragment.newInstance("/first")
copied to clipboard
Register notification listener
Bifrost.registerNotification("doSomething") { arguments ->
// do something
}
copied to clipboard
iOS #
Start Bifrost Flutter Engine in your AppDelegate and also add the common MethodCallHandler
import UIKit
import bifrost
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// start bifrost flutter engine
Bifrost.startFlutterEngine(commonHandler: handle)
return true
}
// common channel handle
private func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
if (call.method == "getAppVersion") {
let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"]
result(version)
}
}
}
copied to clipboard
Start a new ViewController by passing an initial route
let vc = BifrostFlutterViewController.init("/greetings", arguments: arguments)
copied to clipboard
If you want to use storyboard, you can use custom attributes
Register notification listener
Bifrost.registerNotification("doSomething") { arguments in
// do something
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.