Token导航 LogoToken导航TokenDH.com
前端设计操作浏览器github未标认证来源可访问许可证需确认审计通过

flutter-embedding-native-viewsFlutter embedding native views 搜索

Agent Skill

用于搭建或维护带检索增强的 RAG 工作流,适合让 Agent 处理知识库问答、向量检索、来源引用和事实核查。它可以辅助整理数据接入、Embedding、向量库、召回参数和回答生成流程。使用时需要确认数据来源、更新频率、召回阈值和引用展示方式,避免把未命中的资料或过期内容包装成确定事实。

总安装

192,864

周安装

8,248

GitHub Stars

1,278

下载量

67,568
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:flutter-embedding-native-views(Flutter embedding native views 搜索)
来源仓库:https://github.com/flutter/skills
仓库路径:skills/flutter-embedding-native-views
安装命令:
npx skills add https://github.com/flutter/skills --skill flutter-embedding-native-views
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/flutter/skills --skill flutter-embedding-native-views

简介

将原生 Android、iOS 或 macOS 视图和 Web 内容直接嵌入到 Flutter 应用程序中。

  • 支持两种 Android 合成模式(混合和纹理层),具有不同的性能和保真度权衡; iOS 和 macOS 专门使用混合组合
  • 包括在 Android 和 iOS 上实现平台视图的分步工作流程,以及验证和故障排除指南
  • 允许通过全页或多视图(嵌入)模式将 Flutter 嵌入到现有 Web 应用程序中,并提供 JavaScript 和 Dart 配置示例
  • 提供性能缓解策略,例如在复杂动画期间将本机视图屏幕截图渲染为占位符纹理

SKILL.md

Integrating Platform Views and Web Content

Contents

Platform Views Architecture

Platform Views allow embedding native views (Android, iOS, macOS) directly into a Flutter application, enabling the application of transforms, clips, and opacity from Dart.

Android Implementations (API 23+)

Choose the appropriate implementation based on your performance and fidelity requirements:

  • Hybrid Composition: Renders Flutter content into a texture and uses SurfaceFlinger to compose both.

- *Pros:* Best performance and fidelity for Android views. - *Cons:* Lowers overall application FPS. Certain Flutter widget transformations will not work.

  • Texture Layer (Texture Layer Hybrid Composition): Renders Platform Views into a texture. Flutter draws them via the texture and renders its own content directly into a Surface.

- *Pros:* Best performance for Flutter rendering. All transformations work correctly. - *Cons:* Quick scrolling (e.g., WebViews) can be janky. SurfaceView is problematic (breaks accessibility). Text magnifiers break unless Flutter is rendered into a TextureView.

iOS & macOS Implementations

  • iOS: Uses Hybrid Composition exclusively. The native UIView is appended to the view hierarchy.

- *Limitations:* ShaderMask and ColorFiltered widgets are not supported. BackdropFilter has composition limitations.

  • macOS: Uses Hybrid Composition (NSView).

- *Limitations:* Not fully functional in current releases (e.g., gesture support is unavailable).

Performance Mitigation

Mitigate performance drops during complex Dart animations by rendering a screenshot of the native view as a placeholder texture while the animation runs.

Web Embedding Architecture

Embed Flutter into existing web applications (Vanilla JS, React, Angular, etc.) using either Full Page mode or Embedded (Multi-view) mode.

  • Full Page Mode: Flutter takes over the entire browser window. Use an iframe if you need to constrain the Flutter app without modifying the Flutter bootstrap process.
  • Embedded Mode (Multi-view): Render Flutter into specific HTML elements (divs). Requires multiViewEnabled: true during engine initialization.

- Manage views from JavaScript using app.addView() and app.removeView(). - In Dart, replace runApp with runWidget. - Manage the dynamic list of views using WidgetsBinding.instance.platformDispatcher.views and render them using ViewCollection and View widgets.

Workflow: Implementing Android Platform Views

Follow this sequential workflow to implement a Platform View on Android.

Task Progress:

  • 1. Determine the composition mode (Hybrid vs. Texture Layer).
  • 2. Implement the Dart widget.
  • 3. Implement the native Android View and Factory.
  • 4. Register the Platform View in the Android host.
  • 5. Run validator -> review rendering -> fix manual invalidation issues.

1. Dart Implementation

If using Hybrid Composition, use PlatformViewLink, AndroidViewSurface, and PlatformViewsService.initSurfaceAndroidView. If using Texture Layer, use the AndroidView widget.

2. Native Implementation

Create a class implementing io.flutter.plugin.platform.PlatformView that returns your native android.view.View. Create a factory extending PlatformViewFactory to instantiate your view.

3. Registration

Register the factory in your MainActivity.kt (or plugin) using flutterEngine.platformViewsController.registry.registerViewFactory.

*Note: If your native view uses SurfaceView or SurfaceTexture, manually call invalidate on the View or its parent when content changes, as they do not invalidate themselves automatically.*

Workflow: Implementing iOS Platform Views

Follow this sequential workflow to implement a Platform View on iOS.

Task Progress:

  • 1. Implement the Dart widget using UiKitView.
  • 2. Implement the native iOS View (FlutterPlatformView) and Factory (FlutterPlatformViewFactory).
  • 3. Register the Platform View in AppDelegate.swift or the plugin registrar.
  • 4. Run validator -> review composition limitations -> fix unsupported filters.

Workflow: Embedding Flutter in Web Applications

Follow this sequential workflow to embed Flutter into an existing web DOM.

Task Progress:

  • 1. Update flutter_bootstrap.js to enable multi-view.
  • 2. Update main.dart to use runWidget and ViewCollection.
  • 3. Implement JavaScript logic to add/remove host elements.
  • 4. Run validator -> review view constraints -> fix CSS conflicts.

1. JavaScript Configuration

In flutter_bootstrap.js, initialize the engine with multiViewEnabled: true. Use the returned app object to add views: app.addView({hostElement: document.getElementById('my-div')}).

2. Dart Configuration

Replace runApp() with runWidget(). Create a root widget that listens to WidgetsBindingObserver.didChangeMetrics. Map over WidgetsBinding.instance.platformDispatcher.views to create a View widget for each attached FlutterView, and wrap them all in a ViewCollection.

Examples

Example: Android Texture Layer (Dart)

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class NativeAndroidView extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    const String viewType = 'my_native_view';
    final Map<String, dynamic> creationParams = <String, dynamic>{};

    return AndroidView(
      viewType: viewType,
      layoutDirection: TextDirection.ltr,
      creationParams: creationParams,
      creationParamsCodec: const StandardMessageCodec(),
    );
  }
}

Example: Web Multi-View Initialization (JavaScript)

_flutter.loader.load({
  onEntrypointLoaded: async function(engineInitializer) {
    let engine = await engineInitializer.initializeEngine({
      multiViewEnabled: true,
    });
    let app = await engine.runApp();

    // Add a view to a specific DOM element
    let viewId = app.addView({
      hostElement: document.querySelector('#flutter-host-container'),
      initialData: { customData: 'Hello from JS' }
    });
  }
});

Example: Web Multi-View Root Widget (Dart)

import 'dart:ui' show FlutterView;
import 'package:flutter/widgets.dart';

void main() {
  runWidget(MultiViewApp(viewBuilder: (context) => const MyEmbeddedWidget()));
}

class MultiViewApp extends StatefulWidget {
  final WidgetBuilder viewBuilder;
  const MultiViewApp({super.key, required this.viewBuilder});

  @override
  State<MultiViewApp> createState() => _MultiViewAppState();
}

class _MultiViewAppState extends State<MultiViewApp> with WidgetsBindingObserver {
  Map<Object, Widget> _views = {};

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addObserver(this);
    _updateViews();
  }

  @override
  void didChangeMetrics() => _updateViews();

  void _updateViews() {
    final newViews = <Object, Widget>{};
    for (final FlutterView view in WidgetsBinding.instance.platformDispatcher.views) {
      newViews[view.viewId] = _views[view.viewId] ?? View(
        view: view,
        child: Builder(builder: widget.viewBuilder),
      );
    }
    setState(() => _views = newViews);
  }

  @override
  void dispose() {
    WidgetsBinding.instance.removeObserver(this);
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return ViewCollection(views: _views.values.toList(growable: false));
  }
}

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

37.06%
按下载量换算25,041

Claude

27.1%
按下载量换算18,311

Cursor

20.12%
按下载量换算13,595

Gemini CLI

9.53%
按下载量换算6,439

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills