Search packages, repositories and app categories

Package detailsv0.2.0

snap_layouts

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

Windows
30-day downloads
52.3K
Likes
1
Pub points
160

Install package

flutter pub add snap_layouts

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The snap_layouts package enables Flutter applications on Windows to implement the native Windows 11 Snap Layouts feature, offering users a familiar and efficient window management experience. It provides a simple button interface that triggers snap layouts, allowing windows to be quickly arranged into predefined configurations. This enhances productivity by streamlining window positioning without requiring complex code. The package is specifically designed for Windows desktop apps and integrates seamlessly with Flutter's desktop platform.

Use cases

  • Implementing Windows 11-style window snapping
  • Improving user productivity with quick window arrangements
  • Enhancing desktop app usability on Windows
  • Creating responsive window layouts in Flutter apps
  • Enabling native-like window management features

Key features

  • Simple layout button integration
  • Supports Windows 11 Snap Layouts
  • Native Windows window management
  • Minimal setup required
  • Desktop-focused design

Suitable for

  • Windows desktop Flutter developers
  • Apps needing advanced window management
  • Developers targeting Windows 11 users
  • Productivity-focused desktop applications
  • Users seeking native Windows UX

Considerations

  • Limited to Windows platform
  • Requires Windows 11 or later
  • No support for Linux or macOS
  • Depends on native Windows APIs
  • May require additional configuration for full functionality

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

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

Categories

Dependencies

Dependency list 2 items

Source repository

Projects using this package

No data available yet.

Rankings