Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
PlatformViewFactory.java
Go to the documentation of this file.
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
5package io.flutter.plugin.platform;
6
7import android.content.Context;
8import androidx.annotation.NonNull;
9import androidx.annotation.Nullable;
10import io.flutter.plugin.common.MessageCodec;
11
12public abstract class PlatformViewFactory {
13 private final MessageCodec<Object> createArgsCodec;
14
15 /** @param createArgsCodec the codec used to decode the args parameter of {@link #create}. */
16 public PlatformViewFactory(@Nullable MessageCodec<Object> createArgsCodec) {
17 this.createArgsCodec = createArgsCodec;
18 }
19
20 /**
21 * Creates a new Android view to be embedded in the Flutter hierarchy.
22 *
23 * @param context the context to be used when creating the view, this is different than
24 * FlutterView's context.
25 * @param viewId unique identifier for the created instance, this value is known on the Dart side.
26 * @param args arguments sent from the Flutter app. The bytes for this value are decoded using the
27 * createArgsCodec argument passed to the constructor. This is null if createArgsCodec was
28 * null, or no arguments were sent from the Flutter app.
29 */
30 @NonNull
31 public abstract PlatformView create(Context context, int viewId, @Nullable Object args);
32
33 /** Returns the codec to be used for decoding the args parameter of {@link #create}. */
34 @Nullable
35 public final MessageCodec<Object> getCreateArgsCodec() {
36 return createArgsCodec;
37 }
38}
PlatformViewFactory(@Nullable MessageCodec< Object > createArgsCodec)
abstract PlatformView create(Context context, int viewId, @Nullable Object args)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args