12345678910111213 |
- import 'package:flutter_provider_demo/model/base_model.dart';
- import 'package:flutter_provider_demo/model/user_model.dart';
- class EntityFactory {
- // 把api获得的 json 中的 data 字段于Model 绑定
- static T generateOBJ<T>(dynamic json) {
- if (T.toString() == "UserEntity") {
- return UserEntity.fromJson(json) as T;
- } else {
- return BaseEntity(code: -1, msg: "No such Model") as T;
- }
- }
- }
|