草庐IT

Viewport-units

全部标签

ios - XCode 获取 "target specifies product type ' com.apple.product-type.bundle.unit-test',但 'iphoneos' 平台没有此类产品类型”

在XCode中运行我的项目时,我的测试给出了这个错误:targetspecifiesproducttype'com.apple.product-type.bundle.unit-test',butthere'snosuchproducttypeforthe'iphoneos'platform它发生在几次XCode更新之后。有谁知道如何解决这个问题? 最佳答案 看起来Xcode6将ocunit测试包的产品标识符从com.apple.product-type.bundle更改为com.apple.product-type.bundle.

dart - flutter 中的嵌套 ListViews 给出水平视口(viewport)错误

我试图制作像Netflix这样的图库UI,在垂直ListView中使用水平ListView,但我一直收到视口(viewport)错误并且无法解决。完整代码。classMyAppextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext){returnMaterialApp(title:'LiveTree',home:Scaffold(appBar:AppBar(title:Text("Netflux"),),body:HomePage(),),);}}classHomePageextendsStatefulWidget

unit-testing - 使用相同的参数链接多个调用以返回不同的结果

我正在编写一个包含大量单元测试的Flutter应用程序。我正在使用Mockito模拟我的类(class)。来自Java(Android)世界,我可以在其中使用Mockito链接调用以在后续调用中返回不同的值。我希望这能奏效。import'package:test/test.dart';import'package:mockito/mockito.dart';voidmain(){test("somestringtest",(){StringProviderstrProvider=MockStringProvider();when(strProvider.randomStr()).the

android - Flutter:为什么我会收到 "Vertical viewport was given unbounded height"错误?

我是flutter的新手,下面是我的代码import'package:flutter/material.dart';classHomepageextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext){//TODO:implementbuildreturnScaffold(appBar:AppBar(title:Text("ChocoFactory"),),body:HomepageUI(),);}}classHomepageUIextendsStatefulWidget{@overrideStatecreateSt

unit-testing - 在 Dart 中测试包含异步函数的函数

我想测试一个调用其他异步函数的函数,但我不知道如何编写它。函数会像这样:function(Xx,Yy){x.doSomethingAsync().then((result){if(result!=null){y.doSomething();}}}我想同时模拟X和Y,运行X,然后验证是否调用了y.doSomething()。但是我不知道如何等待x.doSomethingAsync()完成。我正在考虑在断言之前做一些等待,但它似乎不是可靠的解决方案。有什么帮助吗?:) 最佳答案 您可以在dart中使用async/await。这会大大简化

unit-testing - flutter 单元测试。运行测试时出错

我在运行flutter单元测试时遇到以下错误。00:05+1:.../home/kazekage/Projects/flutter/flutter_woocommerce/test/model/util/Refund_test.dartShell:[ERROR:flutter/shell/common/shell.cc(184)]DartError:error:importofdart:mirrorswith--enable-mirrors=falseShell:[ERROR:flutter/shell/common/engine.cc(175)]Couldnotpreparetoru

unit-testing - flutter :测试

我正在尝试测试这个功能UserApicreateUserApi(Stringurl,Stringusername,Stringpassword){UserApiuserApi=newUserApi(base:route(url),serializers:repo);userApi.base.basicAuth('$username','$password');returnuserApi;}基本上,测试是将此函数的结果与它的“手动组合”进行比较,期望得到相同的结果。但事实并非如此:Stringusername="asd";Stringpassword="asd";UserApiuserA

unit-testing - flutter :单元测试

我正在尝试测试这个功能:setToday(Mapfilters){if(filters['today']==false){filters['yesterday']=false;filters['lastWeek']=false;filters['lastMonth']=false;filters['customRange']=false;filters['today']=true;}elsefilters['today']=false;}这是测试:test("",(){Mapfilters={"today":false,"yesterday":false,"lastWeek":fals

android - 在 Flutter 中获取 'Horizontal viewport was given unbounded height' 错误

我正在尝试将带有水平GridView子级的ExpansionTile放置在容器中。请参阅下面的代码。我收到错误消息“水平视口(viewport)的高度没有限制。”我不想明确指定ExpansionTile或GridView的高度,而是根据Expanded小部件和GridView的子项计算它。我尝试按照建议在GridView中设置“shrinkWrap:true”here没有成功。我还尝试根据thisanswer在Flexible中包装GridView这给了我错误“RenderFlexchildrenhavenon-zeroflexbutincomingheightconstraintsa

unit-testing - Flutter 中的单元测试通过 BuildContext

我在Dart类中有一个方法,它接受BuildContext参数,如下所示:classMyClass{myMethodName(BuildContextcontext,...){...doSomethingreturnsomething;}}我想测试该方法是否按预期工作:import'package:flutter/material.dart';import'package:flutter_test/flutter_test.dart';import'package:mockito/mockito.dart';...voidmain(){MyClasssut;setUp((){sut=M