flutter CachedNetworkImageProvider is not working - dart

CircleAvatar(
radius: 40.0,
backgroundColor: Colors.blue,
backgroundImage:
user.profileImageUrl.isEmpty
? AssetImage('assets/images/user.png')
: CachedNetworkImageProvider(user.profileImageUrl),
),
It says the 'CachedNetworkImageProvider.load' has fewer positional arguments than those of overridden method 'ImageProvider.load'.
and when I hit the flutter run, it is giving me the following
/C:/Users/Acer/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/cached_network_image-1.1.3/lib/src/cached_network_image_provider.dart:42:24: Error: The method 'CachedNetworkImageProvider.load' has fewer positional arguments than those of overridden method 'ImageProvider.load'.
ImageStreamCompleter load(CachedNetworkImageProvider key) {
^
/D:/Flutter/flutter/packages/flutter/lib/src/painting/image_provider.dart:403:24: Context: This is the overridden method ('load').
ImageStreamCompleter load(T key, DecoderCallback decode);
^

Make sure you are using rc version of cached_network_image.
Add this to your pubspec.yaml file cached_network_image: ^2.0.0-rc and run flutter pub get

use this one on you pubspec.yamal
cached_network_image: ^2.0.0-rc.1
or use this one
cached_network_image: ^2.0.0-rc
let me me know if it works.
Thanks.

If you are using VSCode and you have added the cached_network_image recently to pubspec.yaml then try to stop your app and run again then it will start work

Related

Flutter error no named parameter with the name 'scrollBehavior

I am getting this error when I run the app. What can be problem? I try update my pods. But still I am getting same error. I have an M1 Mac.
↳
objc[11258]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x1efc22c10) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1184b82b8). One of the two will be used. Which one is undefined.
objc[11258]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x1efc22c60) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1184b8308). One of the two will be used. Which one is undefined.
** BUILD FAILED **
Xcode's output:
↳
Pods-Runner-elvtjvosznfleaabicgoahubaeqy
../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.3.4/lib/get_navigation/src/root/get_material_app.dart:297:15: Error: No named parameter with the name 'scrollBehavior'.
scrollBehavior: scrollBehavior,
^^^^^^^^^^^^^^
../../../development/flutter/packages/flutter/lib/src/material/app.dart:217:9: Context: Found this candidate, but the arguments don't match.
const MaterialApp.router({
^^^^^^^^^^^^^^^^^^
../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.3.4/lib/get_navigation/src/root/get_material_app.dart:340:15: Error: No named parameter with the name 'scrollBehavior'.
scrollBehavior: scrollBehavior,
^^^^^^^^^^^^^^
../../../development/flutter/packages/flutter/lib/src/material/app.dart:167:9: Context: Found this candidate, but the arguments don't match.
const MaterialApp({
^^^^^^^^^^^
Command PhaseScriptExecution failed with a nonzero exit code
Pods-Runner-elvtjvosznfleaabicgoahubaeqy
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Analyzing workspace
note: Constructing build description
If you are using packages get or any packages that relating to get, basically the get latest version is not compatible with your project. Since I'm not directly using it, I go to pubspec.lock and change the version to 4.1.4 instead of the latest one 4.3.4.
if you are using fvm, check your "dart.flutterSdkPath" in setting.json, make sure the path is correct
// .vscode/settings.json
{
"dart.flutterSdkPath": ".fvm/flutter_sdk",
// Remove .fvm files from search
"search.exclude": {
"**/.fvm": true
},
// Remove from file watching
"files.watcherExclude": {
"**/.fvm": true
}
}
https://fvm.app/docs/getting_started/configuration
Just open ../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.3.4/lib/get_navigation/src/root/get_material_app.dart file, and then delete all parameters with the name 'scrollBehavior'.
This is how my problem was solved!
You are using get package latest version, but your flutter sdk version is old. so you need to update your flutter sdk. I resolved by updating flutter sdk to latest version. Basically getX is mapping GetMaterialApp.route() parameters with MaterialApp.route() parameters but sdk you have used is not latest one so MaterialApp.route() not contains the this.scrollBehavior parameter and getX is not able to map it.
You can resolve issue by two way:
1st You need to install latest flutter sdk or
2nd You need to downgrade getX package till it is compatible with your current flutter sdk.
You just have to delete the scrollBehavior feature completely so that you search for the feature and delete it Via:
C:/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.3.8/lib/get_navigation/src/root/get_material_app.dart

Non-nullable by default: how to enable the experiment?

I just tried the following in DartPad:
void main() {
int? x;
}
and get the following error:
Error compiling to JavaScript:
main.dart:2:6:
Error: This requires the 'non-nullable' experiment to be enabled.
How do I enable that experiment? I am using the Flutter SDK.
Does the experiment support null-safety static analysis already?
Add the following line to the analysis_options.yaml
analyzer:
enable-experiment:
- non-nullable
Enable the non-nullable experiment with three steps:
Add dart-sdk version into pubspec.yaml
environment:
sdk: '>=2.8.0-dev.0 <2.8.0'
Add enable non-nullable experiment into analysis_options.yaml
analyzer:
enable-experiment:
- non-nullable
Run your Dart code:
dart --enable-experiment=non-nullable ./bin/hello_dart.dart
You enable the experiment by passing the flag --enable-experiment=non-nullable to the compiler or analyzer.
It is not a complete feature yet, so there are no promises about what it will do. Feel free to experiment, but don't use the flag for anything serious.
For me, removing pubspec.lock and rerun fix the issue. I was importing the project from Windows to Mac.
Manually removing pubspec.lock and running flutter pub get resolved the problem. In my case it was due to regression.

Why is source info missing in flutter error

I got the following error in the console while running my app:
flutter: type '() => Null' is not a subtype of type '(dynamic) => FutureOr<dynamic>' of 'f'
Unfortunately it doesn't tell me which code actually caused this error? Why is flutter missing some more information in the output?
Visual Studio Code 1.28.2
Flutter 0.9.4
Dart VM version: 2.0.0
Since you didn't put any code, so as far as I can tell, you are using () which is returning Null, and you were supposed to use (dynamic value) returning Future in your method declaration somewhere in your code.

Why is my Flutter package suddenly warning me that it doesn't depend on its example app?

I'm doing flutter packages pub publish --dry-run to publish an update to my package, GroovinMaterialIcons, and I'm getting warnings that it doesn't depend on the example app:
Suggestions:
* line 3, column 1 of example\lib\main.dart: This package doesn't depend on groovin_material_icons_testapp.
import 'package:groovin_material_icons_testapp/icon_map.dart';
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* line 4, column 1 of example\lib\main.dart: This package doesn't depend on groovin_material_icons_testapp.
import 'package:groovin_material_icons_testapp/search.dart';
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* line 3, column 1 of example\lib\search.dart: This package doesn't depend on groovin_material_icons_testapp.
import 'package:groovin_material_icons_testapp/icon_map.dart';
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This has never happened to me before. Why would the package need to depend on the example?
I was able to solve this by specifying relative path instead of using package:* syntax. E.g. This one gave me warning
import 'package:example/main.dart
which was fixed when I replaced it with
import '../lib/main.dart'
I know that's not the recommended way but the warning went away after this.
You've probably run the dart file with the dart icon instead of the Flutter icon try to run with the Flutter icon.

Compiled AngularDart fails with error in dynamic_injector

I have been trying to make AngularDart work but I always get exceptions for undefined objects.
#MirrorsUsed(
targets: const [
'angular.core',
'angular.core.dom',
'angular.core.parser',
'angular.routing',
'angular.core.zone',
'di.di',
'di.dynamic_injector',
NodeTreeSanitizer,
DynamicParser,
DynamicParserBackend,
Injector
],
metaTargets: const [
NgInjectableService,
NgComponent,
NgDirective,
NgController,
NgFilter,
NgAttr,
NgOneWay,
NgOneWayOneTime,
NgTwoWay,
NgCallback,
NgZone
],
override: '*'
)
import 'dart:mirrors';
And compiled javascript showing error:
Uncaught TypeError: Cannot call method 'get$parameters' of undefined dynamic_injector.dart:42
DynamicInjector.newInstanceOf$4 dynamic_injector.dart:42
When I'm removing MirrorsUsed2 there is no errors, but compiled file is large.
Adding these helped for me
'angular.filter',
'angular.perf',
'perf_api',
and instead of angular.core.parser
'angular.core.parser.dynamic_parser'
'angular.core.parser.lexer'
I also added all my own libraries.
See also https://code.google.com/p/dart/issues/detail?id=14686
Recently, I found Dart-AngularJS when compiled not to run, even the simplest example. I reinstalled my dart sdk to the latest stable version and the errors disappeared. Could you see if this works? Please see related issue on github project.

Resources