草庐IT

any_cast

全部标签

android - flutter 错误 : type 'int' is not a subtype of type 'String' in type cast

我正在尝试使用Flutter应用从RESTAPI获取数据。我正在以json_serializable方式构建模型类。下面是我的代码。ma​​in.dartimport'package:flutter/material.dart';import'dart:convert'asconvert;import'package:http/http.dart'ashttp;import'./category.dart';voidmain(){runApp(MyApp());}classMyAppextendsStatefulWidget{@overrideStatecreateState(){//

dart - Flutter:_InternalLinkedHashMap 没有实例 > 方法 'cast'

Sthg让我发疯,我尝试在卡片中显示json产品,但它不起作用。到目前为止,这是我尝试过的:产品类别:classProduct{finalStringid;Product({this.id});factoryProduct.fromJson(Mapjson){returnnewProduct(id:json['id']asString);}}JSON:FutureloadProducts()async{finalresponse=awaithttp.get('https://api.stripe.com/v1/products');returnresponse.body;}json具有

Git 错误,命令 git fetch Fatal : not a git repository (or any of the parent directories): . git in visual studio code

我必须从Flutterforweb开始,下载DARTsdk以及Visualstudio代码,我已经安装了Flutter插件是VS代码,但它显示错误Git错误,命令gitfetch致命:不是git存储库(或任何父目录):.git进程结束,退出代码为69我已经在Intellij中设置了git路径并在Windows中设置了桌面环境但是也有(Intellij),同样的错误即将到来Ps:我是新手,请详细建议我解决方案 最佳答案 您的工作副本似乎不是克隆的。通过以下命令克隆SDK:gitclonehttps://github.com/dart-

android - "Is there a way to set any object as dynamic as according devices resolution in flutter?"

我正在创建一个设计,其中有一个中心圆容器和中心圆边缘的5个圆容器,但是当相同的代码在不同的设备上运行时,它们会改变它的位置,最后一个图像链接也显示了设计我建立。“这是我创建的设计代码。”import'package:flutter/material.dart';import'package:flutter_app/circle/firstCircle.dart';import'package:flutter_app/circle/secondCircle.dart';import'package:flutter_app/circle/thirdCircle.dart';import'p

flutter - 如何修复 : "The method ' cast' was called on null"during transaction. 更新

我在尝试对我的Firestore集合执行事务更新时收到NoSuchMethodError。Receiver:nullTriedcalling:cast()#0Object.noSuchMethod(dart:core/runtime/libobject_patch.dart:50:5)#1MethodChannel.invokeMapMethod(package:flutter/src/services/platform_channel.dart:331:19)#2Firestore.runTransaction(file:///Users/wready/dev_tools/flutt

flutter - Dart 类 'String' 没有实例方法 'cast'

我写了一个dart方法,它采用泛型类型T,然后尝试将动态类型转换为T。同样的错误。)在这个特定场景中,我将一个字符串作为T传递。下面一行抛出错误Tresult=value.cast();完整代码如下...classJsonObject{finalMap_map;JsonObject(this._map);TgetValue(Stringkey){dynamicvalue=_map[key];if(value==null)thrownewJsonParseException._("JsonMap:cannotfindvaluewithkey="+key);Tresult=value.ca

android - Flutter: InternalLinkedHashMap<String, dynamic >' has no instance method ' cast' with matching arguments

我无法从之前的问题中找到解决方案,我已将json字符串转换为map下面是我的API调用方法。FuturefetchEvent()async{//hereichangeFuturetypeStringurl='http://xxxxxxxxxxxx.tk/api/userapp/event/lists';varheaders=newMap();//hereidefinedMaptypeheaders['Auth-Key']='OCDOC@2018';headers['End-Client']='OCDOC';varbody=newMap();//hereidefinedMaptypehe

json - 错误 : Type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List<dynamic>' in type cast

我是Flutter的新手,我尝试从“10.0.2.2:8000/api/membres”上的api获取数据,但出现错误,如typeListdynamicisnotasubtypeoftype'List.我正在关注flutter的示例:https://flutter.dev/docs/cookbook/networking/fetch-data#complete-example请帮助我遵循有用的教程并告诉我如何修复此代码。我的主页.dartimport'package:flutter/material.dart';import'dart:async';import'package:htt

flutter - 当我尝试登录或注册时,出现错误 "Error type ' AuthResult' is not a subtype of type 'FirebaseUser' in type cast"

我正在为我的大学项目制作一个flutter应用程序,我在其中添加了一个登录和注册页面并通过Firebase对其进行了身份验证,当我单击登录时调试控制台显示“错误类型‘AuthResult’是不是类型转换中“FirebaseUser”类型的子类型”,当我在此错误后重新加载应用程序时,它成功登录。在此更新后将firebase_auth包更新到0.12.0之前,一切都运行良好,方法“signInWithEmailAndPassword()”和“createUserWithEmailAndPassword()”抛出错误“A“AuthResult”类型的值不能分配给“FirebaseUser”类

widget - 小部件库抛出的异常 '!children.any((Widget child) => child == null)' : is not true

您好,我在运行应用程序时遇到以下错误问题的可能原因是什么?══╡EXCEPTIONCAUGHTBYWIDGETSLIBRARY╞═══════════════════════════════════════════════════════════ThefollowingassertionwasthrownbuildingHome(dirty,state:_HomeState#f7a67):'package:flutter/src/widgets/framework.dart':Failedassertion:line1639:'!children.any((Widgetchild)=>