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

插件详情v1.0.3

flutter_spacer

spacer 是一个用于 Flutter 的 Dart 包,可轻松按屏幕宽度或高度的百分比来间距控件。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
35
喜欢数
20
Pub 分数
150

安装插件

flutter pub add flutter_spacer

插件介绍

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

flutter_spacer 是一个 Flutter 包,通过使用屏幕宽度或高度的百分比来简化小部件间距。它提供了一种简洁直观的方法,在 UI 元素之间添加响应式间距,而无需手动计算数值。非常适合在不同屏幕尺寸和方向上创建一致的布局,增强了布局的灵活性并减少了样板代码。该包支持所有主要平台,确保跨平台一致性。在表单、网格和需要比例间距的响应式设计中尤其有用。

适合场景

  • 响应式UI布局
  • 表单间距
  • 网格对齐
  • 跨平台设计
  • 动态填充
  • 居中对齐控件

主要特点

  • 基于百分比的间距
  • 支持宽度和高度
  • 跨平台兼容性
  • 最小化样板代码
  • 轻松集成
  • 响应式设计

适合对象

  • 开发响应式应用的开发者
  • 寻求精确间距的UI设计师
  • 需要一致布局缩放的项目
  • 注重可维护代码的团队
  • 面向多种设备尺寸的应用

使用建议

  • 需要理解基于百分比的布局
  • 在复杂布局中可能需要额外的约束
  • 不适合固定像素间距的需求
  • 仅限间距功能
  • 最好与其他布局小部件一起使用

原始 README

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

flutter_spacer is a Dart package that simplifies the creation of responsive layouts by providing utilities for easily spacing between widgets in terms of percentage of screen width or height.

Features

  • Extension Methods: Use extension methods on num to create SizedBox widgets with a percentage of the screen width or height.
  • Responsive Utilities: The package includes utilities to get the device's height and width, making it easy to create responsive layouts.

Getting started

To use this package, add flutter_spacer to your pubspec.yaml file

  dependencies:
  flutter_spacer: ^1.0.2 # use the latest version

or

 dart pub add flutter_spacer

Usage

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

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return FlutterSpacer(
      builder: (context) {
        return MaterialApp(
          title: 'My App',
          home: MyHomePage(),
        );
      },
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('My App'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Container(
          
              height: 20,
              width: 50,
              color: Colors.blue,
              child: Center(
                child: Text(
                  'first Container',
                  style: TextStyle(color: Colors.white),
                ),
              ),
            ),
            
            20.hs // give you space of 20%
            Container(
          
              height: 20,
              width: 50,
              color: Colors.blue,
              child: Center(
                child: Text(
                  'Second Container',
                  style: TextStyle(color: Colors.white),
                ),
              ),
            ),

          ],
        ),
      ),
    );
  }
}

Additional Information

Thank you for using the flutter_spacer package! Here's some additional information to help you make the most out of this package:

Issues and Contributions

If you encounter any issues with the package or have suggestions for improvements, feel free to open an issue on the GitHub repository. Contributions are welcome, and we appreciate any help to make this package better.

License

This project is licensed under the MIT License. Feel free to review the terms and conditions.

Contact

For any further inquiries or communication, you can reach out to the package maintainer:

  • Maintainer: Mustafa majid
  • Email: mstafadev0@gmail.com
Support the Project

If you find this package helpful, consider giving it a star on GitHub and spreading the word. Your support is greatly appreciated!

Static Badge


Happy coding! 🚀

所属分类

源码仓库

使用此插件的项目

暂无相关数据。