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(); } }