item_country.dart 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:fuwei/data/country_entity.dart';
  4. import 'package:fuwei/detail/detail.dart';
  5. import 'package:fuwei/utils/common_util.dart';
  6. class CountryItemWidget extends StatelessWidget {
  7. const CountryItemWidget(this.country, {super.key});
  8. final CountryEntity country;
  9. @override
  10. Widget build(BuildContext context) {
  11. var textSize = 0.0;
  12. var imageWidth = 0.0;
  13. var imageHeight = 0.0;
  14. if (Util.isWeb()) {
  15. textSize = 18.sp;
  16. imageWidth = 150.w;
  17. imageHeight = 100.w;
  18. } else {
  19. textSize = 60.sp;
  20. imageWidth = 500.w;
  21. imageHeight = 250.w;
  22. }
  23. return GestureDetector(
  24. onTap: () {
  25. Util.gotoPage(context, DetailPageWidget(country.id));
  26. },
  27. child: Column(
  28. mainAxisAlignment: MainAxisAlignment.center,
  29. children: [
  30. Image(
  31. image: NetworkImage(country.countryImgUrl),
  32. width: imageWidth,
  33. height: imageHeight,
  34. fit: BoxFit.fill,
  35. ),
  36. Padding(
  37. padding: EdgeInsets.only(top: 10.h),
  38. child: Text(
  39. country.countryName,
  40. style: TextStyle(fontSize: textSize, color: Colors.black),
  41. ),
  42. )
  43. ],
  44. ),
  45. );
  46. }
  47. }