entity_factory.dart 495 B

123456789101112131415161718
  1. import 'package:flutter_tracker/model/submit_model.dart';
  2. import 'package:flutter_tracker/model/user_model.dart';
  3. /// Description:
  4. /// Time : 2021年12月03日 Friday
  5. /// Author : liuyuqi.gov@msncn
  6. class EntityFactory {
  7. static T? geneerateObj<T>(dynamic json) {
  8. switch (T.toString()) {
  9. case "UserModel":
  10. return UserModel.fromJson(json) as T;
  11. case "SubmitModel":
  12. return SubmitModel.fromJson(json) as T;
  13. default:
  14. return null;
  15. }
  16. }
  17. }