天道酬勤,学无止境

dart-2

The argument type 'Object' can't be assigned to the parameter type 'ImageProvider<Object>'

I just updated to Dart2 and Flutter sdk: '>=2.12.0 <3.0.0' and now this if statement breaks: decoration: new BoxDecoration( shape: BoxShape.circle, color: Colors.blueAccent, border: Border.all( color: Colors.blueAccent, width: 20.0, style: BorderStyle.solid), image: new DecorationImage( fit: BoxFit.cover, image: myMarkerThumb != 'noImage' ? NetworkImage(myMarkerThumb) : AssetImage('assets/images/noImageAvailable.png'), ), ), The argument type 'Object' can't be assigned to the parameter type 'ImageProvider'. ), I'm just starting with flutter and have no idea where to look else.

2022-06-07 13:30:11    分类:问答    flutter   if-statement   typeerror   dart-2

How to typedef a generic function?

I have a generic static method that looks like this: static build<K>() { return (GenericClass<K> param) => MyClass<K>(param); } So far I have tried: typedef F = MyClass<K> Function(GenericClass<K> param); but it says that: The return type '(GenericClass<K>) → MyClass<K>' isn't a '(GenericClass<dynamic>) → MyClass<dynamic>', as defined by the method 'build'. and typedef F = SimpleViewModel<K> Function<k>(Store<K> param); Which says that: The return type '(GenericClass<K>) → MyClass<K>' isn't a '<K>(GenericClass<K>) → MyClass<K>', as defined by the method 'build'. MyClass looks like this: class

2022-05-02 19:03:52    分类:问答    dart   dart-2

Remove Index wise CustomWidget from List<Widget> in Flutter

I have initially empty list of Widget in Column. Now on Other widget click I am adding new Custom Widget in _contactItems Column( children: _contactItems, ) List<Widget> _contactItems = new List<CustomWidget>(); _contactItems.add(newCustomWidget(value)); Now Suppose I have 6 Records (6 Custom Widgets in Column). I am trying to remove index wise records (Example. I am removing 3rd record then 1st record. Column Widgets (dynamic widgets) should be updated as _contactItems updating in setState()) Now on CustomWidget click I am removing that particular CustomWidget from Column. setState(() {

2022-03-21 06:15:19    分类:问答    dart   flutter   flutter-sliver   dart-2

is it possible to lazily use JS libs with Dart?

I am using chartjs (with the dart interface https://pub.dartlang.org/packages/chartjs) and trying to make it deferred by injecting a <script src="chartjs.js"></script> into the head section and awaiting it's load event to then use the lib. I am getting this exception: Cannot read property 'Chart' of undefined. It does not happen when the script is within the head of the html before dart. So, is it possible to load a JS lib after Dart loaded?

2022-03-16 01:16:23    分类:问答    dart   dart-2

NoSuchMethodError: 方法 'ancestorStateOfType' 在 null 上被调用(NoSuchMethodError: The method 'ancestorStateOfType' was called on null)

问题 我正在做这样的屏幕更改 iam 列表流,当它发出时我更改屏幕 @override void initState() { super.initState(); appBloc.error.listen((data) { _scaffoldKey.currentState.showSnackBar(new SnackBar(content: new Text(data))); }); appBloc.success.listen((_) => goToDashBoardScreen(context)); } 和 doToDashBoardScreen 看起来像这样 Navigator.pushReplacement(context, new SlideRightRoute(widget: DashBoardScreen())); 但我收到这样的错误,但我更改了页面。 22:05:02.446 3 info flutter.tools E/flutter (13216): NoSuchMethodError: The method 'ancestorStateOfType' was called on null. 22:05:02.446 4 info flutter.tools E/flutter (13216): Receiver: null 22:05:02.446 5

2021-12-23 07:53:19    分类:技术分享    dart   flutter   dart-2

NoSuchMethodError: The method 'ancestorStateOfType' was called on null

i am doing screen change like this iam listing for stream and when it emit i change the screen @override void initState() { super.initState(); appBloc.error.listen((data) { _scaffoldKey.currentState.showSnackBar(new SnackBar(content: new Text(data))); }); appBloc.success.listen((_) => goToDashBoardScreen(context)); } and doToDashBoardScreen look like this Navigator.pushReplacement(context, new SlideRightRoute(widget: DashBoardScreen())); but i am getting error like this but i change the page. 22:05:02.446 3 info flutter.tools E/flutter (13216): NoSuchMethodError: The method

2021-12-13 18:28:13    分类:问答    dart   flutter   dart-2

如何在 dart/flutter 中声明 64 位无符号整数?(How do I declare 64bit unsigned int in dart/flutter?)

问题 对于应用程序,我需要一个 64 位的 unsigned int。 查看 dart 文档,我没有看到如何确切地声明一个。 谁能告诉我这是怎么做到的? 我将在按位运算中使用这个“64bit unsigned int”。 回答1 Dart 没有原生的无符号 64 位整数。 对于许多操作,您可以只使用int有符号64 位整数,并将其解释为无符号。 这是相同的位。 但是,这不适用于除法。 (如果是用于网络,则int是一个 JavaScript 数字,您需要做一些完全不同的事情)。 最简单的通用方法是使用BigInt并在对其执行任何操作后使用toUnsigned(64) 。 回答2 只需使用 fixnum 您可以使用Int64()轻松创建一个int64

2021-12-03 18:30:17    分类:技术分享    dart   int   flutter   unsigned   dart-2

How do I declare 64bit unsigned int in dart/flutter?

For an app, I need a 64bit unsigned int. Looking at dart documentation I did not see how to exactly go about declaring one. Can anyone tell me how this is done? I will use this "64bit unsigned int" in bitwise operation.

2021-11-23 11:44:07    分类:问答    dart   int   flutter   unsigned   dart-2

Only static members can be accessed in initializer. Dart2.0

I am using banklist in stateful widget. passing list to pageState using List<Bank> bankLists = this.widget.bankLists; Que 1. Why I am getting error at gradientcolor: gradientBankCard("FFB74093","FFB74093")) that only static members can be accessed in initializer? Que 2. How to pass const Data to gradientBankCard method . for Example I want to pass Color.fromRGBO(220, 132, 58, 1.0) to Arguments that gives error to. I List<Bank> bankLists = [ Bank( id: "1", name: "B1", loanAmount: "₹ 250000", emi: "₹11732", intrest_rate: "11.69 % ", processing_fee: "1.29 %", tenure: "2 years", gradientcolor

2021-06-21 09:05:21    分类:问答    dart   flutter   dart-2

Upload & fetch media files from AWS S3 in Flutter

My flutter app is using firebase as a backend but I need to store media files (photos & videos) in my s3 bucket. The mission is to upload the media retrieved from the image picker into s3 & get back the url, which can then be stored as a string in my firebase database. The problem is a scarcity of aws libraries or api for dart 2. I found 3 in pub, but 2 of them were incompatible with dart 2 & 1 was under development. Has anyone implemented this in flutter using dart 2? Any suggestions are welcome. Thank you. The packages I found were (pub.dartlang.org) : aws_client, aws_interop, amazon_s3

2021-06-14 20:35:02    分类:问答    amazon-web-services   amazon-s3   dart   flutter   dart-2