I created a flutter web app.
This app is working well but I want to export it as an iOS app to use it on my phone.
When I try to build the app, I get this error :
Launching lib/main.dart on iPhone in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: QJAXXXXXXX
Xcode build done. 56,0s
Failed to build iOS app
Error output from Xcode build:
↳
2022-04-27 16:41:52.572 xcodebuild[91214:1008948] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/DVTiOSFrameworks/DVTiOSFrameworks-19114/DTDeviceKitBase/DTDKRemoteDeviceData.m:373
Details: (null) deviceType from 00008030-001E2CC81E9A402E was NULL when -platform called.
Object: <DTDKMobileDeviceToken: 0x7f8b64b380a0>
Method: -platform
Thread: <NSThread: 0x7f8b60b20e60>{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-04-27 16:41:52.771 xcodebuild[91214:1008959] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/DVTiOSFrameworks/DVTiOSFrameworks-19114/DTDeviceKitBase/DTDKRemoteDeviceData.m:373
Details: (null) deviceType from 00008030-001E2CC81E9A402E was NULL when -platform called.
Object: <DTDKMobileDeviceToken: 0x7f8b64b380a0>
Method: -platform
Thread: <NSThread: 0x7f8b6427c7f0>{number = 10, name = (null)}
Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.
2022-04-27 16:41:52.845 xcodebuild[91214:1008959] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/DVTiOSFrameworks/DVTiOSFrameworks-19114/DTDeviceKitBase/DTDKRemoteDeviceData.m:373
Details: (null) deviceType from 00008030-001E2CC81E9A402E was NULL when -platform called.
Object: <DTDKMobileDeviceToken: 0x7f8b64b380a0>
Method: -platform
Thread: <NSThread: 0x7f8b6427c7f0>{number = 10, 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/2z/tz90cc4d63gd7v38j8zm21g80000gn/T/flutter_tools.iZwJm9/flutter_ios_build_temp_dirfoYRV2/temporary_xcresult_bundle
Invalid depfile: /Users/Pierre/AndroidStudioProjects/picomanager/.dart_tool/flutter_build/05d710429877ee87af274badd140677f/kernel_snapshot.d
Invalid depfile: /Users/Pierre/AndroidStudioProjects/picomanager/.dart_tool/flutter_build/05d710429877ee87af274badd140677f/kernel_snapshot.d
Invalid depfile: /Users/Pierre/AndroidStudioProjects/picomanager/.dart_tool/flutter_build/05d710429877ee87af274badd140677f/kernel_snapshot.d
Invalid depfile: /Users/Pierre/AndroidStudioProjects/picomanager/.dart_tool/flutter_build/05d710429877ee87af274badd140677f/kernel_snapshot.d
: Error: Not found: 'dart:html'
import 'dart:html';
^
: Error: Not found: 'dart:html'
import 'dart:html';
^
: Error: Not found: 'dart:html'
import 'dart:html';
^
: Error: Not found: 'dart:html'
import 'dart:html';
^
: Error: Not found: 'dart:js'
export 'dart:js' show allowInterop, allowInteropCaptureThis;
^
: Error: Not found: 'dart:js_util'
export 'dart:js_util';
^
: Error: Not found: 'dart:html'
import 'dart:html';
^
: Error: Type 'Blob' not found.
Blob _createBlobFromBytes(Uint8List bytes, String? mimeType) {
^^^^
: Error: Type 'Blob' not found.
Blob? _browserBlob;
^^^^
: Error: Type 'Element' not found.
late Element _target;
^^^^^^^
: Error: Type 'Blob' not found.
Future<Blob> get _blob async {
^^^^
: Error: Type 'Blob' not found.
Future<Uint8List> _blobToByteBuffer(Blob blob) async {
^^^^
: Error: Type 'Element' not found.
Element Function(String href, String suggestedName) createAnchorElement;
^^^^^^^
: Error: Type 'AnchorElement' not found.
AnchorElement createAnchorElement(String href, String? suggestedName) {
^^^^^^^^^^^^^
: Error: Type 'Element' not found.
void addElementToContainerAndClick(Element container, Element element) {
^^^^^^^
: Error: Type 'Element' not found.
void addElementToContainerAndClick(Element container, Element element) {
^^^^^^^
: Error: Type 'Element' not found.
Element ensureInitialized(String id) {
^^^^^^^
: Error: 'HttpRequest' isn't a type.
final _xhrs = <HttpRequest>{};
^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'Auth'.
- 'Auth' is from 'package:firebase/src/auth.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/auth.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final nextWrapper = allowInterop((firebase_interop.UserJsImpl? user) {
^^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'Auth'.
- 'Auth' is from 'package:firebase/src/auth.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/auth.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final errorWrapper = allowInterop((e) => changeController.addError(e));
^^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'Auth'.
- 'Auth' is from 'package:firebase/src/auth.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/auth.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
allowInterop((firebase_interop.UserJsImpl? user) {
^^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'Auth'.
- 'Auth' is from 'package:firebase/src/auth.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/auth.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
allowInterop(idTokenChangedController.addError),
^^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'DatabaseReference<T>'.
- 'DatabaseReference' is from 'package:firebase/src/database.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/database.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
allowInterop((update) => jsify(transactionUpdate(dartify(update))));
^^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'DatabaseReference<T>'.
- 'DatabaseReference' is from 'package:firebase/src/database.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/database.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final onCompleteWrap = allowInterop(
^^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'Query<T>'.
- 'Query' is from 'package:firebase/src/database.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/database.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final callbackWrap = allowInterop((
^^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'Query<T>'.
- 'Query' is from 'package:firebase/src/database.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/database.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
jsObject.once(eventType, allowInterop(
^^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'DataSnapshot'.
- 'DataSnapshot' is from 'package:firebase/src/database.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/database.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final actionWrap = allowInterop((d) => action(DataSnapshot.getInstance(d)));
^^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'Messaging'.
- 'Messaging' is from 'package:firebase/src/messaging.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/messaging.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final nextWrapper = allowInterop((payload) {
^^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'Messaging'.
- 'Messaging' is from 'package:firebase/src/messaging.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/messaging.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final errorWrapper = allowInterop(controller.addError);
^^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'Messaging'.
- 'Messaging' is from 'package:firebase/src/messaging.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/messaging.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final nextWrapper = allowInterop((payload) {
^^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'Messaging'.
- 'Messaging' is from 'package:firebase/src/messaging.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/messaging.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final nextWrapper = allowInterop((_) => null);
^^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'Messaging'.
- 'Messaging' is from 'package:firebase/src/messaging.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/messaging.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final errorWrapper = allowInterop((e) {
^^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'UploadTask'.
- 'UploadTask' is from 'package:firebase/src/storage.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/storage.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final nextWrapper = allowInterop(
^^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'UploadTask'.
- 'UploadTask' is from 'package:firebase/src/storage.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/storage.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final onCompletion = allowInterop(() {
^^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'UploadTask'.
- 'UploadTask' is from 'package:firebase/src/storage.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/storage.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
allowInterop(_changeController.addError),
^^^^^^^^^^^^
: Error: Method not found: 'hasProperty'.
if (js.hasProperty(error, 'message')) {
^^^^^^^^^^^
: Error: Method not found: 'getProperty'.
final message = js.getProperty(error, 'message');
^^^^^^^^^^^
: Error: Method not found: 'getProperty'.
map[key] = dartify(util.getProperty(jsObject, key));
^^^^^^^^^^^
: Error: Method not found: 'newObject'.
final jsMap = util.newObject();
^^^^^^^^^
: Error: Method not found: 'setProperty'.
util.setProperty(jsMap, key, jsify(value));
^^^^^^^^^^^
: Error: Method not found: 'allowInterop'.
return allowInterop(dartObject);
^^^^^^^^^^^^
: Error: Method not found: 'callMethod'.
util.callMethod(jsObject, method, args);
^^^^^^^^^^
: Error: Method not found: 'promiseToFuture'.
value = await util.promiseToFuture(thenable);
^^^^^^^^^^^^^^^
: Error: Method not found: 'hasProperty'.
if (util.hasProperty(e, 'code')) {
^^^^^^^^^^^
: Error: Method not found: 'allowInterop'.
PromiseJsImpl<S>(allowInterop((
^^^^^^^^^^^^
: Error: Method not found: 'allowInterop'.
allowInterop(c.completeError);
^^^^^^^^^^^^
: Error: Method not found: 'getProperty'.
String get code => util.getProperty(_source, 'code');
^^^^^^^^^^^
: Error: Method not found: 'getProperty'.
String get message => util.getProperty(_source, 'message');
^^^^^^^^^^^
: Error: Method not found: 'getProperty'.
String get name => util.getProperty(_source, 'name');
^^^^^^^^^^^
: Error: Method not found: 'getProperty'.
Object get serverResponse => util.getProperty(_source, 'serverResponse');
^^^^^^^^^^^
: Error: Method not found: 'getProperty'.
String get stack => util.getProperty(_source, 'stack');
^^^^^^^^^^^
: Error: Method not found: 'instanceof'.
return util.instanceof(object, type);
^^^^^^^^^^
: Error: Undefined name 'window'.
Object? start = window;
^^^^^^
: Error: Method not found: 'getProperty'.
start = util.getProperty(start, item);
^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'Firestore'.
- 'Firestore' is from 'package:firebase/src/firestore.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/firestore.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final updateFunctionWrap = allowInterop((transaction) =>
^^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'DocumentReference'.
- 'DocumentReference' is from 'package:firebase/src/firestore.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/firestore.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
allowInterop((firestore_interop.DocumentSnapshotJsImpl snapshot) {
^^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'DocumentReference'.
- 'DocumentReference' is from 'package:firebase/src/firestore.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/firestore.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final errorWrapper = allowInterop((e) => controller.addError(e));
^^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'Query<T>'.
- 'Query' is from 'package:firebase/src/firestore.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/firestore.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
allowInterop((firestore_interop.QuerySnapshotJsImpl snapshot) {
^^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'Query<T>'.
- 'Query' is from 'package:firebase/src/firestore.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/firestore.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final errorWrapper = allowInterop((e) => controller.addError(e));
^^^^^^^^^^^^
: Error: The method 'allowInterop' isn't defined for the class 'QuerySnapshot'.
- 'QuerySnapshot' is from 'package:firebase/src/firestore.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase-9.0.2/lib/src/firestore.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
allowInterop((s) => callback(DocumentSnapshot.getInstance(s)));
^^^^^^^^^^^^
: Error: The getter 'Url' isn't defined for the class 'XFile'.
- 'XFile' is from 'package:cross_file/src/types/html.dart' ('../../.pub-cache/hosted/pub.dartlang.org/cross_file-0.3.2/lib/src/types/html.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'Url'.
_path = Url.createObjectUrl(_browserBlob);
^^^
: Error: The method 'Blob' isn't defined for the class 'XFile'.
- 'XFile' is from 'package:cross_file/src/types/html.dart' ('../../.pub-cache/hosted/pub.dartlang.org/cross_file-0.3.2/lib/src/types/html.dart').
Try correcting the name to the name of an existing method, or defining a method named 'Blob'.
? Blob(<dynamic>[bytes])
^^^^
: Error: The method 'Blob' isn't defined for the class 'XFile'.
- 'XFile' is from 'package:cross_file/src/types/html.dart' ('../../.pub-cache/hosted/pub.dartlang.org/cross_file-0.3.2/lib/src/types/html.dart').
Try correcting the name to the name of an existing method, or defining a method named 'Blob'.
: Blob(<dynamic>[bytes], mimeType);
^^^^
: Error: 'Blob' isn't a type.
Blob? _browserBlob;
^^^^
: Error: 'Element' isn't a type.
late Element _target;
^^^^^^^
: Error: 'HttpRequest' isn't a type.
late HttpRequest request;
^^^^^^^^^^^
: Error: 'ProgressEvent' isn't a type.
} on ProgressEvent catch (e) {
^^^^^^^^^^^^^
: Error: The getter 'HttpRequest' isn't defined for the class 'XFile'.
- 'XFile' is from 'package:cross_file/src/types/html.dart' ('../../.pub-cache/hosted/pub.dartlang.org/cross_file-0.3.2/lib/src/types/html.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'HttpRequest'.
request = await HttpRequest.request(path, responseType: 'blob');
^^^^^^^^^^^
: Error: 'Blob' isn't a type.
final Blob blob = await _blob;
^^^^
: Error: 'Blob' isn't a type.
final Blob slice = blob.slice(start ?? 0, end ?? blob.size, blob.type);
^^^^
: Error: 'Blob' isn't a type.
Future<Uint8List> _blobToByteBuffer(Blob blob) async {
^^^^
: Error: 'FileReader' isn't a type.
final FileReader reader = FileReader();
^^^^^^^^^^
: Error: The method 'FileReader' isn't defined for the class 'XFile'.
- 'XFile' is from 'package:cross_file/src/types/html.dart' ('../../.pub-cache/hosted/pub.dartlang.org/cross_file-0.3.2/lib/src/types/html.dart').
Try correcting the name to the name of an existing method, or defining a method named 'FileReader'.
final FileReader reader = FileReader();
^^^^^^^^^^
: Error: 'AnchorElement' isn't a type.
final AnchorElement element = _hasTestOverrides
^^^^^^^^^^^^^
: Error: 'AnchorElement' isn't a type.
? _overrides!.createAnchorElement(this.path, name) as AnchorElement
^^^^^^^^^^^^^
: Error: 'Element' isn't a type.
Element Function(String href, String suggestedName) createAnchorElement;
^^^^^^^
: Error: Method not found: 'webOnlyInstantiateImageCodecFromUrl'.
return ui.webOnlyInstantiateImageCodecFromUrl(// ignore: undefined_function, avoid_dynamic_calls
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: Error: The method 'HttpRequest' isn't defined for the class 'BrowserClient'.
- 'BrowserClient' is from 'package:http/src/browser_client.dart' ('../../.pub-cache/hosted/pub.dartlang.org/http-0.13.4/lib/src/browser_client.dart').
Try correcting the name to the name of an existing method, or defining a method named 'HttpRequest'.
var xhr = HttpRequest();
^^^^^^^^^^^
: Error: 'AnchorElement' isn't a type.
final AnchorElement element = AnchorElement(href: href);
^^^^^^^^^^^^^
: Error: Method not found: 'AnchorElement'.
final AnchorElement element = AnchorElement(href: href);
^^^^^^^^^^^^^
: Error: 'Element' isn't a type.
void addElementToContainerAndClick(Element container, Element element) {
^^^^^^^
: Error: 'Element' isn't a type.
void addElementToContainerAndClick(Element container, Element element) {
^^^^^^^
: Error: 'Element' isn't a type.
Element? target = querySelector('#$id');
^^^^^^^
: Error: Method not found: 'querySelector'.
Element? target = querySelector('#$id');
^^^^^^^^^^^^^
: Error: 'Element' isn't a type.
final Element targetElement = Element.tag('flt-x-file')..id = id;
^^^^^^^
: Error: Undefined name 'Element'.
final Element targetElement = Element.tag('flt-x-file')..id = id;
^^^^^^^
: Error: Method not found: 'querySelector'.
querySelector('body')!.children.add(targetElement);
^^^^^^^^^^^^^
: Error: Undefined name 'window'.
return window.navigator.vendor == 'Apple Computer, Inc.';
^^^^^^
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:623:37)
#2 writeDepfile (package:vm/kernel_front_end.dart:763:21)
<asynchronous suspension>
#3 FrontendCompiler.compile (package:frontend_server/frontend_server.dart:586:9)
<asynchronous suspension>
#4 starter (package:flutter_frontend_server/server.dart:85:12)
<asynchronous suspension>
#5 main (file:///opt/s/w/ir/cache/builder/src/flutter/flutter_frontend_server/bin/starter.dart:13:24)
<asynchronous suspension>
Failed to package /Users/Pierre/AndroidStudioProjects/picomanager.
Command PhaseScriptExecution failed with a nonzero exit code
note: Using new build system
note: Planning
note: Build preparation complete
note: Building targets in parallel
/Users/Pierre/AndroidStudioProjects/picomanager/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.0.99. (in target 'leveldb-library' from project 'Pods')
Result bundle written to path:
/var/folders/2z/tz90cc4d63gd7v38j8zm21g80000gn/T/flutter_tools.iZwJm9/flutter_ios_build_temp_dirfoYRV2/temporary_xcresult_bundle
Could not build the precompiled application for the device.
Error launching application on iPhone.
Exited (sigterm)
Have you ever seen this error before ?
How did you fix it ? I tried to clean the project several times but this is not working.
Is it possible to build a flutter app designed for web on iOS ?
Thank you !
Unfortunately, Flutter builds for mobile platforms break if you have an import of dart:html somewhere in your code.
A solution to this problem can be to use conditional imports, but you have to construct something like this:
downloader.dart
void downloadFile(List<int> data, String fileName) {
throw UnimplementedError('Cannot use the downloader');
}
downloader_mobile.dart
import 'dart:developer';
void downloadFile(List<int> data, String fileName) {
log('Download is not available for mobile.');
}
downloader_web.dart
// ignore_for_file: avoid_web_libraries_in_flutter
import 'dart:convert';
import 'dart:html' as html;
void downloadFile(List<int> data, String fileName) {
final base64encodedData = base64Encode(data);
final anchor = html.AnchorElement(
href: 'data:application/octet-stream;charset=utf-8;'
'base64,$base64encodedData',
)
..setAttribute('download', fileName)
..click();
html.document.body?.children.remove(anchor);
}
And in the consuming class we check for the existence of dart.library.io and dart.library.js to determine if we are in a web or mobile environment.
import 'package:xxx/features/xxx/tools/downloader.dart'
if (dart.library.io) 'package:xxx/features/xxx/tools/downloader_mobile.dart'
if (dart.library.js) 'package:xxx/features/xxx/tools/downloader_web.dart';
Related
First time create a VS extension [VSIX] project in VS2022.
I do not know what is cause of problems below. I do everything like in doc.
I tried to run a simple VSIX project hello world in VS 2022 like in doc: https://learn.microsoft.com/en-us/visualstudio/extensibility/extensibility-hello-world?view=vs-2022
Step 1.
Right-click the project (not the solution). On the context menu, select Add, and then New Item.
Step 2.
Select the Extensibility section, and then choose Command.
Step 3.
Press F5 to debug, check the XAML binding failures:
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using System;
using System.ComponentModel.Design;
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using Task = System.Threading.Tasks.Task;
namespace VSIXProject2 {
internal sealed class Command1 {
public
const int CommandId = 0x0100;
public static readonly Guid CommandSet = new Guid("f83fb9b7-23b6-4605-bc93-74df2c22ec53");
private readonly AsyncPackage package;
private Command1(AsyncPackage package, OleMenuCommandService commandService) {
this.package = package ??
throw new ArgumentNullException(nameof(package));
commandService = commandService ??
throw new ArgumentNullException(nameof(commandService));
var menuCommandID = new CommandID(CommandSet, CommandId);
var menuItem = new MenuCommand(this.Execute, menuCommandID);
commandService.AddCommand(menuItem);
}
public static Command1 Instance {
get;
private set;
}
private Microsoft.VisualStudio.Shell.IAsyncServiceProvider ServiceProvider {
get {
return this.package;
}
}
public static async Task InitializeAsync(AsyncPackage package) {
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken);
OleMenuCommandService commandService = await package.GetServiceAsync(typeof (IMenuCommandService)) as OleMenuCommandService;
Instance = new Command1(package, commandService);
}
private void Execute(object sender, EventArgs e) {
ThreadHelper.ThrowIfNotOnUIThread();
string message = string.Format(CultureInfo.CurrentCulture, "Inside {0}.MenuItemCallback()", this.GetType().FullName);
string title = "Command1";
VsShellUtilities.ShowMessageBox(
this.package,
message,
title,
OLEMSGICON.OLEMSGICON_INFO,
OLEMSGBUTTON.OLEMSGBUTTON_OK,
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
}
}
}
System.Windows.Data Error: 17 : Cannot get 'CurrentState' value (type 'Int32') from '' (type 'PolicyBasedDataSource'). BindingExpression:Path=CurrentState; DataItem='PolicyBasedDataSource' (HashCode=8713795); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String') System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='' BindingExpression:Path=ToolTip; DataItem='GlyphButton' (Name='MaximizeButton'); target element is 'GlyphButton' (Name='MaximizeButton'); target property is 'Name' (type 'String') System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='' BindingExpression:Path=ToolTip; DataItem='GlyphButton' (Name='CloseButton'); target element is 'GlyphButton' (Name='CloseButton'); target property is 'Name' (type 'String') System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='' BindingExpression:Path=Content; DataItem='Button' (Name=''); target element is 'Button' (Name=''); target property is 'Name' (type 'String') System.Windows.Data Error: 40 : BindingExpression path error: 'Text' property not found on 'object' ''DataSource' (HashCode=60105532)'. BindingExpression:Path=Text; DataItem='DataSource' (HashCode=60105532); target element is 'VsToolBar' (Name=''); target property is 'Name' (type 'String') System.Windows.Data Error: 40 : BindingExpression path error: 'Items' property not found on 'object' ''DataSource' (HashCode=60105532)'. BindingExpression:Path=Items; DataItem='DataSource' (HashCode=60105532); target element is 'VsToolBar' (Name=''); target property is 'ItemsSource' (type 'IEnumerable') System.Windows.Data Error: 40 : BindingExpression path error: 'PlacementSlot' property not found on 'object' ''DataSource' (HashCode=60105532)'. BindingExpression:Path=PlacementSlot; DataItem='DataSource' (HashCode=60105532); target element is 'VsToolBar' (Name=''); target property is 'Band' (type 'Int32') System.Windows.Data Error: 40 : BindingExpression path error: 'BandIndex' property not found on 'object' ''DataSource' (HashCode=60105532)'. BindingExpression:Path=BandIndex; DataItem='DataSource' (HashCode=60105532); target element is 'VsToolBar' (Name=''); target property is 'BandIndex' (type 'Int32') System.Windows.Data Error: 40 : BindingExpression path error: 'IsVisible' property not found on 'object' ''DataSource' (HashCode=60105532)'. BindingExpression:Path=IsVisible; DataItem='DataSource' (HashCode=60105532); target element is 'VsToolBar' (Name=''); target property is 'Visibility' (type 'Visibility')
I found similar problem here: https://developercommunity.visualstudio.com/t/new-vsix-project-in-vs2022-has-xaml-binding-failur/1580267?viewtype=solutions
I want to raise an exception like that if an object is missing from the context object attribute list:
//******************************************************************************
EMissingContextObject = class (...)
//******************************************************************************
private
// Attributes
fAttrName : string;
fAttrType : TClass;
public
// Overiden constructors
constructor create( attrName_ : string; attrType_ : TClass );
// Properties
property attrName : string read fAttrName;
property attrType : TClass read fAttrType;
end;
//******************************************************************************
How can I pass the TClass type of an arbitrary TObject descendant? I know there is the
CClassType = class of TClassType;
definition but I don't want to depend on this declaration.
I've tried the TObject.classType, but it just works on instances.
I've tried the TypeInfo( TClassType ) but it gives back just the name of the class.
There should be something like in Java:
TClass c = TClassType.class;
or
TClass c = TClass.forName( className );
Thanks in advance!
In my PHP Extension (Written in C) I have a string with the class name. To be more precise, I have the namespace + class name. For example: Dumb\Factory
This class implements an interface defined in my extension which has a class entry
zend_class_entry *garlic_servicemanager_factoryinterface_ce;
and implements a public method named createService
Inside another class I have a method named get and I check to see if the parameter is a string. When it is a String I would like to instantiate the class and call that method, however I don't know how to instantiate the PHP class from within my C code.
How may I instantiate a class from a string so I can call the method defined by the interface?
You have to find the class_entry from the string and you can do it like below...
zend_class_entry *ce = NULL;
char *className = "Dumb\Factory";
zend_class_entry **pce;
if (zend_lookup_class(className, strlen(className ), &pce TSRMLS_CC) == FAILURE) {
zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Class %s does not exist", className);
return;
}
ce = *pce;
// Now you have got "zend_class_entry" and
// now you can create N number of objects out of it.
// Check the Reflection API for more info.
I have a numeric parameter in the symfony's parameters.yml file and I have a configuration class in my bundle where I validate that the parameter is an integer, but I get the following error in the validation proccess:
[Symfony\Component\Config\Definition\Exception\InvalidTypeException]
Invalid type for path "page_size". Expected int, but got string.
Is there a way to specify the parameter type in the parameters.yml file?
EDIT
parameters.yml:
parameters:
...
list_page_size: 15
...
config.yml:
...
example:
page_size: %list_page_size%
...
Configuration.php:
class Configuration implements ConfigurationInterface
{
/**
* {#inheritDoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('example');
$rootNode->children()
// Some code here
->integerNode('page_size')
->defaultValue(15)
->end()
// More code here
->end();
return $treeBuilder;
}
}
EDIT 2
I have discovered that the exception is thrown in the prepend() method in the bundle extension file (DependencyInjection/ExampleExtension.php), but the error is not thrown in the load method of the same file. It seems like if the parameters.yml file was not loaded at prepend method execution time.
The exception is simply because the is_int check fails.
A simple solution would be to add a normalization step like:
// Some code here
->integerNode('page_size')
->beforeNormalization()
->ifString()
->then(function ($val) { return strval(intval($val)) === $val ? intval($val) : $val; })
->end()
->defaultValue(15)
->end()
// More code here
Also take a look at http://symfony.com/doc/current/components/config/definition.html#normalization
If you entered something like :
page_size: "10"
Then it's a normal behavior.
You should not use " :
page_size: 10
export class MyClass extends kendo.data.ObservableObject {
constructor() {
super();
super.init(this);
}
.
.
.
.
}
I get compilation error:
Error 599 Build: Type name 'kendo.data.ObservableObject' in extends clause does not reference constructor function for 'kendo.data.ObservableObject'.
What am I missing here ?
Type name 'kendo.data.ObservableObject' in extends clause does not reference constructor function for 'kendo.data.ObservableObject'.
Based on http://docs.telerik.com/kendo-ui/api/framework/observableobject the constructor needs as least one argument (the object to observe) So you need to call the constructor with an argument as shown:
export class MyClass extends kendo.data.ObservableObject {
constructor(objToObserve) {
super(objToObserve);
}
.
.
.
.
}
This error, perhaps the most confusing issued by the compiler, means that when the compiler looked up the value indicated by the type in the extends clause, it didn't resolve to a value that was a constructor function for that type.
A smaller example:
class C { }
module M {
var C = 3;
class D extends C { } // <-- Error
}
Here, the type name C inside M means class C, but the value name C means the var declared in the module.
It sounds like you might have a var kendo or var data somewhere in your program. To diagnose this, above the line you write extends kendo.data.ObservableObject, write var foo: kendo.data.ObservableObject and see what error you get.