搜尋套件、儲存庫與 APP 分類

套件詳情v0.2.0

snap_layouts

該外掛程式提供了一個簡單的視窗佈局按鈕,可實作原生 Windows 11 的 Snap Layouts 功能。

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 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。

所在榜單