运行Flutter项目后,出现此错误。我能做什么来解决它?
Error: The method 'setMockMessageHandler'
isn't defined for the class 'BasicMessageChannel<dynamic>'.
FAILURE: Build failed with an exception.
Run Code Online (Sandbox Code Playgroud) mobile-application dart flutter flutter2.0 flutter-exception
迁移到 null-safety 和 flutter 2 后,我遇到了 ios 构建问题:
我运行flutter clean; rm ios/Podfile.lock pubspec.lock; rm -rf ios/Pods ios/Runner.xcworkspace; flutter run --flavor dev -t lib/main_dev.dart
并得到这个 logcat:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_FlutterStandardTypedData", referenced from:
objc-class-ref in google_maps_flutter(GoogleMapController.o)
"_OBJC_CLASS_$_FlutterStandardMessageCodec", referenced from:
objc-class-ref in google_maps_flutter(GoogleMapController.o)
"_OBJC_CLASS_$_FlutterError", referenced from:
objc-class-ref in firebase_core(FLTFirebasePlugin.o)
objc-class-ref in google_maps_flutter(FLTGoogleMapsPlugin.o)
objc-class-ref in google_maps_flutter(FLTGoogleMapTileOverlayController.o)
objc-class-ref in google_maps_flutter(GoogleMapMarkerController.o)
objc-class-ref in google_maps_flutter(GoogleMapController.o)
objc-class-ref in onesignal_flutter(OSFlutterCategories.o)
"_OBJC_CLASS_$_FlutterMethodChannel", referenced from:
objc-class-ref in firebase_core(FLTFirebaseCorePlugin.o)
objc-class-ref in firebase_crashlytics(FLTFirebaseCrashlyticsPlugin.o)
objc-class-ref in google_maps_flutter(GoogleMapController.o)
objc-class-ref in onesignal_flutter(OSFlutterOutcomeEventsController.o)
objc-class-ref …
Run Code Online (Sandbox Code Playgroud) 我正在制作一个项目,其中当用户单击按钮时,计时器将启动,在用户设置时间后,将播放我 just_audio: ^0.6.15+1
在我的 flutter 项目中使用的声音,但它会导致下面的许多问题都是错误的。
D/Linux (21303): [Posix_connect Debug]Process com.snss.xlnc :443 \nE/flutter (21303): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: Connection aborted\nE/flutter (21303): #0 AudioPlayer._load (package:just_audio/just_audio.dart:688:11)\nE/flutter (21303): <asynchronous suspension>\nE/flutter (21303): #1 AudioPlayer.load (package:just_audio/just_audio.dart:625:14)\nE/flutter (21303): <asynchronous suspension>\nE/flutter (21303): #2 AudioPlayer.setAudioSource (package:just_audio/just_audio.dart:602:18)\nE/flutter (21303): <asynchronous suspension>\nE/flutter (21303): #3 _ClassStartState.keepRunning (package:xlnc/tutor/startClass.dart:84:7)\nE/flutter (21303): <asynchronous suspension>\nE/flutter (21303): \n
Run Code Online (Sandbox Code Playgroud)\n这是我的代码
\nvar t = DateFormat.Hms().parse(time);\nvar rT = DateFormat.Hms().parse(remTime);\nvar co = t.isAfter(rT);\n\nif (co) {\n player.setUrl('$soundUrl');\n player.setVolume(1);\n player.play();\n player.setLoopMode(LoopMode.one);\n}\n
Run Code Online (Sandbox Code Playgroud)\n这是我的颤振医生-v
\n[\xe2\x88\x9a] Flutter (Channel stable, 2.0.1, on Microsoft Windows …
Run Code Online (Sandbox Code Playgroud) 我发布这个问题是为了帮助未来的读者。升级到后,Flutter 2.8
在尝试运行我的应用程序时突然出现此错误:
Flutter: A value of type 'ListTileThemeData' can't be assigned to a variable of type 'ListTileTheme'.
Run Code Online (Sandbox Code Playgroud)
我是如何解决这个问题的?
在我的应用程序中,我使用 2 个材质应用程序来处理底部导航栏的导航。由于我的应用程序非常复杂,这是执行此操作的最佳方法。
在一个屏幕上,当用户未登录时,将打开一个底部表单,用户可以在其中输入他的登录凭据。
bottomSheet 应出现在导航栏上方。
在下面的代码片段中,这就是我解决它的方法。
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(),
);
}
}
final _navigationKey = GlobalKey<NavigatorState>();
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int currentIndex = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
resizeToAvoidBottomInset: true,
body: MaterialApp(
navigatorKey: _navigationKey, …
Run Code Online (Sandbox Code Playgroud) 我在 Flutter 2.0 中遇到了 Firebase Cloud Messaging onMessage 的问题。
功能
FirebaseMessaging.onMessage.listen((RemoteMessage message) { ... }
是不叫在前台接收消息时。但是,日志说
收到消息的广播
在收到的第一条消息中,我收到了额外的警告,例如:
访问隐藏方法 Landroid/os/WorkSource
但是警告在后续消息中消失。
在有趣的是,
FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler);
作品。
如果我将应用程序发送到后台,我会收到通知并调用定义的方法。
@override
void initState() {
initializeFlutterFire()
.then((value) => subscribeToMessages);
super.initState();
}
Future<void> initializeFlutterFire() async {
try {
Firebase.initializeApp();
setState(() {
_initialized = true;
print("Firebase has been initialized");
});
} catch (e) {
setState(() {
_error = true;
});
}
}
void subscribeToMessages() {
// The following handler is called, when App …
Run Code Online (Sandbox Code Playgroud) android firebase flutter firebase-cloud-messaging flutter2.0
我正在使用 Flutter 2.0 开发一个 Windows 桌面应用程序。如何清除应用程序数据并使其保持在第 0 天的状态、删除所有缓存、删除任何签名帐户……就像 Android 中的清除数据一样。
我不能使用,TextEditingController
因为TextFormField
使用Autocomplete
fieldViewBuilder
TextEditingController
Autocomplete(
optionsBuilder: (TextEditingValue textEditingValue) {
if (textEditingValue.text == '') return [];
return this
.productNames
.where((Map<String, dynamic> option) {
return option['ar']
.toLowerCase()
.contains(textEditingValue.text.toLowerCase());
});
},
fieldViewBuilder: (context, textEditingController,
focusNode, onFieldSubmitted) =>
TextFormField(
controller: textEditingController,//uses fieldViewBuilder TextEditingController
focusNode: focusNode,
),
),
Run Code Online (Sandbox Code Playgroud) Flutter 应用程序专为移动和 Web 设计。我们使用 firebase_messaging 来实现消息传递功能。早些时候这是工作魅力。最近我们将 Flutter SDK 升级到 2.0 版本(Channel stable,2.0.4)。
\n该应用程序的工作方式与早期的移动版本相同。但是在网络版本中执行时出现下面提到的错误并且无法解决。
\n以下命令已尝试禁用空安全,但没有用。
\nflutter run --no-sound-null-safety\n
Run Code Online (Sandbox Code Playgroud)\n\n\n错误日志:
\n
Debug service listening on ws://127.0.0.1:53789/y22KqzTNKwU=/ws\n\nRunning with unsound null safety\nFor more information see https://dart.dev/null-safety/unsound-null-safety\nDebug service listening on ws://127.0.0.1:53789/y22KqzTNKwU=/ws\nTypeError: Cannot read property 'isSupported' of undefined\n at new firebase_messaging_web.FirebaseMessagingWeb.new (http://localhost:53495/packages/firebase_messaging_web/firebase_messaging_web.dart.lib.js:189:51)\n at Function.registerWith (http://localhost:53495/packages/firebase_messaging_web/firebase_messaging_web.dart.lib.js:56:73)\n at Object.registerPlugins (http://localhost:53495/packages/pca_app/generated_plugin_registrant.dart.lib.js:44:49)\n at main (http://localhost:53495/web_entrypoint.dart.lib.js:44:35)\n at main.next (<anonymous>)\n at runBody (http://localhost:53495/dart_sdk.js:39051:34)\n at Object._async [as async] (http://localhost:53495/dart_sdk.js:39082:7)\n at main$ (http://localhost:53495/web_entrypoint.dart.lib.js:43:18)\n at http://localhost:53495/main_module.bootstrap.js:19:10\n at Array.forEach (<anonymous>)\n …
Run Code Online (Sandbox Code Playgroud) 在切换到 Flutter 2 之前,我使用旧版本的 firebaseMessaging 没有问题,现在我有了最新版本。升级后出现以下错误:
The class 'FirebaseMessaging' doesn't have a default constructor.
Run Code Online (Sandbox Code Playgroud)
和:
The method 'configure' isn't defined for the type 'FirebaseMessaging'.
Run Code Online (Sandbox Code Playgroud)
全班:
class ShowNotifications {
static final FirebaseMessaging firebaseMessaging = FirebaseMessaging();
static FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
new FlutterLocalNotificationsPlugin();
static void initialization(){
var initializationSettingsAndroid =
new AndroidInitializationSettings('@mipmap/ic_launcher');
var initializationSettingsIOS = new IOSInitializationSettings();
var initializationSettings = new InitializationSettings(
android: initializationSettingsAndroid, iOS: initializationSettingsIOS);
flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
flutterLocalNotificationsPlugin.initialize(initializationSettings,
onSelectNotification: onSelectNotification);
}
static void showNotification(String title, String body) async {
await _demoNotification(title, …
Run Code Online (Sandbox Code Playgroud) flutter ×10
flutter2.0 ×10
dart ×3
android ×2
caching ×1
desktop ×1
firebase ×1
flutter-ios ×1
flutter-web ×1
just-audio ×1
mobile ×1
onesignal ×1
windows ×1