Files
MookNote/lib/widgets/master_detail_scaffold.dart
DelLevin-Home 1192f8f7e0 适配平板
2026-06-30 21:51:38 +08:00

37 lines
1.0 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/material.dart';
import '../utils/responsive.dart';
/// Master-Detail 布局包装器
/// 手机或 detail 为 null 时只显示 master平板显示左右分栏
class MasterDetailScaffold extends StatelessWidget {
final Widget master;
final Widget? detail;
final double masterFraction;
final double minMasterWidth;
const MasterDetailScaffold({
super.key,
required this.master,
this.detail,
this.masterFraction = 0.38,
this.minMasterWidth = 320,
});
@override
Widget build(BuildContext context) {
if (!Breakpoint.isWideContent(context) || detail == null) {
return master;
}
final screenWidth = MediaQuery.sizeOf(context).width;
final effectiveMasterWidth =
(screenWidth * masterFraction).clamp(minMasterWidth, screenWidth * 0.5);
return Row(
children: [
SizedBox(width: effectiveMasterWidth, child: master),
const VerticalDivider(width: 0.5, thickness: 0.5),
Expanded(child: detail!),
],
);
}
}