entity_factory.dart 524 B

1234567891011121314151617181920
  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. break;
  12. case "SubmitModel":
  13. return SubmitModel.fromJson(json) as T;
  14. break;
  15. default:
  16. return null;
  17. }
  18. }
  19. }