// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. // @dart=2.9 mixin TestMixin { Future test(Future fetch) async { final response = await fetch; T result; if (response is Response) { result = response.data; } else if (response is PagingResponse) { result = response.data.data as T; } else if (response is T) { result = response; } else { throw Exception('Invalid response type'); } return result; } } class PagingResponse { final PagingResponseData data; PagingResponse(this.data); } class PagingResponseData { final List data; PagingResponseData(this.data); } class Response { final T data; Response(this.data); } class Class1 with TestMixin, String> { _test() { final response = Response('test'); test(Future.value(response)); } } class Class2 with TestMixin, String> { _test() { final response = PagingResponse(PagingResponseData(['test'])); test(Future.value(response)); } } main() {}