text stringlengths 1 474 |
|---|
<topic_start>Compiled (dynamic) library |
To link to a compiled dynamic library, |
use the following instructions:<topic_end> |
<topic_start>Open-source third-party library |
To create a Flutter plugin that includes both |
C/C++/Objective-C and Dart code, |
use the following instructions:The native code is then statically linked into |
the application binary of any app that uses |
this plugin.<topic_end> |
<topic_start>Closed-source third-party library |
To create a Flutter plugin that includes Dart |
source code, but distribute the C/C++ library |
in binary form, use the following instructions:warning Warning |
Do not upload this plugin |
(or any plugin containing binary code) to pub.dev. |
Instead, this plugin should be downloaded |
from a trusted third-party, |
as shown in the CocoaPods example.<topic_end> |
<topic_start> |
Stripping iOS symbols |
When creating a release archive (IPA), |
the symbols are stripped by Xcode.<topic_end> |
<topic_start> |
Other Resources |
To learn more about C interoperability, check out these videos: |
<topic_end> |
<topic_start>Hosting native iOS views in your Flutter app with Platform Views |
Platform views allow you to embed native views in a Flutter app, |
so you can apply transforms, clips, and opacity to the native view |
from Dart.This allows you, for example, to use the native |
Google Maps from the Android and iOS SDKs |
directly inside your Flutter app.info Note |
This page discusses how to host your own native iOS views |
within a Flutter app. |
If you’d like to embed native Android views |
in your Flutter app, |
see Hosting native Android views.iOS only uses Hybrid composition, |
which means that the native |
UIView is appended to the view hierarchy.To create a platform view on iOS, |
use the following instructions:<topic_end> |
<topic_start> |
On the Dart side |
On the Dart side, create a Widget |
and add the build implementation, |
as shown in the following steps.In the Dart widget file, make changes similar to those |
shown in native_view_example.dart:Add the following imports: |
<code_start>import 'package:flutter/foundation.dart'; |
import 'package:flutter/services.dart';<code_end> |
Implement a build() method: |
<code_start>Widget build(BuildContext context) { |
// This is used in the platform side to register the view. |
const String viewType = '<platform-view-type>'; |
// Pass parameters to the platform side. |
final Map<String, dynamic> creationParams = <String, dynamic>{}; |
return UiKitView( |
viewType: viewType, |
layoutDirection: TextDirection.ltr, |
creationParams: creationParams, |
creationParamsCodec: const StandardMessageCodec(), |
); |
}<code_end> |
For more information, see the API docs for: |
UIKitView.<topic_end> |
<topic_start> |
On the platform side |
On the platform side, use either Swift or Objective-C:Implement the factory and the platform view. |
The FLNativeViewFactory creates the platform view, |
and the platform view provides a reference to the UIView. |
For example, FLNativeView.swift:Finally, register the platform view. |
This can be done in an app or a plugin.For app registration, |
modify the App’s AppDelegate.swift:For plugin registration, |
modify the plugin’s main file |
(for example, FLPlugin.swift):In Objective-C, add the headers for the factory and the platform view. |
For example, as shown in FLNativeView.h:Implement the factory and the platform view. |
The FLNativeViewFactory creates the platform view, |
and the platform view provides a reference to the |
UIView. For example, FLNativeView.m:Finally, register the platform view. |
This can be done in an app or a plugin.For app registration, |
modify the App’s AppDelegate.m:For plugin registration, |
modify the main plugin file |
(for example, FLPlugin.m):For more information, see the API docs for:<topic_end> |
<topic_start> |
Putting it together |
When implementing the build() method in Dart, |
you can use defaultTargetPlatform |
to detect the platform, and decide which widget to use: |
<code_start>Widget build(BuildContext context) { |
// This is used in the platform side to register the view. |
const String viewType = '<platform-view-type>'; |
// Pass parameters to the platform side. |
final Map<String, dynamic> creationParams = <String, dynamic>{}; |
switch (defaultTargetPlatform) { |
case TargetPlatform.android: |
// return widget on Android. |
case TargetPlatform.iOS: |
// return widget on iOS. |
default: |
throw UnsupportedError('Unsupported platform view'); |
} |
}<code_end> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.