草庐IT

try-catch-else

全部标签

ios - 接收器 :null error when trying to save form using globalKey

我正在关注这个https://medium.com/@c_innovative/simple-firebase-login-flow-in-flutter-6f44c2b5c58a教程,我在登录工作时遇到了一些麻烦。我已经将我的应用程序连接到firebase并在firebase控制台上启用了电子邮件和密码身份验证!我已经尝试将关键参数输入到TextFormfield中,但到目前为止我无法这样做。classLoginPageextendsStatefulWidget{@overrideStatecreateState(){return_LoginPageState();}}class_L

flutter - 如何使用 yield 返回错误(from catch error)

我的服务_session尝试登录并在成功时返回true或在失败时返回来自catchError的错误消息。我想生成此消息,因此从catchblock调用yield,但这是不可能的,所以我这样做了:这会像我预期的那样工作还是有其他方法可以做到这一点?@overrideStreammapEventToState(DgEventevent)async*{if(eventisLoginDgEvent){yieldLoadingState();StringerrMessage;boolhasLogged=await_session.login(event.userCredential.login,

flutter - 在 null 上调用了方法 'setState'。 E/flutter (13218) : Receiver: null E/flutter (13218): Tried calling: setState(Closure: () => Null)

我的目标是使用Firebase在Flutter中构建注册。但是,当我按下包含注册功能的按钮时,没有任何反应,我收到此错误:E/flutter(13218):[ERROR:flutter/lib/ui/ui_dart_state.cc(148)]UnhandledException:NoSuchMethodError:Themethod'setState'wascalledonnull.E/flutter(13218):Receiver:nullE/flutter(13218):Triedcalling:setState(Closure:()=>Null)与firebase的集成正在运行

dart - 如何在 dart 中使用传递的数据编写 if else 语句(flutter app)

我正在尝试在我的flutter应用程序上用dart编写一个if/else语句。我试图查看传递的id是否等于3以返回整页代码,否则将是不同的页面。例如……Widgetbuild(BuildContextcontext){finalTextEditingControllercontroller=newTextEditingController();Stringresult="";If(${widget.id}=3){returnScaffold(allofscaffold1)};else{returnScaffold(allofscaffold2)};我是否需要将${widget.id}设

button - 如何在按钮中使用 if else 条件 - flutter

我试图在满足特定条件后用户按下此按钮后显示一个警告对话框。如果文本为空,它将弹出一个对话框,但是使用我在下面尝试的方法,即使按下按钮后文本不为空,它仍然会弹出对话框。RaisedButton(onPressed:priceController.text==""?()=>showDialog(context:context,builder:(BuildContextcontext){returnAlertDialog(title:Text("Enteraprice"),);}):()=>apiRequest(url,{'price':priceController.text,'user_

http - Flutter 内置值反序列化'由于 : Tried to build class but nested builder for field threw: Tried to construct class with null field 而失败

我正在为我的PODO类使用构建值以下是我的代码librarymobile_login_model;import'package:built_value/built_value.dart';import'package:built_value/serializer.dart';part'mobile_login_model.g.dart';abstractclassMobileLoginModelimplementsBuilt{MobileLoginModel._();factoryMobileLoginModel([updates(MobileLoginModelBuilderb)])

if-statement - dart 替代很多 if else if

我想用另一个字符串替换Dart中的URL字符串。示例:if(url=="http://www.example.com/1"){home="example";}elseif(url=="http://www.example.com/2"){home="anotherexample";}有没有更好的方法,代码更少而且速度更快?我必须这样做60多次.. 最佳答案 如果你想要更少的代码,你可以这样做:homes={"http://www.example.com/1":"example","http://www.example.com/2":

database - SQLite 中的 "if, then, else"

在不使用自定义函数的情况下,是否可以在SQLite中执行以下操作。我有两个表,它们通过公共(public)ID号链接。在第二个表中,有两个变量。我想做的是能够返回一个结果列表,包括:行ID,如果这两个变量(可能有两个以上)的所有实例都为NULL,则为NULL,如果它们都是0,则为1如果一个或多个为1,则为2。我现在的情况如下:SELECTa.aid,(SELECTcount(*)fromW3S19bWHEREa.aid=b.aid)asnum,(SELECTcount(*)FROMW3S19cWHEREa.aid=c.aidANDH110ISNULLANDH112ISNULL)asnu

android - 非法状态异常 : Invalid tables when trying to query database with ContentProvider

尝试使用如下所示的自定义ContentProvider查询我的数据库时出现以下错误。我已确认该表存在且名称正确,但它仍然无法正常工作。我能够让它与原始查询一起工作,但我希望我们使用ContentProvider模式进行练习。谢谢,如果您需要更多信息,请告诉我。SQLiteOpenHelperpublicclassDatabaseHelperextendsSQLiteOpenHelper{privatestaticfinalStringTAG=DatabaseHelper.class.getSimpleName();privatestaticfinalStringDB_PATH="/da

ruby-on-rails - 参数错误 : odd number of arguments for Hash when trying to connect to redis

我正在尝试通过遵循thistutorial来让Rails连接到Redis.但是当我尝试$redis=Redis.new(:host=>'localhost',:port=>6379)或者甚至只是Redis.new。我也尝试了新的表示法(host:'localhost',port:6379)。Redis工作(通过redis-cli通过的ping-PONG测试)。ArgumentError:oddnumberofargumentsforHashfrom/var/lib/gems/1.9.1/gems/redis-2.1.1/lib/redis.rb:65:in`[]'from/var/li