70 lines
2.0 KiB
Dart
70 lines
2.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
class CustomCellWidget extends StatelessWidget {
|
|
const CustomCellWidget({
|
|
super.key,
|
|
required this.leftText,
|
|
this.leftIcon,
|
|
this.rightWidget,
|
|
this.onTap,
|
|
this.visible = true,
|
|
});
|
|
|
|
final String leftText;
|
|
final Icon? leftIcon;
|
|
final Widget? rightWidget;
|
|
final GestureTapCallback? onTap;
|
|
final bool visible; // 控制是否显示
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// 如果不显示,返回空
|
|
if (!visible) {
|
|
return const SizedBox.shrink();
|
|
}
|
|
return GestureDetector(
|
|
onTap: onTap,
|
|
child: Container(
|
|
width: double.infinity,
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.all(Radius.circular(8.r)),
|
|
),
|
|
margin: EdgeInsets.symmetric(vertical: 10.h),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
if (leftIcon != null) leftIcon!,
|
|
if (leftIcon != null) SizedBox(width: 4.w),
|
|
Text(
|
|
leftText,
|
|
style: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Colors.black87,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
rightWidget ??
|
|
Text(
|
|
'未填写',
|
|
style: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Colors.black54,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|