PayItem.dart 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/widgets.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. class PayItem extends StatelessWidget {
  5. String label;
  6. ImageProvider icon;
  7. Function() onPress;
  8. PayItem({Key? key, required this.label, required this.icon, required this.onPress }) : super(key: key);
  9. @override
  10. Widget build(BuildContext context) {
  11. return Padding(
  12. padding: EdgeInsets.fromLTRB(15.w, 0, 15.w, 0),
  13. child: ListTile(
  14. onTap: () {
  15. onPress();
  16. },
  17. contentPadding: const EdgeInsets.symmetric(horizontal: 0.0),
  18. // 这边使用了contentPadding
  19. leading: Image(
  20. image: icon,
  21. width: 30.w,
  22. height: 30.w,
  23. ),
  24. title: Transform(
  25. transform: Matrix4.translationValues(-15, 0.0, 0.0),
  26. child: Text(label,
  27. style: TextStyle(
  28. fontSize: 18.sp, color: const Color(0xff333333))),
  29. ),
  30. trailing: Image(
  31. image: const AssetImage('images/userRight.png'),
  32. width: 10.w,
  33. height: 18.w,
  34. ),
  35. ),
  36. );
  37. }
  38. }