flutter_floor_layout
A flexible and extensible Flutter floor layout package using MVVM architecture.
基于 MVVM 架构设计的灵活可扩展 Flutter 楼层布局包。
Features
- MVVM 架构,视图和业务逻辑分离
- Flexible MVVM architecture for separation of UI and business logic
- 支持自定义楼层类型及样式
- Support custom floor types and styles
- 统一楼层注册机制,扩展方便
- Unified registration mechanism for easy extension
- 内置通用容器,支持圆角、内外边距、背景图、阴影等样式配置
- Built-in container with support for border radius, padding, background image, shadow, etc.
- 提供示例参考,快速集成
- Comes with example for quick start
Getting started
在你的 pubspec.yaml 中添加依赖:
Add this to your pubspec.yaml:
dependencies:
flutter_floor_layout:
git:
url: https://github.com/Greathao/flutter_floor_layout.git
ref: main
然后运行:
Then run:
flutter pub get
Usage
简单示例:
import 'package:flutter_floor_layout/flutter_floor_layout.dart';
void registerFloors() {
FloorRegistry.register(
'banner',
(model) => BannerViewModel(model as ExampleFloorModel),
(vm) => BannerWidget(viewModel: vm as BannerViewModel),
);
// 注册更多楼层
}
void main() {
registerFloors();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
final floors = mockFloors; // 楼层数据
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Floor Layout Demo')),
body: ListView(
children: floors.map((floor) {
final floorWidget = FloorRegistry.build(floor.floorType, floor)?.item2;
return floorWidget ?? const SizedBox();
}).toList(),
),
),
);
}
}
更多示例请查看 example/ 目录。
Additional information
请参阅项目源码和示例,了解更详细的自定义楼层和样式使用方法。 Refer to the source code and example folder for detailed custom floor and style usage.
MIT License © 2025 Greathao
欢迎 Issues 和 PR! Issues and PRs are welcome!