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

插件详情v3.2.2

split_view

此小部件为 Flutter 提供水平或垂直拆分视图。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
2.4万
喜欢数
73
Pub 分数
160

安装插件

flutter pub add split_view

插件介绍

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

split_view 包提供了一种灵活的方式来创建 Flutter 应用中的水平或垂直拆分视图。它允许用户将屏幕划分为两个可调整大小的部分,非常适合并排显示内容,例如文件浏览器、编辑器布局或仪表板面板。该控件支持拖拽调整大小功能,并可在 Android、iOS、Web、macOS、Windows 和 Linux 等主要平台上正常工作。它轻量且能无缝集成到现有的 Flutter UI 中。

适合场景

  • 双面板布局
  • 文件浏览器接口
  • 代码编辑器侧边栏
  • 仪表板面板布局
  • 可调整大小的 UI 组件

主要特点

  • 水平和垂直分割方向
  • 拖拽调整大小的手柄
  • 跨平台兼容性
  • 与 Flutter widget 的简单集成
  • 响应式布局支持

适合对象

  • 开发复杂 UI 的开发者
  • 需要双面板导航的应用
  • 需要分屏视图的编辑器或工具
  • 跨平台桌面和网页应用

使用建议

  • 可能需要额外的逻辑来管理状态
  • 不适用于简单的单面板屏幕
  • 性能取决于子部件的复杂性
  • 超出基本调整大小之外的自定义功能有限

原始 README

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

Splitter view plugin

A splitter view for flutter.

Usage

To use this plugin, add split_view as a dependency in your pubspec.yaml file.

Example

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title!),
      ),
      body: SplitView(
        children: [
          SplitView(
            viewMode: SplitViewMode.Horizontal,
            indicator: SplitIndicator(viewMode: SplitViewMode.Horizontal),
            activeIndicator: SplitIndicator(
              viewMode: SplitViewMode.Horizontal,
              isActive: true,
            ),
            children: [
              Container(
                child: Center(child: Text("View1")),
                color: Colors.red,
              ),
              Container(
                child: Center(child: Text("View2")),
                color: Colors.blue,
              ),
              Container(
                child: Center(child: Text("View3")),
                color: Colors.green,
              ),
            ],
            onWeightChanged: (w) => print("Horizon: $w"),
          ),
          Container(
            child: Center(child: Text("View4")),
            color: Colors.purple,
          ),
          Container(
            child: Center(child: Text("View5")),
            color: Colors.yellow,
          ),
        ],
        viewMode: SplitViewMode.Vertical,
        indicator: SplitIndicator(viewMode: SplitViewMode.Vertical),
        activeIndicator: SplitIndicator(
          viewMode: SplitViewMode.Vertical,
          isActive: true,
        ),
        controller: SplitViewController(limits: [null, WeightLimit(max: 0.5)]),
        onWeightChanged: (w) => print("Vertical $w"),
      ),
    );
  }
}

Support

If you find this package useful, please consider supporting the development:

Buy Me A Coffee

ToDo

  • Add tests.
  • Aim to enhance documents.
  • and more...

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目