Files
smart_grid_iot_app_flutter/lib/shared/widgets/x_card.dart
T
andyesfly 56830e94ec feat: 完成智能电网电工端 Flutter 应用初始化
创建完整的 Flutter 项目结构,包含 Android 和 iOS 平台配置、核心网络层、路由、状态管理及业务模块(订单、收益、认证),适配原 uni-app 项目功能逻辑
2026-10-06 11:54:10 +08:00

60 lines
1.5 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 '../../core/theme/app_colors.dart';
import '../../core/theme/app_dimens.dart';
/// 各页面 `.ios-card` 的等价实现:白底 + 浅描边 + 圆角 + 极淡阴影。
class XCard extends StatelessWidget {
const XCard({
super.key,
required this.child,
this.padding,
this.margin,
this.radius = AppRadius.xl,
this.background = AppColors.surfaceContainerLowest,
this.borderColor = AppColors.borderSoft,
this.shadows = AppShadows.card,
this.onTap,
});
final Widget child;
final EdgeInsetsGeometry? padding;
final EdgeInsetsGeometry? margin;
final double radius;
final Color background;
final Color borderColor;
/// 订单卡片用 [AppShadows.orderCard](0 2px 8px),其余用 [AppShadows.card]。
final List<BoxShadow> shadows;
final VoidCallback? onTap;
@override
Widget build(BuildContext context) {
final r = BorderRadius.circular(radius);
final content = Container(
padding: padding,
decoration: BoxDecoration(
color: background,
border: Border.all(color: borderColor),
borderRadius: r,
boxShadow: shadows,
),
child: child,
);
return Padding(
padding: margin ?? EdgeInsets.zero,
child: onTap == null
? content
: Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
borderRadius: r,
child: content,
),
),
);
}
}