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.
Related
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
Two of my apps broke after what I assume was a change to Xcode (10.1 - 10B61) or iOS API. Both use Receigen in Obj-C mode and for some reason no longer recognize UIDevice.
Here are the imports auto-generated by Receigen:
What change to Xcode or the API am I missing?
Turns out Receigen changed a few things. Previously it didn't import UIKit/UIKit.h, but it did import Foundation/Foundation.h
Also previously, the method declaration and variable types had more underscores:
inline static void FastReceiptCheck_CheckInAppPurchases(NSArray *_inapp_identifiers, FastReceiptCheck_InAppValidateBlock _inapp_block, FastReceiptCheck_CallBackBlock _callback_block)
vs
inline static void FastReceiptCheck_CheckInAppPurchases(NSArray *_inapp_identifiers, FastReceiptCheckInAppValidateBlock _inapp_block, FastReceiptCheckCallBackBlock _callback_block)
I ended up inserting this into my Build Script which adds the UIKit import:
echo '#import <UIKit/UIKit.h>' | cat - "$FILENAME" > temp && mv temp "$FILENAME"
And changing my method calls
Thanks for the help!
Receigen released version 4.0.4 which adds the UIKit/UIKit.h import. Just make sure you keep in mind the variable type changes.
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.
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.
I am using analyzer_experimental to parse a Dart file into a CompilationUnit:
import 'package:analyzer_experimental/analyzer.dart';
var unit;
try {
unit = parseDartFile(path);
} on AnalyzerErrorGroup catch(e){
print(e);
}
The above code will catch any parsing errors encountered.
I am also interested in seeing any warnings associated with the file (e.g. 'Undefined name "foo"'). I know that the experimental_analyzer library has the capability to generate these warnings when running from the command line but it does not seem to be possible to get the warnings programmatically, without directly referencing classes in the src folder (which seems like a bad idea).
Is there any way to achieve this?
It's likely this package was very incomplete at the time.
There's now an analyzer package on pub and also a (work-in-progress) STDIN/STDOUT Analyzer Service aimed to help making tooling support easier for IDE extension authors.