json_convert_content.dart 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. // ignore_for_file: non_constant_identifier_names
  2. // ignore_for_file: camel_case_types
  3. // ignore_for_file: prefer_single_quotes
  4. // This file is automatically generated. DO NOT EDIT, all your changes would be lost.
  5. import 'package:flutter/material.dart' show debugPrint;
  6. import 'package:domain/entity/auth_login_entity.dart';
  7. import 'package:domain/entity/captcha_img_entity.dart';
  8. import 'package:domain/entity/facility_book_entity.dart';
  9. import 'package:domain/entity/facility_index_entity.dart';
  10. import 'package:domain/entity/facility_page_entity.dart';
  11. import 'package:domain/entity/feedback_detail_entity.dart';
  12. import 'package:domain/entity/feedback_list_entity.dart';
  13. import 'package:domain/entity/form_content_entity.dart';
  14. import 'package:domain/entity/form_detail_entity.dart';
  15. import 'package:domain/entity/form_list_entity.dart';
  16. import 'package:domain/entity/form_option_entity.dart';
  17. import 'package:domain/entity/form_submitted_entity.dart';
  18. import 'package:domain/entity/form_submitted_page_entity.dart';
  19. import 'package:domain/entity/garage_sale_rent_detail_entity.dart';
  20. import 'package:domain/entity/garage_sale_rent_entity.dart';
  21. import 'package:domain/entity/id_name_entity.dart';
  22. import 'package:domain/entity/myfollowing_list_entity.dart';
  23. import 'package:domain/entity/myposts_newsfeed_entity.dart';
  24. import 'package:domain/entity/myposts_sale_rent_entity.dart';
  25. import 'package:domain/entity/newsfeed_comment_publish_entity.dart';
  26. import 'package:domain/entity/newsfeed_detail_entity.dart';
  27. import 'package:domain/entity/newsfeed_following_entity.dart';
  28. import 'package:domain/entity/newsfeed_foryou_entity.dart';
  29. import 'package:domain/entity/newsfeed_news_entity.dart';
  30. import 'package:domain/entity/notice_board_announ_entity.dart';
  31. import 'package:domain/entity/notice_board_documents_entity.dart';
  32. import 'package:domain/entity/notice_board_event_entity.dart';
  33. import 'package:domain/entity/payment_page_entity.dart';
  34. import 'package:domain/entity/property_news_entity.dart';
  35. import 'package:domain/entity/property_sale_rent_entity.dart';
  36. import 'package:domain/entity/server_time.dart';
  37. import 'package:domain/entity/user_me_entity.dart';
  38. import 'package:domain/entity/visitor_page_entity.dart';
  39. JsonConvert jsonConvert = JsonConvert();
  40. typedef JsonConvertFunction<T> = T Function(Map<String, dynamic> json);
  41. typedef EnumConvertFunction<T> = T Function(String value);
  42. typedef ConvertExceptionHandler = void Function(Object error, StackTrace stackTrace);
  43. extension MapSafeExt<K, V> on Map<K, V> {
  44. T? getOrNull<T>(K? key) {
  45. if (!containsKey(key) || key == null) {
  46. return null;
  47. } else {
  48. return this[key] as T?;
  49. }
  50. }
  51. }
  52. class JsonConvert {
  53. static ConvertExceptionHandler? onError;
  54. JsonConvertClassCollection convertFuncMap = JsonConvertClassCollection();
  55. /// When you are in the development, to generate a new model class, hot-reload doesn't find new generation model class, you can build on MaterialApp method called jsonConvert. ReassembleConvertFuncMap (); This method only works in a development environment
  56. /// https://flutter.cn/docs/development/tools/hot-reload
  57. /// class MyApp extends StatelessWidget {
  58. /// const MyApp({Key? key})
  59. /// : super(key: key);
  60. ///
  61. /// @override
  62. /// Widget build(BuildContext context) {
  63. /// jsonConvert.reassembleConvertFuncMap();
  64. /// return MaterialApp();
  65. /// }
  66. /// }
  67. void reassembleConvertFuncMap() {
  68. bool isReleaseMode = const bool.fromEnvironment('dart.vm.product');
  69. if (!isReleaseMode) {
  70. convertFuncMap = JsonConvertClassCollection();
  71. }
  72. }
  73. T? convert<T>(dynamic value, {EnumConvertFunction? enumConvert}) {
  74. if (value == null) {
  75. return null;
  76. }
  77. if (value is T) {
  78. return value;
  79. }
  80. try {
  81. return _asT<T>(value, enumConvert: enumConvert);
  82. } catch (e, stackTrace) {
  83. debugPrint('asT<$T> $e $stackTrace');
  84. if (onError != null) {
  85. onError!(e, stackTrace);
  86. }
  87. return null;
  88. }
  89. }
  90. List<T?>? convertList<T>(List<dynamic>? value,
  91. {EnumConvertFunction? enumConvert}) {
  92. if (value == null) {
  93. return null;
  94. }
  95. try {
  96. return value.map((dynamic e) => _asT<T>(e, enumConvert: enumConvert))
  97. .toList();
  98. } catch (e, stackTrace) {
  99. debugPrint('asT<$T> $e $stackTrace');
  100. if (onError != null) {
  101. onError!(e, stackTrace);
  102. }
  103. return <T>[];
  104. }
  105. }
  106. List<T>? convertListNotNull<T>(dynamic value,
  107. {EnumConvertFunction? enumConvert}) {
  108. if (value == null) {
  109. return null;
  110. }
  111. try {
  112. return (value as List<dynamic>).map((dynamic e) =>
  113. _asT<T>(e, enumConvert: enumConvert)!).toList();
  114. } catch (e, stackTrace) {
  115. debugPrint('asT<$T> $e $stackTrace');
  116. if (onError != null) {
  117. onError!(e, stackTrace);
  118. }
  119. return <T>[];
  120. }
  121. }
  122. T? _asT<T extends Object?>(dynamic value,
  123. {EnumConvertFunction? enumConvert}) {
  124. final String type = T.toString();
  125. final String valueS = value.toString();
  126. if (enumConvert != null) {
  127. return enumConvert(valueS) as T;
  128. } else if (type == "String") {
  129. return valueS as T;
  130. } else if (type == "int") {
  131. final int? intValue = int.tryParse(valueS);
  132. if (intValue == null) {
  133. return double.tryParse(valueS)?.toInt() as T?;
  134. } else {
  135. return intValue as T;
  136. }
  137. } else if (type == "double") {
  138. return double.parse(valueS) as T;
  139. } else if (type == "DateTime") {
  140. return DateTime.parse(valueS) as T;
  141. } else if (type == "bool") {
  142. if (valueS == '0' || valueS == '1') {
  143. return (valueS == '1') as T;
  144. }
  145. return (valueS == 'true') as T;
  146. } else if (type == "Map" || type.startsWith("Map<")) {
  147. return value as T;
  148. } else {
  149. if (convertFuncMap.containsKey(type)) {
  150. if (value == null) {
  151. return null;
  152. }
  153. var covertFunc = convertFuncMap[type]!;
  154. if (covertFunc is Map<String, dynamic>) {
  155. return covertFunc(value as Map<String, dynamic>) as T;
  156. } else {
  157. return covertFunc(Map<String, dynamic>.from(value)) as T;
  158. }
  159. } else {
  160. throw UnimplementedError(
  161. '$type unimplemented,you can try running the app again');
  162. }
  163. }
  164. }
  165. //list is returned by type
  166. static M? _getListChildType<M>(List<Map<String, dynamic>> data) {
  167. if (<AuthLoginEntity>[] is M) {
  168. return data.map<AuthLoginEntity>((Map<String, dynamic> e) =>
  169. AuthLoginEntity.fromJson(e)).toList() as M;
  170. }
  171. if (<CaptchaImgEntity>[] is M) {
  172. return data.map<CaptchaImgEntity>((Map<String, dynamic> e) =>
  173. CaptchaImgEntity.fromJson(e)).toList() as M;
  174. }
  175. if (<FacilityBookEntity>[] is M) {
  176. return data.map<FacilityBookEntity>((Map<String, dynamic> e) =>
  177. FacilityBookEntity.fromJson(e)).toList() as M;
  178. }
  179. if (<FacilityBookFacilityType>[] is M) {
  180. return data.map<FacilityBookFacilityType>((Map<String, dynamic> e) =>
  181. FacilityBookFacilityType.fromJson(e)).toList() as M;
  182. }
  183. if (<FacilityBookFacilities>[] is M) {
  184. return data.map<FacilityBookFacilities>((Map<String, dynamic> e) =>
  185. FacilityBookFacilities.fromJson(e)).toList() as M;
  186. }
  187. if (<FacilityBookFacilitiesPeriods>[] is M) {
  188. return data.map<FacilityBookFacilitiesPeriods>((Map<String, dynamic> e) =>
  189. FacilityBookFacilitiesPeriods.fromJson(e)).toList() as M;
  190. }
  191. if (<FacilityIndexEntity>[] is M) {
  192. return data.map<FacilityIndexEntity>((Map<String, dynamic> e) =>
  193. FacilityIndexEntity.fromJson(e)).toList() as M;
  194. }
  195. if (<FacilityPageEntity>[] is M) {
  196. return data.map<FacilityPageEntity>((Map<String, dynamic> e) =>
  197. FacilityPageEntity.fromJson(e)).toList() as M;
  198. }
  199. if (<FacilityDetail>[] is M) {
  200. return data.map<FacilityDetail>((Map<String, dynamic> e) =>
  201. FacilityDetail.fromJson(e)).toList() as M;
  202. }
  203. if (<FacilityPageListBooking>[] is M) {
  204. return data.map<FacilityPageListBooking>((Map<String, dynamic> e) =>
  205. FacilityPageListBooking.fromJson(e)).toList() as M;
  206. }
  207. if (<FacilityPageListFacility>[] is M) {
  208. return data.map<FacilityPageListFacility>((Map<String, dynamic> e) =>
  209. FacilityPageListFacility.fromJson(e)).toList() as M;
  210. }
  211. if (<FacilityPageListFacilityType>[] is M) {
  212. return data.map<FacilityPageListFacilityType>((Map<String, dynamic> e) =>
  213. FacilityPageListFacilityType.fromJson(e)).toList() as M;
  214. }
  215. if (<FacilityPageListTimePeriod>[] is M) {
  216. return data.map<FacilityPageListTimePeriod>((Map<String, dynamic> e) =>
  217. FacilityPageListTimePeriod.fromJson(e)).toList() as M;
  218. }
  219. if (<FacilityPageListAccount>[] is M) {
  220. return data.map<FacilityPageListAccount>((Map<String, dynamic> e) =>
  221. FacilityPageListAccount.fromJson(e)).toList() as M;
  222. }
  223. if (<FeedbackDetailEntity>[] is M) {
  224. return data.map<FeedbackDetailEntity>((Map<String, dynamic> e) =>
  225. FeedbackDetailEntity.fromJson(e)).toList() as M;
  226. }
  227. if (<FeedbackDetailReplies>[] is M) {
  228. return data.map<FeedbackDetailReplies>((Map<String, dynamic> e) =>
  229. FeedbackDetailReplies.fromJson(e)).toList() as M;
  230. }
  231. if (<FeedbackListEntity>[] is M) {
  232. return data.map<FeedbackListEntity>((Map<String, dynamic> e) =>
  233. FeedbackListEntity.fromJson(e)).toList() as M;
  234. }
  235. if (<FeedbackItemEntity>[] is M) {
  236. return data.map<FeedbackItemEntity>((Map<String, dynamic> e) =>
  237. FeedbackItemEntity.fromJson(e)).toList() as M;
  238. }
  239. if (<FormContentEntity>[] is M) {
  240. return data.map<FormContentEntity>((Map<String, dynamic> e) =>
  241. FormContentEntity.fromJson(e)).toList() as M;
  242. }
  243. if (<FormDetailEntity>[] is M) {
  244. return data.map<FormDetailEntity>((Map<String, dynamic> e) =>
  245. FormDetailEntity.fromJson(e)).toList() as M;
  246. }
  247. if (<FormListEntity>[] is M) {
  248. return data.map<FormListEntity>((Map<String, dynamic> e) =>
  249. FormListEntity.fromJson(e)).toList() as M;
  250. }
  251. if (<FormOptionEntity>[] is M) {
  252. return data.map<FormOptionEntity>((Map<String, dynamic> e) =>
  253. FormOptionEntity.fromJson(e)).toList() as M;
  254. }
  255. if (<FormSubmittedEntity>[] is M) {
  256. return data.map<FormSubmittedEntity>((Map<String, dynamic> e) =>
  257. FormSubmittedEntity.fromJson(e)).toList() as M;
  258. }
  259. if (<FormSubmittedEstateOnlineForm>[] is M) {
  260. return data.map<FormSubmittedEstateOnlineForm>((Map<String, dynamic> e) =>
  261. FormSubmittedEstateOnlineForm.fromJson(e)).toList() as M;
  262. }
  263. if (<FormSubmittedPageEntity>[] is M) {
  264. return data.map<FormSubmittedPageEntity>((Map<String, dynamic> e) =>
  265. FormSubmittedPageEntity.fromJson(e)).toList() as M;
  266. }
  267. if (<GarageSaleRentDetailEntity>[] is M) {
  268. return data.map<GarageSaleRentDetailEntity>((Map<String, dynamic> e) =>
  269. GarageSaleRentDetailEntity.fromJson(e)).toList() as M;
  270. }
  271. if (<GarageSaleRentDetailAccount>[] is M) {
  272. return data.map<GarageSaleRentDetailAccount>((Map<String, dynamic> e) =>
  273. GarageSaleRentDetailAccount.fromJson(e)).toList() as M;
  274. }
  275. if (<GarageSaleRentEntity>[] is M) {
  276. return data.map<GarageSaleRentEntity>((Map<String, dynamic> e) =>
  277. GarageSaleRentEntity.fromJson(e)).toList() as M;
  278. }
  279. if (<GarageSaleRentList>[] is M) {
  280. return data.map<GarageSaleRentList>((Map<String, dynamic> e) =>
  281. GarageSaleRentList.fromJson(e)).toList() as M;
  282. }
  283. if (<GarageSaleRentListAccount>[] is M) {
  284. return data.map<GarageSaleRentListAccount>((Map<String, dynamic> e) =>
  285. GarageSaleRentListAccount.fromJson(e)).toList() as M;
  286. }
  287. if (<IdNameEntity>[] is M) {
  288. return data.map<IdNameEntity>((Map<String, dynamic> e) =>
  289. IdNameEntity.fromJson(e)).toList() as M;
  290. }
  291. if (<MyfollowingListEntity>[] is M) {
  292. return data.map<MyfollowingListEntity>((Map<String, dynamic> e) =>
  293. MyfollowingListEntity.fromJson(e)).toList() as M;
  294. }
  295. if (<MypostsNewsfeedEntity>[] is M) {
  296. return data.map<MypostsNewsfeedEntity>((Map<String, dynamic> e) =>
  297. MypostsNewsfeedEntity.fromJson(e)).toList() as M;
  298. }
  299. if (<MypostsNewsfeedList>[] is M) {
  300. return data.map<MypostsNewsfeedList>((Map<String, dynamic> e) =>
  301. MypostsNewsfeedList.fromJson(e)).toList() as M;
  302. }
  303. if (<MypostsNewsfeedListAccount>[] is M) {
  304. return data.map<MypostsNewsfeedListAccount>((Map<String, dynamic> e) =>
  305. MypostsNewsfeedListAccount.fromJson(e)).toList() as M;
  306. }
  307. if (<MypostsSaleRentEntity>[] is M) {
  308. return data.map<MypostsSaleRentEntity>((Map<String, dynamic> e) =>
  309. MypostsSaleRentEntity.fromJson(e)).toList() as M;
  310. }
  311. if (<MypostsSaleRentList>[] is M) {
  312. return data.map<MypostsSaleRentList>((Map<String, dynamic> e) =>
  313. MypostsSaleRentList.fromJson(e)).toList() as M;
  314. }
  315. if (<NewsfeedCommentPublishEntity>[] is M) {
  316. return data.map<NewsfeedCommentPublishEntity>((Map<String, dynamic> e) =>
  317. NewsfeedCommentPublishEntity.fromJson(e)).toList() as M;
  318. }
  319. if (<NewsfeedDetailEntity>[] is M) {
  320. return data.map<NewsfeedDetailEntity>((Map<String, dynamic> e) =>
  321. NewsfeedDetailEntity.fromJson(e)).toList() as M;
  322. }
  323. if (<NewsfeedDetailAccount>[] is M) {
  324. return data.map<NewsfeedDetailAccount>((Map<String, dynamic> e) =>
  325. NewsfeedDetailAccount.fromJson(e)).toList() as M;
  326. }
  327. if (<NewsfeedDetailComments>[] is M) {
  328. return data.map<NewsfeedDetailComments>((Map<String, dynamic> e) =>
  329. NewsfeedDetailComments.fromJson(e)).toList() as M;
  330. }
  331. if (<NewsfeedDetailCommentsAccount>[] is M) {
  332. return data.map<NewsfeedDetailCommentsAccount>((Map<String, dynamic> e) =>
  333. NewsfeedDetailCommentsAccount.fromJson(e)).toList() as M;
  334. }
  335. if (<NewsfeedDetailCommentsToAccount>[] is M) {
  336. return data.map<NewsfeedDetailCommentsToAccount>((
  337. Map<String, dynamic> e) =>
  338. NewsfeedDetailCommentsToAccount.fromJson(e)).toList() as M;
  339. }
  340. if (<NewsfeedFollowingEntity>[] is M) {
  341. return data.map<NewsfeedFollowingEntity>((Map<String, dynamic> e) =>
  342. NewsfeedFollowingEntity.fromJson(e)).toList() as M;
  343. }
  344. if (<NewsfeedFollowingList>[] is M) {
  345. return data.map<NewsfeedFollowingList>((Map<String, dynamic> e) =>
  346. NewsfeedFollowingList.fromJson(e)).toList() as M;
  347. }
  348. if (<NewsfeedFollowingListAccount>[] is M) {
  349. return data.map<NewsfeedFollowingListAccount>((Map<String, dynamic> e) =>
  350. NewsfeedFollowingListAccount.fromJson(e)).toList() as M;
  351. }
  352. if (<NewsfeedForyouEntity>[] is M) {
  353. return data.map<NewsfeedForyouEntity>((Map<String, dynamic> e) =>
  354. NewsfeedForyouEntity.fromJson(e)).toList() as M;
  355. }
  356. if (<NewsfeedForyouList>[] is M) {
  357. return data.map<NewsfeedForyouList>((Map<String, dynamic> e) =>
  358. NewsfeedForyouList.fromJson(e)).toList() as M;
  359. }
  360. if (<NewsfeedForyouListAccount>[] is M) {
  361. return data.map<NewsfeedForyouListAccount>((Map<String, dynamic> e) =>
  362. NewsfeedForyouListAccount.fromJson(e)).toList() as M;
  363. }
  364. if (<NewsfeedNewsEntity>[] is M) {
  365. return data.map<NewsfeedNewsEntity>((Map<String, dynamic> e) =>
  366. NewsfeedNewsEntity.fromJson(e)).toList() as M;
  367. }
  368. if (<NewsfeedNewsList>[] is M) {
  369. return data.map<NewsfeedNewsList>((Map<String, dynamic> e) =>
  370. NewsfeedNewsList.fromJson(e)).toList() as M;
  371. }
  372. if (<NewsfeedNewsListAccount>[] is M) {
  373. return data.map<NewsfeedNewsListAccount>((Map<String, dynamic> e) =>
  374. NewsfeedNewsListAccount.fromJson(e)).toList() as M;
  375. }
  376. if (<NoticeBoardAnnounEntity>[] is M) {
  377. return data.map<NoticeBoardAnnounEntity>((Map<String, dynamic> e) =>
  378. NoticeBoardAnnounEntity.fromJson(e)).toList() as M;
  379. }
  380. if (<NoticeBoardDocumentsEntity>[] is M) {
  381. return data.map<NoticeBoardDocumentsEntity>((Map<String, dynamic> e) =>
  382. NoticeBoardDocumentsEntity.fromJson(e)).toList() as M;
  383. }
  384. if (<NoticeBoardEventEntity>[] is M) {
  385. return data.map<NoticeBoardEventEntity>((Map<String, dynamic> e) =>
  386. NoticeBoardEventEntity.fromJson(e)).toList() as M;
  387. }
  388. if (<PaymentPageEntity>[] is M) {
  389. return data.map<PaymentPageEntity>((Map<String, dynamic> e) => PaymentPageEntity.fromJson(e)).toList() as M;
  390. }
  391. if (<PaymentPageList>[] is M) {
  392. return data.map<PaymentPageList>((Map<String, dynamic> e) => PaymentPageList.fromJson(e)).toList() as M;
  393. }
  394. if (<PropertyNewsEntity>[] is M) {
  395. return data.map<PropertyNewsEntity>((Map<String, dynamic> e) =>
  396. PropertyNewsEntity.fromJson(e)).toList() as M;
  397. }
  398. if (<PropertyNewsList>[] is M) {
  399. return data.map<PropertyNewsList>((Map<String, dynamic> e) =>
  400. PropertyNewsList.fromJson(e)).toList() as M;
  401. }
  402. if (<PropertySaleRentEntity>[] is M) {
  403. return data.map<PropertySaleRentEntity>((Map<String, dynamic> e) =>
  404. PropertySaleRentEntity.fromJson(e)).toList() as M;
  405. }
  406. if (<PropertySaleRentList>[] is M) {
  407. return data.map<PropertySaleRentList>((Map<String, dynamic> e) =>
  408. PropertySaleRentList.fromJson(e)).toList() as M;
  409. }
  410. if (<ServerTime>[] is M) {
  411. return data.map<ServerTime>((Map<String, dynamic> e) =>
  412. ServerTime.fromJson(e)).toList() as M;
  413. }
  414. if (<UserMeEntity>[] is M) {
  415. return data.map<UserMeEntity>((Map<String, dynamic> e) =>
  416. UserMeEntity.fromJson(e)).toList() as M;
  417. }
  418. if (<UserMeHouseholds>[] is M) {
  419. return data.map<UserMeHouseholds>((Map<String, dynamic> e) =>
  420. UserMeHouseholds.fromJson(e)).toList() as M;
  421. }
  422. if (<UserMeEstates>[] is M) {
  423. return data.map<UserMeEstates>((Map<String, dynamic> e) =>
  424. UserMeEstates.fromJson(e)).toList() as M;
  425. }
  426. if (<UserMeEstatesAccounts>[] is M) {
  427. return data.map<UserMeEstatesAccounts>((Map<String, dynamic> e) =>
  428. UserMeEstatesAccounts.fromJson(e)).toList() as M;
  429. }
  430. if (<UserMeEstatesAccountsUnit>[] is M) {
  431. return data.map<UserMeEstatesAccountsUnit>((Map<String, dynamic> e) =>
  432. UserMeEstatesAccountsUnit.fromJson(e)).toList() as M;
  433. }
  434. if (<UserMeDefaultUnit>[] is M) {
  435. return data.map<UserMeDefaultUnit>((Map<String, dynamic> e) =>
  436. UserMeDefaultUnit.fromJson(e)).toList() as M;
  437. }
  438. if (<UserMeInformation>[] is M) {
  439. return data.map<UserMeInformation>((Map<String, dynamic> e) =>
  440. UserMeInformation.fromJson(e)).toList() as M;
  441. }
  442. if (<VisitorPageEntity>[] is M) {
  443. return data.map<VisitorPageEntity>((Map<String, dynamic> e) =>
  444. VisitorPageEntity.fromJson(e)).toList() as M;
  445. }
  446. if (<VisitorPageList>[] is M) {
  447. return data.map<VisitorPageList>((Map<String, dynamic> e) =>
  448. VisitorPageList.fromJson(e)).toList() as M;
  449. }
  450. debugPrint("$M not found");
  451. return null;
  452. }
  453. static M? fromJsonAsT<M>(dynamic json) {
  454. if (json is M) {
  455. return json;
  456. }
  457. if (json is List) {
  458. return _getListChildType<M>(
  459. json.map((dynamic e) => e as Map<String, dynamic>).toList());
  460. } else {
  461. return jsonConvert.convert<M>(json);
  462. }
  463. }
  464. }
  465. class JsonConvertClassCollection {
  466. Map<String, JsonConvertFunction> convertFuncMap = {
  467. (AuthLoginEntity).toString(): AuthLoginEntity.fromJson,
  468. (CaptchaImgEntity).toString(): CaptchaImgEntity.fromJson,
  469. (FacilityBookEntity).toString(): FacilityBookEntity.fromJson,
  470. (FacilityBookFacilityType).toString(): FacilityBookFacilityType.fromJson,
  471. (FacilityBookFacilities).toString(): FacilityBookFacilities.fromJson,
  472. (FacilityBookFacilitiesPeriods).toString(): FacilityBookFacilitiesPeriods
  473. .fromJson,
  474. (FacilityIndexEntity).toString(): FacilityIndexEntity.fromJson,
  475. (FacilityPageEntity).toString(): FacilityPageEntity.fromJson,
  476. (FacilityDetail).toString(): FacilityDetail.fromJson,
  477. (FacilityPageListBooking).toString(): FacilityPageListBooking.fromJson,
  478. (FacilityPageListFacility).toString(): FacilityPageListFacility.fromJson,
  479. (FacilityPageListFacilityType).toString(): FacilityPageListFacilityType
  480. .fromJson,
  481. (FacilityPageListTimePeriod).toString(): FacilityPageListTimePeriod
  482. .fromJson,
  483. (FacilityPageListAccount).toString(): FacilityPageListAccount.fromJson,
  484. (FeedbackDetailEntity).toString(): FeedbackDetailEntity.fromJson,
  485. (FeedbackDetailReplies).toString(): FeedbackDetailReplies.fromJson,
  486. (FeedbackListEntity).toString(): FeedbackListEntity.fromJson,
  487. (FeedbackItemEntity).toString(): FeedbackItemEntity.fromJson,
  488. (FormContentEntity).toString(): FormContentEntity.fromJson,
  489. (FormDetailEntity).toString(): FormDetailEntity.fromJson,
  490. (FormListEntity).toString(): FormListEntity.fromJson,
  491. (FormOptionEntity).toString(): FormOptionEntity.fromJson,
  492. (FormSubmittedEntity).toString(): FormSubmittedEntity.fromJson,
  493. (FormSubmittedEstateOnlineForm).toString(): FormSubmittedEstateOnlineForm
  494. .fromJson,
  495. (FormSubmittedPageEntity).toString(): FormSubmittedPageEntity.fromJson,
  496. (GarageSaleRentDetailEntity).toString(): GarageSaleRentDetailEntity
  497. .fromJson,
  498. (GarageSaleRentDetailAccount).toString(): GarageSaleRentDetailAccount
  499. .fromJson,
  500. (GarageSaleRentEntity).toString(): GarageSaleRentEntity.fromJson,
  501. (GarageSaleRentList).toString(): GarageSaleRentList.fromJson,
  502. (GarageSaleRentListAccount).toString(): GarageSaleRentListAccount.fromJson,
  503. (IdNameEntity).toString(): IdNameEntity.fromJson,
  504. (MyfollowingListEntity).toString(): MyfollowingListEntity.fromJson,
  505. (MypostsNewsfeedEntity).toString(): MypostsNewsfeedEntity.fromJson,
  506. (MypostsNewsfeedList).toString(): MypostsNewsfeedList.fromJson,
  507. (MypostsNewsfeedListAccount).toString(): MypostsNewsfeedListAccount
  508. .fromJson,
  509. (MypostsSaleRentEntity).toString(): MypostsSaleRentEntity.fromJson,
  510. (MypostsSaleRentList).toString(): MypostsSaleRentList.fromJson,
  511. (NewsfeedCommentPublishEntity).toString(): NewsfeedCommentPublishEntity
  512. .fromJson,
  513. (NewsfeedDetailEntity).toString(): NewsfeedDetailEntity.fromJson,
  514. (NewsfeedDetailAccount).toString(): NewsfeedDetailAccount.fromJson,
  515. (NewsfeedDetailComments).toString(): NewsfeedDetailComments.fromJson,
  516. (NewsfeedDetailCommentsAccount).toString(): NewsfeedDetailCommentsAccount
  517. .fromJson,
  518. (NewsfeedDetailCommentsToAccount)
  519. .toString(): NewsfeedDetailCommentsToAccount.fromJson,
  520. (NewsfeedFollowingEntity).toString(): NewsfeedFollowingEntity.fromJson,
  521. (NewsfeedFollowingList).toString(): NewsfeedFollowingList.fromJson,
  522. (NewsfeedFollowingListAccount).toString(): NewsfeedFollowingListAccount
  523. .fromJson,
  524. (NewsfeedForyouEntity).toString(): NewsfeedForyouEntity.fromJson,
  525. (NewsfeedForyouList).toString(): NewsfeedForyouList.fromJson,
  526. (NewsfeedForyouListAccount).toString(): NewsfeedForyouListAccount.fromJson,
  527. (NewsfeedNewsEntity).toString(): NewsfeedNewsEntity.fromJson,
  528. (NewsfeedNewsList).toString(): NewsfeedNewsList.fromJson,
  529. (NewsfeedNewsListAccount).toString(): NewsfeedNewsListAccount.fromJson,
  530. (NoticeBoardAnnounEntity).toString(): NoticeBoardAnnounEntity.fromJson,
  531. (NoticeBoardDocumentsEntity).toString(): NoticeBoardDocumentsEntity
  532. .fromJson,
  533. (NoticeBoardEventEntity).toString(): NoticeBoardEventEntity.fromJson,
  534. (PaymentPageEntity).toString(): PaymentPageEntity.fromJson,
  535. (PaymentPageList).toString(): PaymentPageList.fromJson,
  536. (PropertyNewsEntity).toString(): PropertyNewsEntity.fromJson,
  537. (PropertyNewsList).toString(): PropertyNewsList.fromJson,
  538. (PropertySaleRentEntity).toString(): PropertySaleRentEntity.fromJson,
  539. (PropertySaleRentList).toString(): PropertySaleRentList.fromJson,
  540. (ServerTime).toString(): ServerTime.fromJson,
  541. (UserMeEntity).toString(): UserMeEntity.fromJson,
  542. (UserMeHouseholds).toString(): UserMeHouseholds.fromJson,
  543. (UserMeEstates).toString(): UserMeEstates.fromJson,
  544. (UserMeEstatesAccounts).toString(): UserMeEstatesAccounts.fromJson,
  545. (UserMeEstatesAccountsUnit).toString(): UserMeEstatesAccountsUnit.fromJson,
  546. (UserMeDefaultUnit).toString(): UserMeDefaultUnit.fromJson,
  547. (UserMeInformation).toString(): UserMeInformation.fromJson,
  548. (VisitorPageEntity).toString(): VisitorPageEntity.fromJson,
  549. (VisitorPageList).toString(): VisitorPageList.fromJson,
  550. };
  551. bool containsKey(String type) {
  552. return convertFuncMap.containsKey(type);
  553. }
  554. JsonConvertFunction? operator [](String key) {
  555. return convertFuncMap[key];
  556. }
  557. }