dict_flutter_extension 1.0.1 copy "dict_flutter_extension: ^1.0.1" to clipboard
dict_flutter_extension: ^1.0.1 copied to clipboard

为 Flutter Widget 提供常用扩展方法(点击、内边距、居中、尺寸、可见性等),并封装文件操作、页面导航、Widget 构建等工具类,内部项目通用的 Flutter 语法糖工具库。

dict_flutter_extension #

为 Flutter Widget 提供一组常用扩展方法(点击、内边距、居中、尺寸、可见性等),并封装文件操作、页面导航、Widget 构建等工具类,是内部项目通用的 Flutter 语法糖工具库。

Features #

Widget 扩展(WidgetExt#

在任意 Widget 上可直接调用:

  • click(onClick) — 添加 InkWell 点击事件。
  • clickGesture(onClick) — 添加 GestureDetector 点击事件。
  • padding(EdgeInsets) — 包裹 Padding
  • center() — 包裹 Center 居中。
  • align(Alignment) — 包裹 Align 设置对齐。
  • visibility(bool) — 通过 Offstage 控制显隐。
  • size(width, height) — 包裹 SizedBox 设置尺寸。
  • boundSize(minWidth, maxWidth, ...) — 包裹 ConstrainedBox 设置尺寸约束。
  • expanded([flex]) — 包裹 Expanded 用于 Flex 布局。

工具类 #

  • DictFileUtils — 文件名/后缀获取、文件大小计算、缓存清理、递归删除目录。
  • DictNavigatorUtilsforwardPage / forwardPageByName / back / exitApp 页面导航与退出。
  • DictWidgetUtilsgetMyAppBarNew 快速构建 AppBar、hideKeyboard 隐藏键盘、vb / hb 间距 Widget。

Getting started #

pubspec.yaml 中添加依赖:

dependencies:
  dict_flutter_extension: ^1.0.1

然后执行 flutter pub get

Usage #

import 'package:dict_flutter_extension/dict_flutter_extension.dart';

// Widget 扩展链式调用
Text('Hello')
    .padding(EdgeInsets.all(8))
    .center()
    .click(() => print('tapped'));

// 文件工具
String name = DictFileUtils.getFileName('/path/to/file.txt'); // file.txt
String size = DictFileUtils.renderSize(2048);                 // 2.00K

// 页面导航
forwardPage(context, MyPage());
back(context);

// Widget 工具
AppBar bar = getMyAppBarNew(context, '标题');
Widget gap = vb(16); // 纵向 16px 间距

Additional information #

该库为内部项目需求设计,API 可能随业务调整而变化,通用场景请自行评估兼容性。问题反馈请通过仓库主页提交。

1
likes
130
points
37
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

为 Flutter Widget 提供常用扩展方法(点击、内边距、居中、尺寸、可见性等),并封装文件操作、页面导航、Widget 构建等工具类,内部项目通用的 Flutter 语法糖工具库。

Homepage

License

MIT (license)

Dependencies

flutter

More

Packages that depend on dict_flutter_extension