1 // Copyright 2013 The Flutter Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef FLUTTER_FLUTTERPLATFORMVIEWS_H_ 6 #define FLUTTER_FLUTTERPLATFORMVIEWS_H_ 7 8 #import <UIKit/UIKit.h> 9 10 #import "FlutterCodecs.h" 11 #import "FlutterMacros.h" 12 13 NS_ASSUME_NONNULL_BEGIN 14 15 /** 16 * Wraps a `UIView` for embedding in the Flutter hierarchy 17 */ 18 @protocol FlutterPlatformView <NSObject> 19 /** 20 * Returns a reference to the `UIView` that is wrapped by this `FlutterPlatformView`. 21 */ 22 - (UIView*)view; 23 @end 24 25 FLUTTER_EXPORT 26 @protocol FlutterPlatformViewFactory <NSObject> 27 /** 28 * Create a `FlutterPlatformView`. 29 * 30 * Implemented by iOS code that expose a `UIView` for embedding in a Flutter app. 31 * 32 * The implementation of this method should create a new `UIView` and return it. 33 * 34 * @param frame The rectangle for the newly created `UIView` measued in points. 35 * @param viewId A unique identifier for this `UIView`. 36 * @param args Parameters for creating the `UIView` sent from the Dart side of the Flutter app. 37 * If `createArgsCodec` is not implemented, or if no creation arguments were sent from the Dart 38 * code, this will be null. Otherwise this will be the value sent from the Dart code as decoded by 39 * `createArgsCodec`. 40 */ 41 - (NSObject<FlutterPlatformView>*)createWithFrame:(CGRect)frame 42 viewIdentifier:(int64_t)viewId 43 arguments:(id _Nullable)args; 44 45 /** 46 * Returns the `FlutterMessageCodec` for decoding the args parameter of `createWithFrame`. 47 * 48 * Only needs to be implemented if `createWithFrame` needs an arguments parameter. 49 */ 50 @optional 51 - (NSObject<FlutterMessageCodec>*)createArgsCodec; 52 @end 53 54 NS_ASSUME_NONNULL_END 55 56 #endif // FLUTTER_FLUTTERPLATFORMVIEWS_H_ 57