when build my project in flutter , I get the following error - dart

The Error showing like this...i couldn't understand the actual problem.
Invalid depfile: C:\Users\ajmal\OneDrive\Desktop\Flutter projects\Firebase project -week16\chatapp\.dart_tool\flutter_build\2bc53116d09bd81691d0c1eb73277574\kernel_snapshot.d
: Error: Not found: 'dart:html'
package:get/…/src/sockets_html.dart:5
import 'dart:html';
^
Error: Type 'WebSocket' not found.
package:get/…/src/sockets_html.dart:12
WebSocket? socket;
^^^^^^^^^
: Error: 'WebSocket' isn't a type.
package:get/…/src/sockets_html.dart:12
WebSocket? socket;
^^^^^^^^^
: Error: The method 'WebSocket' isn't defined for the class 'BaseWebSocket'.
package:get/…/src/sockets_html.dart:38
- 'BaseWebSocket' is from 'package:get/get_connect/sockets/src/sockets_html.dart' ('../../../../Documents/flutter_windows_2.10.0-stable/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.6.5/lib/get_connect/sockets/src/sockets_html.dart').
package:get/…/src/sockets_html.dart:1
Try correcting the name to the name of an existing method, or defining a method named 'WebSocket'.
socket = WebSocket(url);
^^^^^^^^^
: Error: The getter 'WebSocket' isn't defined for the class 'BaseWebSocket'.
package:get/…/src/sockets_html.dart:105
- 'BaseWebSocket' is from 'package:get/get_connect/sockets/src/sockets_html.dart' ('../../../../Documents/flutter_windows_2.10.0-stable/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.6.5/lib/get_connect/sockets/src/sockets_html.dart').
package:get/…/src/sockets_html.dart:1
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WebSocket'.
if (socket != null && socket!.readyState == WebSocket.OPEN) {
^^^^^^^^^
Unhandled exception:
FileSystemException(uri=org-dartlang-untranslatable-uri:dart%3Ahtml; message=StandardFileSystem only supports file:* and data:* URIs)
#0 StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file_system.dart:34:7)
#1 asFileUri (package:vm/kernel_front_end.dart:652:37)
#2 writeDepfile (package:vm/kernel_front_end.dart:792:21)
<asynchronous suspension>
#3 FrontendCompiler.compile (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/frontend_server/lib/frontend_server.dart:615:9)
<asynchronous suspension>
#4 starter (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/frontend_server/lib/frontend_server.dart:1433:12)
<asynchronous suspension>
5 main (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/frontend_server/bin/frontend_server_starter.dart:10:14)
<asynchronous suspension>
4
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\ajmal\OneDrive\Documents\flutter_windows_2.10.0-stable\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1156
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\Users\ajmal\OneDrive\Documents\flutter_windows_2.10.0-stable\flutter\bin\flutter.bat'' finished with non-zero exit value 1
Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

It looks like you are trying to import dart:html (direct import or transitive import from a library) but it is not supported.
If you are not building a web application, you cannot import dart:html as it is only available on web (https://api.dart.dev/stable/2.17.6/dart-html/dart-html-library.html).
If it is from your code, you can give universal_html a try as it is supported on io platforms. But some features might not be available and you might hit a UnsuportedError at runtime. But at least it will build.

Related

Flutter #dart=2.9 import 'dart:math'; Error, dart code won't run in emulator?

Question: How can I solve the flutter error as shown below & why does this happen?
What I can't understand out of this error, is
that I can't comprehend what #dart=2.9 is. I hadn't previously run or coded the file in a while. So, when I came back to work on this flutter file project, it threw me this error?
I tried updating flutter on the command prompt. Everything it's fine according to the flutter doctor. The only missing piece is just visual studio, but I use visual studio Code. So, I am assuming that's not the problem. If not, then what could it be? I am deeply thinking about this long error, that can't get to comprehend.
Much appreciation in advance any sort of help will be gratefully appreciated
Error: Flutter run -
When I run flutter run it always displays the errors below.
Invalid depfile: C:\Users\14706\Desktop\Test-SETUP\New folder\This_Folder_Contains_Map_Tests_From_Top_To_Bottom_Atempts\Challenge_1\flutter_login_auth\.dart_tool\flutter_build\6494cc4bb6a11f1a583790c79662ece5\kernel_snapshot.d
Invalid depfile: C:\Users\14706\Desktop\Test-SETUP\New folder\This_Folder_Contains_Map_Tests_From_Top_To_Bottom_Atempts\Challenge_1\flutter_login_auth\.dart_tool\flutter_build\6494cc4bb6a11f1a583790c79662ece5\kernel_snapshot.d
../../../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/firebase_database-6.1.2/lib/firebase_database.dart:5:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// #dart=2.9
^^^^^^^^^^^^
lib/Pages/auth/mainLoginCheck.dart:2:8: Error: Not found: 'dart:html'
import 'dart:html';
^
../../../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/firebase_database-6.1.2/lib/src/utils/push_id_generator.dart:5:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// #dart=2.9
^^^^^^^^^^^^
../../../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/firebase_database-6.1.2/lib/src/database_reference.dart:5:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// #dart=2.9
^^^^^^^^^^^^
../../../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/firebase_database-6.1.2/lib/src/event.dart:5:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// #dart=2.9
^^^^^^^^^^^^
../../../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/firebase_database-6.1.2/lib/src/firebase_database.dart:5:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// #dart=2.9
^^^^^^^^^^^^
../../../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/firebase_database-6.1.2/lib/src/query.dart:5:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// #dart=2.9
^^^^^^^^^^^^
../../../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/firebase_database-6.1.2/lib/src/on_disconnect.dart:5:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// #dart=2.9
^^^^^^^^^^^^
Unhandled exception, umm...???
what even is this error that comes along down here?
Unhandled exception:
FileSystemException(uri=org-dartlang-untranslatable-uri:dart
%3Ahtml; message=StandardFileSystem only supports file:* and data:* URIs)
#0 StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file_system.dart:34:7)
#1 asFileUri (package:vm/kernel_front_end.dart:659:37)
#2 writeDepfile (package:vm/kernel_front_end.dart:799:2
1)
<asynchronous suspension>
#3 FrontendCompiler.compile (package:frontend_server/frontend_server.dart:625:9)
<asynchronous suspension>
#4 starter
(package:frontend_server/frontend_server.dart:1451:12)
<asynchronous suspension>
#5 main (file:///C:/b/s/w/ir/x/w/sdk/pkg/frontend_server
/bin/
frontend_server_starter.dart:10:14)
<asynchronous suspension>
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\14706\Desktop\CODES\Flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1159
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\Users\14706\Desktop\CODES\Flutter\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 28s
Running Gradle task 'assembleDebug'... 30.1s
Exception: Gradle task assembleDebug failed with exit code 1
Error: Not found: 'dart:html'
import 'dart:html';
I have previoulsy tried updating flutter on command prompt. Everything it's fine according to flutter doctor. I have tried looking on what #=dart=2.9 is? but not enought understanding still. I have also tried looking on something the error highlights which is 'dart:html'; still, I don't comprehend how and why that is an errors?
1-just delete import 'dart:html'; from your code
2-run flutter clean then flutter pub get
if that doesn't work check this

AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x2012ebad8) & Versions/A/MobileDevice

meilbeck new % flutter build ios
The plugins flutter_geocoder, flutter_open_whatsapp use a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if these plugins support the Android V2 embedding.
Otherwise, consider removing them since a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding:
https://flutter.dev/go/android-plugin-migration.
Building com.meilbeck for device (ios-release)...
Automatically signing iOS for device deployment using specified development team in Xcode project: 867JW4UJXC
Running Xcode build...
Xcode build done. 19.2s
Failed to build iOS app
Error output from Xcode build:
↳
objc[87290]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x2012ebad8) and
/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1112542c8). One of the two will be used.
Which one is undefined.
objc[87290]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x2012ebb28) and
/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x111254318). One of the two will be used.
Which one is undefined.
2022-03-18 15:18:58.509 xcodebuild[87290:648284] DVTAssertions: Warning in
/Library/Caches/com.apple.xbs/Sources/DVTiOSFrameworks/DVTiOSFrameworks-19527/DTDeviceKitBase/DTDKRemoteDeviceData.m:373
Details: (null) deviceType from 7e6c53032d19882e548d8ba3e94aaa015c48cbcc was NULL when -platform called.
Object: <DTDKMobileDeviceToken: 0x125ebfcd0>
Method: -platform
Thread: <NSThread: 0x1140073b0>{number = 2, name = (null)}
Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.
2022-03-18 15:18:58.661 xcodebuild[87290:648293] DVTAssertions: Warning in
/Library/Caches/com.apple.xbs/Sources/DVTiOSFrameworks/DVTiOSFrameworks-19527/DTDeviceKitBase/DTDKRemoteDeviceData.m:373
Details: (null) deviceType from 7e6c53032d19882e548d8ba3e94aaa015c48cbcc was NULL when -platform called.
Object: <DTDKMobileDeviceToken: 0x125ebfcd0>
Method: -platform
Thread: <NSThread: 0x120051510>{number = 6, name = (null)}
Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.
** BUILD FAILED **
Xcode's output:
↳
Writing result bundle at path:
/var/folders/0x/mj92vy8s15jf03g665gyt7g40000gn/T/flutter_tools.RtsbHM/flutter_ios_build_temp_dirUnd5CU/temporary_xcresult_bun
dle
Invalid depfile: /Users/pitcher/Desktop/mailbeck_new/meilbeck
new/.dart_tool/flutter_build/27c0044011412d1e1c8103768df5edea/kernel_snapshot.d
Invalid depfile: /Users/pitcher/Desktop/mailbeck_new/meilbeck
new/.dart_tool/flutter_build/27c0044011412d1e1c8103768df5edea/kernel_snapshot.d
Error: Couldn't resolve the package 'firebase_core' in 'package:firebase_core/firebase_core.dart'.
Error: Couldn't resolve the package 'firebase_messaging' in 'package:firebase_messaging/firebase_messaging.dart'.
lib/main.dart:4:8: Error: Not found: 'package:firebase_core/firebase_core.dart'
import 'package:firebase_core/firebase_core.dart';
^
lib/main.dart:5:8: Error: Not found: 'package:firebase_messaging/firebase_messaging.dart'
import 'package:firebase_messaging/firebase_messaging.dart';
^
lib/main.dart:19:9: Error: Undefined name 'Firebase'.
await Firebase.initializeApp();
^^^^^^^^
lib/main.dart:89:28: Error: The getter 'FirebaseMessaging' isn't defined for the class '_MyHomePageState'.
- '_MyHomePageState' is from 'package:meilbeck/main.dart' ('lib/main.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'FirebaseMessaging'.
var firstToken = await FirebaseMessaging.instance.getToken();
^^^^^^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_calendar_carousel-2.1.0/lib/flutter_calendar_carousel.dart:956:24:
Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart'
('../../flutter/packages/flutter/lib/src/widgets/binding.dart').
WidgetsBinding.instance?.addPostFrameCallback((_) {
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_datetime_picker-1.5.1/lib/flutter_datetime_picker.dart:311:32:
Warning: Operand of null-aware operation '??' has type 'Color' which excludes null.
- 'Color' is from 'dart:ui'.
color: theme.backgroundColor ?? Colors.white,
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/cached_network_image-3.2.0/lib/src/image_provider/cached_network_image_provid
er.dart:109:29: Warning: Operand of null-aware operation '?.' has type 'PaintingBinding' which excludes null.
- 'PaintingBinding' is from 'package:flutter/src/painting/binding.dart'
('../../flutter/packages/flutter/lib/src/painting/binding.dart').
() => PaintingBinding.instance?.imageCache?.evict(key),
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/cached_network_image-3.2.0/lib/src/image_provider/multi_image_stream_complete
r.dart:152:22: Warning: Operand of null-aware operation '?.' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart'
('../../flutter/packages/flutter/lib/src/scheduler/binding.dart').
SchedulerBinding.instance?.scheduleFrameCallback(_handleAppFrame);
^
Unhandled exception:
FileSystemException(uri=org-dartlang-untranslatable-uri:package%3Afirebase_core%2Ffirebase_core.dart;
message=StandardFileSystem only supports file:* and data:* URIs)
#0 StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file_system.dart:34:7)
#1 asFileUri (package:vm/kernel_front_end.dart:653:37)
#2 writeDepfile (package:vm/kernel_front_end.dart:793:21)
<asynchronous suspension>
#3 FrontendCompiler.compile (file:///opt/s/w/ir/cache/builder/sdk/pkg/frontend_server/lib/frontend_server.dart:614:9)
<asynchronous suspension>
#4 starter (file:///opt/s/w/ir/cache/builder/sdk/pkg/frontend_server/lib/frontend_server.dart:1432:12)
<asynchronous suspension>
#5 main (file:///opt/s/w/ir/cache/builder/sdk/pkg/frontend_server/bin/frontend_server_starter.dart:9:14)
<asynchronous suspension>
Failed to package /Users/pitcher/Desktop/mailbeck_new/meilbeck new.
Command PhaseScriptExecution failed with a nonzero exit code
note: Using new build system
note: Planning
note: Build preparation complete
note: Building targets in dependency order
Result bundle written to path:
/var/folders/0x/mj92vy8s15jf03g665gyt7g40000gn/T/flutter_tools.RtsbHM/flutter_ios_build_temp_dirUnd5CU/temporary_xcresult_bun
dle
Encountered error while building for device.
You should run the following command from your flutter project root directory:
flutter pub add firebase_core
Kindly refer to this documentation for more details.

Can't run any other flutter app except for one

I've cloned a new flutter project from git
When I try to run I get the following error
Error: Could not resolve the package 'application_flutter_todo' in 'package:application_flutter_todo/utils/constants/api.dart'.
../../.pub-cache/git/flutter_maximo_api-35d1fef13c59a0e7fb70a20916adf1f9d26eac02/lib/src/maximo_api.dart:5:8: Error: Not found:
'package:application_flutter_todo/utils/constants/api.dart'
import 'package:application_flutter_todo/utils/constants/api.dart';
^
Unhandled exception:
FileSystemException(uri=org-dartlang-untranslatable-uri:package%3Aapplication_flutter_todo%2Futils%2Fconstants%2Fapi.dart; message=StandardFileSystem only supports file:* and data:*
URIs)
#0 StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file_system.dart:33:7)
#1 asFileUri (package:vm/kernel_front_end.dart:604:37)
<asynchronous suspension>
#2 writeDepfile (package:vm/kernel_front_end.dart:799:21)
<asynchronous suspension>
#3 FrontendCompiler.compile (package:frontend_server/frontend_server.dart:472:15)
<asynchronous suspension>
#4 _FlutterFrontendCompiler.compile (package:flutter_frontend_server/server.dart:38:22)
#5 starter (package:flutter_frontend_server/server.dart:149:27)
#6 main (file:///b/s/w/ir/cache/builder/src/flutter/flutter_frontend_server/bin/starter.dart:8:30)
#7 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:305:32)
#8 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
Failed to build bundle.
Failed to package /Users/Mohammad/Gemba/application_traxxion.
Could not build the precompiled application for the device.
It appears that your application still contains the default signing identifier.
Try replacing 'com.example' with your signing id in Xcode:
open ios/Runner.xcworkspace
Note that the current project doesn't have the import 'package:application_flutter_todo' statement.
That statement belongs to another app and is not in the current project that I'm trying to run.
I've tried,
1- flutter clean
2- updating flutter
3- updating packages
4- cleaning the product
5- cleaning the project
6- running the project from terminal, visual studio code, xcode all three gave the same result.
Nothing of the above have worked.
As the error implies, you should change your package name and BundleId for Android & iOS respectively. You shouldn't be using the default ones.
You can find how to do so here.

puppeteer says Exception: Websocket url not found

For the first time, I am using puppeteer with dart , here the simple code :
import 'package:puppeteer/puppeteer.dart';
main() async {
var browser = await puppeteer.launch();
await browser.close();
}
In pubspec yaml file:
dependencies:
puppeteer: ^1.16.1
websocket: ^0.0.5
# path: ^1.6.0
when I am trying to run this piece of code with dart command:
dart puppy1_test.dart
I am getting this exception :
Unhandled exception:
Exception: Websocket url not found
#0 _waitForWebSocketUrl (package:puppeteer/src/puppeteer.dart:311:3)
<asynchronous suspension>
#1 Puppeteer.launch (package:puppeteer/src/puppeteer.dart:170:30)
<asynchronous suspension>
#2 main (file:///D:/project/<removed>/dl/puppy1/test/puppy1_test.dart:7:33)
#3 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:307:19)
#4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)
I solved the problem by deleting the .local-chromium folder. In this folder the chrome application is stored.
I suspect that the reason was a version mismatch, because I updated the dart version, after the creation of the project.

PWA Worker throws an error with AngularDart

I am trying to add offline capabilities to an angular dart project, running pub build but
Running pub build:pub.exe build
-----
Unhandled exception:
ProcessException: The system cannot find the file specified.
Command: pub.exe build
#0 _buildProjectIfEmptyOrOld (http://localhost:52940/pwa.dart:116)
<asynchronous suspension>
#1 main (http://localhost:52940/pwa.dart:40)
<asynchronous suspension>
#2 _startIsolate.<anonymous closure> (dart:isolate-
patch/isolate_patch.dart:263)
#3 _RawReceivePortImpl._handleMessage (dart:isolate-
patch/isolate_patch.dart:151)
main.dart
import 'package:angular/angular.dart';
import 'package:my_app/views/app_component/app_component.dart';
import 'package:pwa/client.dart' as pwa;
void main() {
bootstrap(AppComponent);
// register PWA ServiceWorker for offline caching.
new pwa.Client();
}
pubspec.yaml
dependencies:
pwa: ^0.1.2
At that point, the pwa is trying to run pub.exe build. I haven't tried it on Windows, only a friend reported it working, but it is entirely possible that pub.exe does no longer work (if it ever did), and it should have been pub all along (and in this case it is a Windows-related bug).
Suggested workaround:
run pub build
run pub run pwa
run pub build again
If the above works, let me know, and I'll fix it in a patch release.

Resources