You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
this package miss the condition kIsWasm and better to defer loading dart:io
Proposal
Changing lib > device_info_plus.dart to those code would solve this problem:
// Copyright 2017 The Chromium Authors. All rights reserved.// Use of this source code is governed by a BSD-style license that can be// found in the LICENSE file.import'dart:async';
import'dart:io' deferred as io;
import'package:device_info_plus_platform_interface/device_info_plus_platform_interface.dart';
import'package:flutter/foundation.dart';
import'src/model/android_device_info.dart';
import'src/model/ios_device_info.dart';
import'src/model/linux_device_info.dart';
import'src/model/macos_device_info.dart';
import'src/model/web_browser_info.dart';
import'src/model/windows_device_info.dart';
export'package:device_info_plus_platform_interface/device_info_plus_platform_interface.dart'show BaseDeviceInfo;
export'src/model/android_device_info.dart';
export'src/model/ios_device_info.dart';
export'src/model/linux_device_info.dart';
export'src/model/macos_device_info.dart';
export'src/model/web_browser_info.dart';
export'src/model/windows_device_info.dart';
export'src/device_info_plus_linux.dart'if (dart.library.js_interop) 'src/device_info_plus_web.dart';
export'src/device_info_plus_windows.dart'if (dart.library.js_interop) 'src/device_info_plus_web.dart';
/// Provides device and operating system information.classDeviceInfoPlugin {
/// No work is done when instantiating the plugin. It's safe to call this /// repeatedly or in performance-sensitive blocks.DeviceInfoPlugin();
// This is to manually endorse the Linux plugin until automatic registration// of dart plugins is implemented.// See https://github.com/flutter/flutter/issues/52267 for more details.staticDeviceInfoPlatformget _platform {
returnDeviceInfoPlatform.instance;
}
/// This information does not change from call to call. Cache it.AndroidDeviceInfo? _cachedAndroidDeviceInfo;
/// Information derived from `android.os.Build`. /// /// See: https://developer.android.com/reference/android/os/Build.htmlFuture<AndroidDeviceInfo> get androidInfo async=>
_cachedAndroidDeviceInfo ??=AndroidDeviceInfo.fromMap((await _platform.deviceInfo()).data);
/// This information does not change from call to call. Cache it.IosDeviceInfo? _cachedIosDeviceInfo;
/// Information derived from `UIDevice`. /// /// See: https://developer.apple.com/documentation/uikit/uideviceFuture<IosDeviceInfo> get iosInfo async=> _cachedIosDeviceInfo ??=IosDeviceInfo.fromMap((await _platform.deviceInfo()).data);
/// This information does not change from call to call. Cache it.LinuxDeviceInfo? _cachedLinuxDeviceInfo;
/// Information derived from `/etc/os-release`. /// /// See: https://www.freedesktop.org/software/systemd/man/os-release.htmlFuture<LinuxDeviceInfo> get linuxInfo async=> _cachedLinuxDeviceInfo ??=await _platform.deviceInfo() asLinuxDeviceInfo;
/// This information does not change from call to call. Cache it.WebBrowserInfo? _cachedWebBrowserInfo;
/// Information derived from `Navigator`.Future<WebBrowserInfo> get webBrowserInfo async=>
_cachedWebBrowserInfo ??=await _platform.deviceInfo() asWebBrowserInfo;
/// This information does not change from call to call. Cache it.MacOsDeviceInfo? _cachedMacosDeviceInfo;
/// Returns device information for macos. Information sourced from Sysctl.Future<MacOsDeviceInfo> get macOsInfo async=> _cachedMacosDeviceInfo ??=MacOsDeviceInfo.fromMap((await _platform.deviceInfo()).data);
WindowsDeviceInfo? _cachedWindowsDeviceInfo;
/// Returns device information for Windows.Future<WindowsDeviceInfo> get windowsInfo async=>
_cachedWindowsDeviceInfo ??=await _platform.deviceInfo() asWindowsDeviceInfo;
/// Returns device information for the current platform.Future<BaseDeviceInfo> get deviceInfo async {
if (kIsWeb || kIsWasm) {
return webBrowserInfo;
} else {
await io.loadLibrary();
if (io.Platform.isAndroid) {
return androidInfo;
} elseif (io.Platform.isIOS) {
return iosInfo;
} elseif (io.Platform.isLinux) {
return linuxInfo;
} elseif (io.Platform.isMacOS) {
return macOsInfo;
} elseif (io.Platform.isWindows) {
return windowsInfo;
}
}
// allow for extension of the pluginreturn _platform.deviceInfo();
}
}
The text was updated successfully, but these errors were encountered:
Plugin
device_info_plus: ^11.3.0
Use case
When run or build web with --wasm
For example:
flutter run -d chrome --wasm
There is an error: Platform operator not support
this package miss the condition
kIsWasm
and better to defer loadingdart:io
Proposal
Changing
lib > device_info_plus.dart
to those code would solve this problem:The text was updated successfully, but these errors were encountered: