123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- import 'dart:html';
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:hengyi/utils/dio_util.dart';
- class CountryDetailWidget extends StatelessWidget {
- CountryDetailWidget(this.countryId, {super.key});
- final int countryId;
- @override
- Widget build(BuildContext context) {
- return FutureBuilder(
- future: NetworkUtil().getCountryDetail(countryId),
- builder: (context, snapshot) {
- if (snapshot.connectionState == ConnectionState.done) {
- if (snapshot.hasData) {
- return Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Expanded(
- flex: 1,
- child: Column(
- children: [
- Container(
- margin: const EdgeInsets.only(top: 20),
- height: 150,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text(
- snapshot.data?.countryName ?? "",
- style: const TextStyle(
- fontSize: 24,
- fontWeight: FontWeight.bold,
- color: Colors.black),
- ),
- Image(
- image: NetworkImage(
- snapshot.data?.countryImgUrl ?? ""),
- width: 200.w,
- height: 150.w,
- ),
- ],
- ),
- ),
- Container(
- color: Colors.grey[300],
- height: 60.h,
- width: 800.w,
- margin: EdgeInsets.only(top: 20.w),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.start,
- children: [
- Row(
- children: [
- Text(
- "签证须知:",
- style: TextStyle(
- fontSize: 14.sp,
- color: Colors.red,
- fontWeight: FontWeight.bold),
- ),
- Text(
- snapshot.data?.countryContent ?? "",
- style: TextStyle(
- fontSize: 14.sp,
- color: Colors.black,
- fontWeight: FontWeight.bold),
- ),
- ],
- )
- ],
- ),
- ),
- GestureDetector(
- onTap: () {
- if (snapshot.data != null &&
- snapshot.data!.countryVisitVisaUrl.isNotEmpty) {
- downLoadFile(snapshot.data!.countryVisitVisaUrl);
- }
- },
- child: Container(
- margin: EdgeInsets.only(top: 20.w),
- child: Text(
- "${snapshot.data?.countryName ?? ""}-旅游签证材料清单",
- style: TextStyle(
- fontSize: 14.sp,
- color: Colors.red,
- fontWeight: FontWeight.bold),
- ),
- ),
- ),
- GestureDetector(
- onTap: () {
- if (snapshot.data != null &&
- snapshot.data!.countryVisitVisaUrl.isNotEmpty) {
- downLoadFile(
- snapshot.data!.countryBusinessVisaUrl);
- }
- },
- child: Container(
- margin: EdgeInsets.only(top: 20.w),
- child: Text(
- "${snapshot.data?.countryName ?? ""}-商务签证材料清单",
- style: TextStyle(
- fontSize: 14.sp,
- color: Colors.red,
- fontWeight: FontWeight.bold),
- ),
- ),
- )
- ],
- ),
- ),
- ],
- );
- } else {
- return Text("Error:${snapshot.error}");
- }
- } else {
- return Container(
- alignment: Alignment.center,
- child: const CircularProgressIndicator(),
- );
- }
- });
- }
- ///调用浏览器的下载功能下载文件
- downLoadFile(url) {
- AnchorElement anchorElement = AnchorElement(href: url);
- anchorElement.download = "资料";
- anchorElement.click();
- }
- }
|