honghengqiang 1 year ago
parent
commit
db6920da4e

BIN
build/c075001b96339384a97db4862b8ab8db.cache.dill.track.dill


+ 90 - 34
build/flutter_assets/NOTICES

@@ -1930,6 +1930,7 @@ POSSIBILITY OF SUCH DAMAGE.
 async
 collection
 stream_channel
+typed_data
 
 Copyright 2015, the Dart project authors. 
 
@@ -5586,6 +5587,30 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 --------------------------------------------------------------------------------
+dio
+
+MIT License
+
+Copyright (c) 2018 wendux
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+--------------------------------------------------------------------------------
 double-conversion
 icu
 
@@ -11037,6 +11062,41 @@ BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
 PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+--------------------------------------------------------------------------------
+http_parser
+matcher
+path
+source_span
+string_scanner
+
+Copyright 2014, the Dart project authors. 
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of Google LLC nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
 --------------------------------------------------------------------------------
 icu
 
@@ -11739,6 +11799,36 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
+--------------------------------------------------------------------------------
+json_annotation
+
+Copyright 2017, the Dart project authors. All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of Google Inc. nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
 --------------------------------------------------------------------------------
 khronos
 
@@ -13651,40 +13741,6 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
---------------------------------------------------------------------------------
-matcher
-path
-source_span
-string_scanner
-
-Copyright 2014, the Dart project authors. 
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    * Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-    * Redistributions in binary form must reproduce the above
-      copyright notice, this list of conditions and the following
-      disclaimer in the documentation and/or other materials provided
-      with the distribution.
-    * Neither the name of Google LLC nor the names of its
-      contributors may be used to endorse or promote products derived
-      from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 --------------------------------------------------------------------------------
 rapidjson
 

+ 28 - 0
lib/data/base_model_entity.dart

@@ -0,0 +1,28 @@
+import 'package:hengyi/generated/json/base/json_field.dart';
+import 'package:hengyi/generated/json/base_model_entity.g.dart';
+import 'dart:convert';
+
+@JsonSerializable()
+class BaseModelEntity<T> {
+
+	late int errorCode;
+	late String errorMsg;
+	late T data;
+  
+  BaseModelEntity();
+
+  factory BaseModelEntity.fromJson(Map<String, dynamic> json) => $BaseModelEntityFromJson(json);
+
+  Map<String, dynamic> toJson() => $BaseModelEntityToJson(this);
+
+  BaseModelEntity copyWith({int? errorCode, String? errorMsg, String? data}) {
+      return BaseModelEntity()..errorCode= errorCode ?? this.errorCode
+			..errorMsg= errorMsg ?? this.errorMsg
+			..data= data ?? this.data;
+  }
+    
+  @override
+  String toString() {
+    return jsonEncode(this);
+  }
+}

+ 1 - 1
lib/detail/country_detail.dart

@@ -47,7 +47,7 @@ class CountryDetailWidget extends StatelessWidget {
                     Row(
                       children: [
                         Text(
-                          "公告:",
+                          "签证须知:",
                           style: TextStyle(
                               fontSize: 14.sp,
                               color: Colors.red,

+ 110 - 0
lib/generated/json/base/json_convert_content.dart

@@ -0,0 +1,110 @@
+// ignore_for_file: non_constant_identifier_names
+// ignore_for_file: camel_case_types
+// ignore_for_file: prefer_single_quotes
+
+// This file is automatically generated. DO NOT EDIT, all your changes would be lost.
+import 'package:flutter/material.dart' show debugPrint;
+import 'package:hengyi/data/base_model_entity.dart';
+
+JsonConvert jsonConvert = JsonConvert();
+typedef JsonConvertFunction<T> = T Function(Map<String, dynamic> json);
+typedef EnumConvertFunction<T> = T Function(String value);
+
+class JsonConvert {
+	static final Map<String, JsonConvertFunction> convertFuncMap = {
+		(BaseModelEntity).toString(): BaseModelEntity.fromJson,
+	};
+
+  T? convert<T>(dynamic value, {EnumConvertFunction? enumConvert}) {
+    if (value == null) {
+      return null;
+    }
+    if (value is T) {
+      return value;
+    }
+    try {
+      return _asT<T>(value, enumConvert: enumConvert);
+    } catch (e, stackTrace) {
+      debugPrint('asT<$T> $e $stackTrace');
+      return null;
+    }
+  }
+
+  List<T?>? convertList<T>(List<dynamic>? value, {EnumConvertFunction? enumConvert}) {
+    if (value == null) {
+      return null;
+    }
+    try {
+      return value.map((dynamic e) => _asT<T>(e,enumConvert: enumConvert)).toList();
+    } catch (e, stackTrace) {
+      debugPrint('asT<$T> $e $stackTrace');
+      return <T>[];
+    }
+  }
+
+List<T>? convertListNotNull<T>(dynamic value, {EnumConvertFunction? enumConvert}) {
+    if (value == null) {
+      return null;
+    }
+    try {
+      return (value as List<dynamic>).map((dynamic e) => _asT<T>(e,enumConvert: enumConvert)!).toList();
+    } catch (e, stackTrace) {
+      debugPrint('asT<$T> $e $stackTrace');
+      return <T>[];
+    }
+  }
+
+  T? _asT<T extends Object?>(dynamic value,
+      {EnumConvertFunction? enumConvert}) {
+    final String type = T.toString();
+    final String valueS = value.toString();
+    if (enumConvert != null) {
+      return enumConvert(valueS) as T;
+    } else if (type == "String") {
+      return valueS as T;
+    } else if (type == "int") {
+      final int? intValue = int.tryParse(valueS);
+      if (intValue == null) {
+        return double.tryParse(valueS)?.toInt() as T?;
+      } else {
+        return intValue as T;
+      }
+    } else if (type == "double") {
+      return double.parse(valueS) as T;
+    } else if (type == "DateTime") {
+      return DateTime.parse(valueS) as T;
+    } else if (type == "bool") {
+      if (valueS == '0' || valueS == '1') {
+        return (valueS == '1') as T;
+      }
+      return (valueS == 'true') as T;
+    } else if (type == "Map" || type.startsWith("Map<")) {
+      return value as T;
+    } else {
+      if (convertFuncMap.containsKey(type)) {
+        return convertFuncMap[type]!(Map<String, dynamic>.from(value)) as T;
+      } else {
+        throw UnimplementedError('$type unimplemented');
+      }
+    }
+  }
+
+	//list is returned by type
+	static M? _getListChildType<M>(List<Map<String, dynamic>> data) {
+		if(<BaseModelEntity>[] is M){
+			return data.map<BaseModelEntity>((Map<String, dynamic> e) => BaseModelEntity.fromJson(e)).toList() as M;
+		}
+
+		debugPrint("${M.toString()} not found");
+	
+		return null;
+}
+
+	static M? fromJsonAsT<M>(dynamic json) {
+		if (json is List) {
+			return _getListChildType<M>(json.map((e) => e as Map<String, dynamic>).toList());
+		} else {
+			return jsonConvert.convert<M>(json);
+		}
+	}
+}

+ 25 - 0
lib/generated/json/base/json_field.dart

@@ -0,0 +1,25 @@
+// ignore_for_file: non_constant_identifier_names
+// ignore_for_file: camel_case_types
+// ignore_for_file: prefer_single_quotes
+
+// This file is automatically generated. DO NOT EDIT, all your changes would be lost.
+
+class JsonSerializable{
+    const JsonSerializable();
+}
+
+class JSONField {
+  //Specify the parse field name
+  final String? name;
+
+  //Whether to participate in toJson
+  final bool? serialize;
+  
+  //Whether to participate in fromMap
+  final bool? deserialize;
+  
+  //Enumeration or not
+  final bool? isEnum;
+  
+  const JSONField({this.name, this.serialize, this.deserialize, this.isEnum});
+}

+ 27 - 0
lib/generated/json/base_model_entity.g.dart

@@ -0,0 +1,27 @@
+import 'package:hengyi/generated/json/base/json_convert_content.dart';
+import 'package:hengyi/data/base_model_entity.dart';
+
+BaseModelEntity<T> $BaseModelEntityFromJson<T>(Map<String, dynamic> json) {
+	final BaseModelEntity<T> baseModelEntity = BaseModelEntity<T>();
+	final int? errorCode = jsonConvert.convert<int>(json['errorCode']);
+	if (errorCode != null) {
+		baseModelEntity.errorCode = errorCode;
+	}
+	final String? errorMsg = jsonConvert.convert<String>(json['errorMsg']);
+	if (errorMsg != null) {
+		baseModelEntity.errorMsg = errorMsg;
+	}
+	final T? data = JsonConvert.fromJsonAsT(json['data']);
+	if (data != null) {
+		baseModelEntity.data = data;
+	}
+	return baseModelEntity;
+}
+
+Map<String, dynamic> $BaseModelEntityToJson(BaseModelEntity entity) {
+	final Map<String, dynamic> data = <String, dynamic>{};
+	data['errorCode'] = entity.errorCode;
+	data['errorMsg'] = entity.errorMsg;
+	data['data'] = entity.data;
+	return data;
+}

+ 4 - 6
lib/home/item_country.dart

@@ -1,7 +1,7 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
-import 'package:hengyi/detail/country_detail.dart';
 import 'package:hengyi/detail/detail.dart';
+import 'package:hengyi/utils/common_util.dart';
 
 class CountryItemWidget extends StatelessWidget {
   const CountryItemWidget(this.url, {super.key});
@@ -12,19 +12,17 @@ class CountryItemWidget extends StatelessWidget {
   Widget build(BuildContext context) {
     return GestureDetector(
       onTap: () {
-        Navigator.push(context,
-            MaterialPageRoute(builder: (context) => DetailPageWidget()));
-        print("点击位置---$url");
+        Util.gotoPage(context, const DetailPageWidget());
       },
       child: Column(
         mainAxisAlignment: MainAxisAlignment.center,
         children: [
           Image(
-            image: AssetImage("images/logo.png"),
+            image: const AssetImage("images/logo.png"),
             width: 120.w,
             height: 120.w,
           ),
-          Text(
+          const Text(
             "美国",
             style: TextStyle(fontSize: 14, color: Colors.black),
           )

+ 17 - 0
lib/utils/common_util.dart

@@ -0,0 +1,17 @@
+import 'package:flutter/material.dart';
+
+class Util {
+  /// 页面跳转
+  static void gotoPage(BuildContext context, Widget widget) {
+    Navigator.push(
+        context,
+        PageRouteBuilder(
+            transitionDuration: const Duration(milliseconds: 400),
+            pageBuilder: ((context, animation, secondaryAnimation) {
+              return FadeTransition(
+                opacity: animation,
+                child: widget,
+              );
+            })));
+  }
+}

+ 12 - 0
lib/utils/dio_util.dart

@@ -0,0 +1,12 @@
+import 'dart:convert';
+
+import 'package:dio/dio.dart';
+import 'package:hengyi/data/base_model_entity.dart';
+
+class NetworkUtil {
+  Future<List<String>> networkrequest() async {
+    var response = await Dio().get("https://www.wanandroid.com/banner/json");
+    var data = json.decode(response.toString());
+    return BaseModelEntity<List<String>>.fromJson(data).data;
+  }
+}

+ 32 - 0
pubspec.lock

@@ -49,6 +49,14 @@ packages:
       url: "https://pub.flutter-io.cn"
     source: hosted
     version: "1.0.5"
+  dio:
+    dependency: "direct main"
+    description:
+      name: dio
+      sha256: "7d328c4d898a61efc3cd93655a0955858e29a0aa647f0f9e02d59b3bb275e2e8"
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "4.0.6"
   fake_async:
     dependency: transitive
     description:
@@ -83,6 +91,14 @@ packages:
     description: flutter
     source: sdk
     version: "0.0.0"
+  http_parser:
+    dependency: transitive
+    description:
+      name: http_parser
+      sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "4.0.2"
   js:
     dependency: transitive
     description:
@@ -91,6 +107,14 @@ packages:
       url: "https://pub.flutter-io.cn"
     source: hosted
     version: "0.6.5"
+  json_annotation:
+    dependency: "direct main"
+    description:
+      name: json_annotation
+      sha256: c33da08e136c3df0190bd5bbe51ae1df4a7d96e7954d1d7249fea2968a72d317
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "4.8.0"
   lints:
     dependency: transitive
     description:
@@ -184,6 +208,14 @@ packages:
       url: "https://pub.flutter-io.cn"
     source: hosted
     version: "0.4.16"
+  typed_data:
+    dependency: transitive
+    description:
+      name: typed_data
+      sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5"
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "1.3.1"
   vector_math:
     dependency: transitive
     description:

+ 2 - 0
pubspec.yaml

@@ -36,6 +36,8 @@ dependencies:
   # Use with the CupertinoIcons class for iOS style icons.
   cupertino_icons: ^1.0.2
   flutter_screenutil: ^5.7.0
+  dio: ^4.0.4
+  json_annotation: ^4.5.0
 
 dev_dependencies:
   flutter_test: