简体   繁体   中英

Flutter / Dart - Limit a generic to a class that implements X or Y interface and … use the methods inherited from the abstract class

I understand that the generic can be limited to inherit, extend, implement X or Y class, whether abstract or not.

Future<void> getInfo<T extends BaseModel>({required String extraUri})

But how can I use the methods that that interface gives to its children? Something like:

T.inheritMethodCall();

Pass object to this function and call method:

  Future<void> getInfo<T extends BaseModel>(T t, {required String extraUri}) {
    t.inheritMethodCall();
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM