country_detail.dart 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. import 'dart:html';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import 'package:hengyi/utils/dio_util.dart';
  5. class CountryDetailWidget extends StatelessWidget {
  6. CountryDetailWidget(this.countryId, {super.key});
  7. final int countryId;
  8. @override
  9. Widget build(BuildContext context) {
  10. return FutureBuilder(
  11. future: NetworkUtil().getCountryDetail(countryId),
  12. builder: (context, snapshot) {
  13. if (snapshot.connectionState == ConnectionState.done) {
  14. if (snapshot.hasData) {
  15. return Column(
  16. mainAxisAlignment: MainAxisAlignment.center,
  17. children: [
  18. Expanded(
  19. flex: 1,
  20. child: Column(
  21. children: [
  22. Container(
  23. margin: const EdgeInsets.only(top: 20),
  24. height: 150,
  25. child: Row(
  26. mainAxisAlignment: MainAxisAlignment.center,
  27. children: [
  28. Text(
  29. snapshot.data?.countryName ?? "",
  30. style: const TextStyle(
  31. fontSize: 24,
  32. fontWeight: FontWeight.bold,
  33. color: Colors.black),
  34. ),
  35. Image(
  36. image: NetworkImage(
  37. snapshot.data?.countryImgUrl ?? ""),
  38. width: 200.w,
  39. height: 150.w,
  40. ),
  41. ],
  42. ),
  43. ),
  44. Container(
  45. color: Colors.grey[300],
  46. height: 60.h,
  47. width: 800.w,
  48. margin: EdgeInsets.only(top: 20.w),
  49. child: Row(
  50. mainAxisAlignment: MainAxisAlignment.start,
  51. children: [
  52. Row(
  53. children: [
  54. Text(
  55. "签证须知:",
  56. style: TextStyle(
  57. fontSize: 14.sp,
  58. color: Colors.red,
  59. fontWeight: FontWeight.bold),
  60. ),
  61. Text(
  62. snapshot.data?.countryContent ?? "",
  63. style: TextStyle(
  64. fontSize: 14.sp,
  65. color: Colors.black,
  66. fontWeight: FontWeight.bold),
  67. ),
  68. ],
  69. )
  70. ],
  71. ),
  72. ),
  73. GestureDetector(
  74. onTap: () {
  75. if (snapshot.data != null &&
  76. snapshot.data!.countryVisitVisaUrl.isNotEmpty) {
  77. downLoadFile(snapshot.data!.countryVisitVisaUrl);
  78. }
  79. },
  80. child: Container(
  81. margin: EdgeInsets.only(top: 20.w),
  82. child: Text(
  83. "${snapshot.data?.countryName ?? ""}-旅游签证材料清单",
  84. style: TextStyle(
  85. fontSize: 14.sp,
  86. color: Colors.red,
  87. fontWeight: FontWeight.bold),
  88. ),
  89. ),
  90. ),
  91. GestureDetector(
  92. onTap: () {
  93. if (snapshot.data != null &&
  94. snapshot.data!.countryVisitVisaUrl.isNotEmpty) {
  95. downLoadFile(
  96. snapshot.data!.countryBusinessVisaUrl);
  97. }
  98. },
  99. child: Container(
  100. margin: EdgeInsets.only(top: 20.w),
  101. child: Text(
  102. "${snapshot.data?.countryName ?? ""}-商务签证材料清单",
  103. style: TextStyle(
  104. fontSize: 14.sp,
  105. color: Colors.red,
  106. fontWeight: FontWeight.bold),
  107. ),
  108. ),
  109. )
  110. ],
  111. ),
  112. ),
  113. ],
  114. );
  115. } else {
  116. return Text("Error:${snapshot.error}");
  117. }
  118. } else {
  119. return Container(
  120. alignment: Alignment.center,
  121. child: const CircularProgressIndicator(),
  122. );
  123. }
  124. });
  125. }
  126. ///调用浏览器的下载功能下载文件
  127. downLoadFile(url) {
  128. AnchorElement anchorElement = AnchorElement(href: url);
  129. anchorElement.download = "资料";
  130. anchorElement.click();
  131. }
  132. }