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

插件详情v0.2.0

snap_layouts

该插件提供了一个简单的窗口布局按钮,可实现原生 Windows 11 拆分布局功能。

Windows
近 30 天下载
5.2万
喜欢数
1
Pub 分数
160

安装插件

flutter pub add snap_layouts

插件介绍

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

snap_layouts 包使 Flutter 应用程序能够在 Windows 上实现原生的 Windows 11 Snap Layouts 功能,为用户提供熟悉且高效的窗口管理体验。它提供了一个简单的按钮界面,可触发 snap 布局,使窗口能够快速排列到预定义的配置中。这通过简化窗口定位过程来提升生产力,而无需编写复杂的代码。该包专为 Windows 桌面应用设计,并与 Flutter 的桌面平台无缝集成。

适合场景

  • 实现 Windows 11 风格的窗口吸附
  • 通过快速窗口布局提升用户生产力
  • 增强 Windows 桌面应用程序的可用性
  • 在 Flutter 应用中创建响应式窗口布局
  • 启用原生窗口管理功能

主要特点

  • 简单布局按钮集成
  • 支持 Windows 11 Snap 布局
  • 原生 Windows 窗口管理
  • 所需的最小设置
  • 以桌面为重点的设计

适合对象

  • Windows 桌面 Flutter 开发人员
  • 需要高级窗口管理的应用程序
  • 面向 Windows 11 用户的开发者
  • 以生产力为导向的桌面应用程序
  • 寻求原生 Windows 用户体验的用户

使用建议

  • 仅限 Windows 平台
  • 需要 Windows 11 或更高版本
  • 不支持 Linux 或 macOS
  • 依赖原生 Windows API
  • 可能需要额外配置才能实现完整功能

原始 README

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

snap_layouts

pub version

This plugin provides a simple window layout button, SnapLayoutsButton, which can implement the native Windows 11 Snap Layouts feature.


English | 简体中文


Supported Platforms

Linux macOS Windows iOS Android
❌ ❌ ✔️ ❌ ❌

Features

  • Native Windows 11-style Snap Layouts button
  • Default Windows 11-style window title bar
  • Integration with the window_manager plugin
  • Full customization support

Quick Start

Installation
flutter pub add snap_layouts
flutter pub add window_manager

Or add the following to your pubspec.yaml:

dependencies:
  snap_layouts: ^0.2.0
  window_manager: ^0.5.0
Usage

You can directly check the example.

SnapLayoutsButton

Place the button on your page.

import 'package:flutter/material.dart';
import 'package:snap_layouts/snap_layouts.dart';
import 'package:window_manager/window_manager.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await windowManager.ensureInitialized();
  WindowOptions windowOptions = WindowOptions(
    // Ensure this option
    titleBarStyle: TitleBarStyle.hidden,
  );
  windowManager.waitUntilReadyToShow(windowOptions, () async {
    await windowManager.show();
    await windowManager.focus();
  });

  runApp(const MyApp());
}

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: SizedBox(width: 46, height: 32, child: SnapLayoutsButton()),
        ),
      ),
    );
  }
}
SnapLayoutsCaption

Place the title bar on your page.

import 'package:flutter/material.dart';
import 'package:snap_layouts/snap_layouts.dart';
import 'package:window_manager/window_manager.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await windowManager.ensureInitialized();
  WindowOptions windowOptions = WindowOptions(
    // Ensure this option
    titleBarStyle: TitleBarStyle.hidden,
  );
  windowManager.waitUntilReadyToShow(windowOptions, () async {
    await windowManager.show();
    await windowManager.focus();
  });

  runApp(const MyApp());
}

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> with WindowListener {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: PreferredSize(
          preferredSize: const Size.fromHeight(kWindowCaptionHeight),
          child: SnapLayoutsCaption(
            title: Text('snap_layouts_example'),
            actions: [
              WindowCaptionAction(
                icon: Icon(Icons.favorite_outline),
                onPressed: () {},
              ),
            ],
          ),
        ),
        body: Center(child: Text('Snap Layouts Example')),
      ),
    );
  }

  @override
  void onWindowMaximize() {
    setState(() {});
  }

  @override
  void onWindowUnmaximize() {
    setState(() {});
  }
}

References

  • https://learn.microsoft.com/en-us/windows/apps/desktop/modernize/ui/apply-snap-layout-menu
  • https://github.com/luoluoqixi/flutter_windows11_snap_layouts_examples.git
  • https://github.com/grassator/win32-window-custom-titlebar
  • https://github.com/leanflutter/window_manager

License

MIT

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目

暂无相关数据。

所在榜单