搜索插件、代码仓与 APP 分类

插件详情v0.0.1+2

pip_plugin

跨所有平台的画中画模式下显示可自定义文本叠加层的 Flutter 插件。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
6
喜欢数
21
Pub 分数
130

安装插件

flutter pub add pip_plugin

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

pip_plugin 是一个 Flutter 包,可让开发者在 Android、iOS、Web、macOS、Windows 和 Linux 上的画中画(PiP)模式中显示可自定义的文字叠加层。它提供了一致的 API,可在 PiP 窗口中显示浮动文字图层,适用于注释、计时器或状态指示器。该插件与 Flutter 的跨平台架构无缝集成,并支持动态内容更新。专为需要在视频播放或多任务场景中持续提供视觉反馈的应用而设计。

适合场景

  • 带有屏幕标签的实时视频流
  • 带有实时注释的教育类应用程序
  • 带有参与者状态叠加的视频会议
  • 需要持续UI提示的多任务应用程序
  • 带有引导说明的交互式教程

主要特点

  • 跨平台画中画文本叠加
  • 可自定义的文本样式和定位
  • 无需重启即可动态更新内容
  • 支持所有主要的桌面和移动平台
  • 通过 Flutter pub 简单集成
  • 实时叠加渲染

适合对象

  • 开发媒体丰富的 Flutter 应用的开发者
  • PiP 中需要持续显示屏幕信息的应用
  • 教育或培训应用程序
  • 流媒体或直播活动平台
  • 多窗口或分屏界面

使用建议

  • 目标平台需要支持画中画模式
  • 文本可见性在不同屏幕尺寸上可能有所不同
  • 频繁更新的性能影响
  • 仅限文本叠加(不支持图像或复杂小部件)
  • 特定于平台的画中画行为可能会影响布局

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

pip_plugin

⚠️ Experimental
A Flutter plugin that enables a customizable Picture-in-Picture window displaying text.


Table of Contents


Introduction

pip_plugin is an experimental Flutter plugin that lets you display text overlays in Picture-in-Picture mode on Android, iOS, Web, and Desktop. It exposes a simple Dart API to configure the PiP window’s appearance and control its lifecycle.


Preview

ios macos web


Installation

Add the plugin to your pubspec:

dependencies:
  pip_plugin: ^<latest_version>

Then run:

flutter pub get

Platform-specific Setup

Android
  1. In your AndroidManifest.xml, enable PiP support:

    <application
        android:supportsPictureInPicture="true"
        …>
        …
    </application>
    
  2. Enable PiP callbacks there are two approaches:

1. Activity Wrapper (Recommended)

Wrap your main activity with the provided helper—this is the simplest integration.

  • Kotlin

    import cl.puntito.simple_pip_mode.PipCallbackHelperActivityWrapper
    
    class MainActivity: PipCallbackHelperActivityWrapper() {
        // No additional code needed
    }
    
  • Java

    import cl.puntito.simple_pip_mode.PipCallbackHelperActivityWrapper;
    
    public class MainActivity extends PipCallbackHelperActivityWrapper {
        // No additional code needed
    }
    

Once inherited, PiP callbacks and the PiP widget become available automatically.

2. Callback Helper

If you prefer not to subclass your activity, you can manually wire up the callbacks:

  • Kotlin

    import cl.puntito.simple_pip_mode.PipCallbackHelper
    import io.flutter.embedding.engine.FlutterEngine
    import io.flutter.embedding.android.FlutterActivity
    import android.content.res.Configuration
    
    class MainActivity: FlutterActivity() {
      private val pipHelper = PipCallbackHelper()
    
      override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        super.configureFlutterEngine(flutterEngine)
        pipHelper.configureFlutterEngine(flutterEngine)
      }
    
      override fun onPictureInPictureModeChanged(
        isInPipMode: Boolean,
        newConfig: Configuration?
      ) {
        super.onPictureInPictureModeChanged(isInPipMode, newConfig)
        pipHelper.onPictureInPictureModeChanged(isInPipMode)
      }
    }
    
  • Java

    import cl.puntito.simple_pip_mode.PipCallbackHelper;
    import io.flutter.embedding.engine.FlutterEngine;
    import io.flutter.embedding.android.FlutterActivity;
    import android.content.res.Configuration;
    
    public class MainActivity extends FlutterActivity {
        private final PipCallbackHelper pipHelper = new PipCallbackHelper();
    
        @Override
        public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
            super.configureFlutterEngine(flutterEngine);
            pipHelper.configureFlutterEngine(flutterEngine);
        }
    
        @Override
        public void onPictureInPictureModeChanged(
          boolean isInPipMode,
          Configuration newConfig
        ) {
            super.onPictureInPictureModeChanged(isInPipMode, newConfig);
            pipHelper.onPictureInPictureModeChanged(isInPipMode);
        }
    }
    

iOS

In your Info.plist, add PiP to the background modes:

<key>UIBackgroundModes</key>
<array>
  <string>audio</string>
  <string>airplay</string>
  <string>picture-in-picture</string>
</array>

Other Platforms
  • Web and Desktop: No extra configuration.

Usage

Plugin API

Import the main plugin class and manage PiP mode:
⚠️ Initialize first: call setupPip(...) before using other PiP methods.


/// Prepares PiP with an optional title and configuration.
Future<bool> setupPip({
  /// On desktop platforms, you can optionally set a `windowTitle`.
  String? windowTitle,
  PipConfiguration? configuration,
});

/// Enters Picture-in-Picture mode.
Future<bool> startPip();

/// Exits Picture-in-Picture mode.
/// (On Android this is a no-op, as PiP closes automatically.)
Future<bool> stopPip();

/// Returns whether PiP is supported on the current platform.
Future<bool> isPipSupported();

/// Dynamically updates the PiP window’s appearance:
/// - backgroundColor, textColor, textSize, textAlign, ratio
Future<bool> update({
  Color? backgroundColor,
  Color? textColor,
  double? textSize,
  /// Only `left`, `right`, and `center` are supported.
  TextAlign? textAlign,
  /// ignored on Web platforms.
  (int, int)? ratio,
});

/// Changes the displayed text in PiP.
Future<bool> updateText(String text);

/// Emits `true`/`false` whenever PiP becomes active/inactive.
Stream<bool> get pipActiveStream;

/// Whether the plugin has been initialized.
bool get isInitialized;

/// Releases any resources held by the plugin.
void dispose();

Showing Text in PiP
  • Android: Wrap your UI with the built-in TextPipWidget to render the PiP text overlay, then drive it with the plugin API.
  • All other platforms: No widget required—just invoke the PipPlugin methods directly.
Android Example
import 'package:flutter/material.dart';
import 'package:pip_plugin/pip_plugin.dart';
import 'package:pip_plugin/text_pip_widget.dart';

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final pip = PipPlugin();

  @override
  void initState() {
    super.initState();
    _initPlugin();
  }

  void _initPlugin() async {
    final supported = await pip.isPipSupported();
    if (supported) {
      await pip.setupPip();
      await pip.updateText('inside PiP');
    }
  }

  @override
  Widget build(BuildContext context) {
    return TextPipWidget(
      child: Scaffold(
        body: const Center(child: Text('outside PiP')),
        floatingActionButton: FloatingActionButton(
          onPressed: () async {
            await pip.startPip();            
          },
          child: const Icon(Icons.picture_in_picture),
        ),
      ),
    );
  }
}

Platform Support

Platform Minimum Version / Notes
Android API 26+
iOS iOS 15+ (for Simulator testing, use an iPad simulator)
Web Follows the Document Picture-in-Picture API.
Desktop All major versions (macOS, Windows, Linux)

所属分类

依赖

依赖清单 3 项

源码仓库

使用此插件的项目

暂无相关数据。