Commit 35cdb7c51533d6ac9c95c773cc81c9fb85d2639c
1 parent
0b0a48ea
fix:购买页样式写死导致超出父视图范围,点击事件丢失
Showing
1 changed file
with
34 additions
and
31 deletions
lib/pages/shop/home/widgets/product_item.dart
| 1 | -import 'package:cached_network_image/cached_network_image.dart'; | ||
| 2 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; | 
| 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 
| 4 | import 'package:wow_english/models/product_entity.dart'; | 3 | import 'package:wow_english/models/product_entity.dart'; | 
| @@ -47,44 +46,48 @@ class ProductItem extends StatelessWidget { | @@ -47,44 +46,48 @@ class ProductItem extends StatelessWidget { | ||
| 47 | style: TextStyle( | 46 | style: TextStyle( | 
| 48 | fontSize: 16.sp, color: const Color(0xFF333333)), | 47 | fontSize: 16.sp, color: const Color(0xFF333333)), | 
| 49 | ), | 48 | ), | 
| 50 | - RichText( | ||
| 51 | - text: TextSpan(children: [ | ||
| 52 | - TextSpan( | ||
| 53 | - text: '¥', | 49 | + FittedBox( | 
| 50 | + fit: BoxFit.scaleDown, | ||
| 51 | + child: RichText( | ||
| 52 | + text: TextSpan(children: [ | ||
| 53 | + TextSpan( | ||
| 54 | + text: '¥', | ||
| 55 | + style: TextStyle( | ||
| 56 | + fontSize: 21.sp, | ||
| 57 | + color: const Color(0xFFF51A1A), | ||
| 58 | + )), | ||
| 59 | + TextSpan( | ||
| 60 | + text: entity?.price?.toString() ?? '', | ||
| 54 | style: TextStyle( | 61 | style: TextStyle( | 
| 55 | - fontSize: 21.sp, | 62 | + fontSize: 40.sp, | 
| 56 | color: const Color(0xFFF51A1A), | 63 | color: const Color(0xFFF51A1A), | 
| 57 | - )), | ||
| 58 | - TextSpan( | ||
| 59 | - text: entity?.price?.toString() ?? '', | ||
| 60 | - style: TextStyle( | ||
| 61 | - fontSize: 40.sp, | ||
| 62 | - color: const Color(0xFFF51A1A), | ||
| 63 | - ), | ||
| 64 | - ) | ||
| 65 | - ]), | 64 | + ), | 
| 65 | + ) | ||
| 66 | + ]), | ||
| 67 | + ), | ||
| 66 | ), | 68 | ), | 
| 67 | GestureDetector( | 69 | GestureDetector( | 
| 68 | onTap: () { | 70 | onTap: () { | 
| 69 | onTap(); | 71 | onTap(); | 
| 70 | }, | 72 | }, | 
| 71 | child: Container( | 73 | child: Container( | 
| 72 | - decoration: BoxDecoration( | ||
| 73 | - color: const Color(0xFFF5C51F), | ||
| 74 | - borderRadius: BorderRadius.circular(5.r), | ||
| 75 | - border: Border.all( | ||
| 76 | - color: const Color(0xFF333333), | ||
| 77 | - width: 1.0, | ||
| 78 | - )), | ||
| 79 | - padding: EdgeInsets.symmetric( | ||
| 80 | - vertical: 1.h, | ||
| 81 | - horizontal: 26.5.w, | ||
| 82 | - ), | ||
| 83 | - child: Text( | ||
| 84 | - '立即购买', | ||
| 85 | - style: TextStyle( | ||
| 86 | - fontSize: 10.sp, color: const Color(0xFF333333)), | ||
| 87 | - ), | 74 | + decoration: BoxDecoration( | 
| 75 | + color: const Color(0xFFF5C51F), | ||
| 76 | + borderRadius: BorderRadius.circular(5.r), | ||
| 77 | + border: Border.all( | ||
| 78 | + color: const Color(0xFF333333), | ||
| 79 | + width: 1.0, | ||
| 80 | + )), | ||
| 81 | + padding: EdgeInsets.symmetric( | ||
| 82 | + vertical: 1.h | ||
| 83 | + ), | ||
| 84 | + child: Center( | ||
| 85 | + child: Text( | ||
| 86 | + '立即购买', | ||
| 87 | + style: TextStyle( | ||
| 88 | + fontSize: 10.sp, color: const Color(0xFF333333)), | ||
| 89 | + ), | ||
| 90 | + ) | ||
| 88 | ), | 91 | ), | 
| 89 | ) | 92 | ) | 
| 90 | ], | 93 | ], | 
