好的,这里是我的问题的解决方案:
提取/检索数据
final Either<ServerException, TokenModel> result = await repository.getToken(...);result.fold( (exception) => DoWhatYouWantWithException, (tokenModel) => DoWhatYouWantWithModel);//Other way to 'extract' the dataif (result.isRight()) { final TokenModel tokenModel = result.getOrElse(null);}测试异常
//You can extract it from below, or test it directly with the typeexpect(() => result, throwsA(isInstanceOf<ServerException>()));



