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

floating_overlay 封面
插件详情v1.2.1

floating_overlay

一个允许浮动小部件被拖动和缩放的部件包装器。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
447
喜欢数
47
Pub 分数
150

安装插件

flutter pub add floating_overlay

插件介绍

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

floating_overlay 包提供了一个小部件包装器,可使浮动小部件能够被交互式拖动和缩放。它非常适合创建可移动的用户界面元素,例如弹出面板、可拖动工具或浮动操作区域。该包支持多种平台,包括 Android、iOS、Web、macOS、Windows 和 Linux,确保在不同设备上行为一致。基于 Flutter 构建,它能无缝集成到现有布局中,并提供响应式的触摸和指针交互。它轻量且专注于核心功能,没有不必要的依赖。

适合场景

  • 可拖动的弹出面板
  • 浮动工具栏
  • 交互式覆盖层
  • 可调整大小的 UI 组件
  • 自定义浮动窗口

主要特点

  • 可拖动定位
  • 可缩放内容
  • 跨平台支持
  • 简单的 API 集成
  • 指针交互处理

适合对象

  • 开发交互式 UI 的开发者
  • 需要可移动覆盖层的应用程序
  • 设计师原型设计浮动元素
  • 跨平台 Flutter 应用
  • 需要用户操作的UI组件

使用建议

  • 需要手动处理边缘约束
  • 可能需要额外的逻辑来检测碰撞
  • 性能取决于叠加层的复杂度
  • 不适用于静态叠加层
  • 有限的内置动画

原始 README

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

A widget wrapper that allows a floating widget be dragged and rescaled.

Features

  • Floating widget on top of the screen
  • Resizing and repositioning the floating widget
  • Constrainable space to float inside the tree (optional)
  • Limiting borders with padding
  • State managment when pushing and poping screens (needs the RouteObserver for managing push)

FloatingOverlay

Getting started

Add to your pubspec.yaml file:

dependencies:
  flutter:
    sdk: flutter
  floating_overlay: ^1.2.1

Import the package

import 'package:floating_overlay/floating_overlay.dart';

Usage

Create a FloatingOverlayController

final controller = FloatingOverlayController.absoluteSize(
  maxSize: const Size(200, 200),
  minSize: const Size(100, 100),
  start: Offset.zero,
  padding: const EdgeInsets.all(20.0),
  constrained: true,
);

or

final controller = FloatingOverlayController.relativeSize(
  maxScale: 2.0,
  minScale: 1.0,
  start: Offset.zero,
  padding: const EdgeInsets.all(20.0),
  constrained: true,
);

Insert the FloatingOverlay widget inside your widget tree and give it the controller, a child and a floatingChild.

FloatingOverlay(
  controller: controller,
  floatingChild: SizedBox.square(
    dimension: 100.0,
    child: Container(
      decoration: BoxDecoration(
        color: Theme.of(context).primaryColor,
        border: Border.all(
          color: Colors.black,
          width: 5.0,
        ),
      ),
    ),
  ),
  child: Container(),
);

Then use the controller to make the floating child show or hide.

controller.hide();
controller.isFloating;
controller.show();
controller.toggle();

所属分类

依赖

依赖清单 3 项

源码仓库

使用此插件的项目

暂无相关数据。