我的 flutter 应用程序在 iOS 模拟器中正常运行。
我通过以下方式添加了fluttertoast:
将其添加到 pubspec.yaml 上
依赖项:flutter:sdk:flutter
库比蒂诺图标:^0.1.3
颤振吐司:^7.0.1
导入我的 dart 文件
导入'包:fluttertoast/fluttertoast.dart';
到目前为止,它按预期工作。但是,当我转移到真正的 iOS 设备(我的 iPhone XS)时,它无法编译。我收到此错误:
致命错误:找不到模块“fluttertoast”@import fluttertoast;
我缺少什么?
我正在尝试使用Future内部数据从 firestore 数据库获取单个字符串数据FutureBuilder。但从null快照数据中获得价值。下面提供了完整的代码。告诉我我哪里出错了。
我可以在函数中打印数据fetchPost()。从 firestore 获取数据后,它会进入FutureBuilder,
但快照数据为空AsyncSnapshot<String>(ConnectionState.done, null, null)
import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
Future <String>fetchPost() async {
final DocumentReference documentReference = Firestore.instance.document("myData/dummy");
documentReference.get().then((datasnapshot){
if(datasnapshot.exists){
print("get data" +datasnapshot.data['url']); ///this printing data //in console
return datasnapshot.data['url'];
}
}).catchError((e){
print("Error");
print(e);
});
}
void main() => runApp(MyApp(post: fetchPost()));
class MyApp extends StatelessWidget {
final Future<String> post;
MyApp({Key key, this.post}) : super(key: key);
@override
Widget build(BuildContext context) {
return …Run Code Online (Sandbox Code Playgroud) 我的问题
这个问题是关于Flutter web的导航的。使用onGenerateRoute函数时,网络导航“接近”普通体验。我们可以使用浏览器的后退按钮弹出路由,推送新路由并在 URL 中获取这些路由的名称。但我的问题出在前进按钮上:
示范
在此视频中,我展示了我的项目导航以及 0:26 后我遇到的问题
要重现的代码
我写了一个简单的项目来演示我的问题。
GitHub: https: //github.com/NeroThroN/navigator
解决方案
有人有解决方案在 Flutter 中包含并修复前进按钮或在浏览器中完全禁用前进按钮吗?
我的颤振应用程序有问题。该应用程序在某些 Android 设备上关闭,没有任何有用的崩溃日志。此外,crashlytics 在任何情况下都不会发送日志。我尝试观察不同的事物,我想提供更多有关我迄今为止所掌握的信息。当我从应用程序打开视频播放器时,通常会发生这种情况。我尝试使用一个带有视频播放器的小应用程序来重现该错误,但该应用程序并未发生该错误。当发生崩溃时,我会收到如下日志:
\nD/ViewRootImpl@7eaca8c[MainActivity](30160): ViewPostImeInputStage processPointer 0\nD/ViewRootImpl@7eaca8c[MainActivity](30160): ViewPostImeInputStage processPointer 1\nI/ExoPlayerImpl(30160): Init 108e3e3 [ExoPlayerLib/2.13.1] [a3xelte, SM-A310F, samsung, 24]\nI/Choreographer(30160): Skipped 43 frames! The application may be doing too much work on its main thread.\nI/System.out(30160): (HTTPLog)-Static: isSBSettingEnabled false\nI/System.out(30160): (HTTPLog)-Static: isSBSettingEnabled false\nD/ViewRootImpl@7eaca8c[MainActivity](30160): Relayout returned: oldFrame=[0,0][720,1280] newFrame=[0,0][720,1280] result=0x1 surface={isValid=true -880830464} surfaceGenerationChanged=false\nD/ViewRootImpl@7eaca8c[MainActivity](30160): ViewPostImeInputStage processPointer 0\nD/ViewRootImpl@7eaca8c[MainActivity](30160): ViewPostImeInputStage processPointer 1\nI/System.out(30160): (HTTPLog)-Static: isSBSettingEnabled false\nI/System.out(30160): (HTTPLog)-Static: isSBSettingEnabled false\nLost connection to device.\nRun Code Online (Sandbox Code Playgroud)\n没有任何崩溃报告。它只是说\xe2\x80\x9c与设备\xe2\x80\x9d失去连接。然后我尝试从Android设备的logcat跟踪应用程序的PID。我在这里也没有遇到任何有用的日志。我看到的关于应用程序\xe2\x80\x99s pid的最后一件事是\xe2\x80\x9c06-23 17:05:48.253 2738 13601 I ActivityManager: Process [Application package name] (pid 3573) has dead(379,50 )\xe2\x80\x9d。我认为这可能是内存问题,操作系统可能会杀死我的应用程序的进程,因此我想监视应用程序使用的内存。我使用具有 …
我被困住了。我的后台通知显示两次。但前台只有一个通知。这是我的代码
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
// If you're going to use other Firebase services in the background, such as Firestore,
// make sure you call `initializeApp` before using other Firebase services.
await Firebase.initializeApp();
if(
!AwesomeStringUtils.isNullOrEmpty(message.notification?.title, considerWhiteSpaceAsEmpty: true) ||
!AwesomeStringUtils.isNullOrEmpty(message.notification?.body, considerWhiteSpaceAsEmpty: true)
){
// print('message also contained a notification: ${message.notification.body}');
String imageUrl;
imageUrl ??= message.notification.android?.imageUrl;
imageUrl ??= message.notification.apple?.imageUrl;
print(imageUrl);
if(imageUrl == null){
var id = Random().nextInt(2147483647);
await AwesomeNotifications().createNotification(
content: NotificationContent(
id: id,
title: message.notification.title,
body: message.notification.body,
color: Colors.orange,
customSound: 'resource://raw/alert', …Run Code Online (Sandbox Code Playgroud) 关注此博客文章:https://blog.ishangavidusha.com/flutter-authentication-flow-with-go-router-and-provider
我已经使用 go router 实现了一个 flutter 应用程序。我已在我的 flutter 应用程序中添加了 firebase 身份验证处理程序initState():
@override
void initState() {
appService = AppService(widget.sharedPreferences);
authService = AuthService();
authSubscription = authService.onAuthStateChange.listen(onAuthStateChange);
super.initState();
}
Run Code Online (Sandbox Code Playgroud)
在我的 authservice 类中,我有一个如下的构造函数:
AuthService() {
authSubscription =
FirebaseAuth.instance.authStateChanges().listen((User? user) {
if (user == null) {
//appService.loginState = false;
print('User is currently signed out!');
_onAuthStateChange.add(false);
} else {
//appService.loginState = true;
print('User is signed in!');
_onAuthStateChange.add(true);
}
});
}
Run Code Online (Sandbox Code Playgroud)
一切正常。当我在应用程序中更改某些内容并保存更改时,应用程序会执行热重新加载。似乎热重载使前一个事件处理程序保持活动状态,因为每次热重载后,authStateChanges当我执行登录任务时,我都会再调用一次事件处理程序。热重载后,print('User is signed in!');登录后我会得到两个打印语句。每次热重载后还会有一个。
这是可以接受的开发行为还是我的应用程序架构不正确?
我正在尝试为 Windows 开发创建一个新的 Flutter 项目,但无法选中PlatformsAndroid Studio 部分中的 Windows 复选框。我使用的是最新的 Flutter SDK(稳定版),并且还安装了 Visual Studio(2022 社区)。请帮我找到缺少的东西。
如何在颤振中从 ExpansionTile 中删除这条灰线?
代码
ExpansionTile(
title: Text(
"Title",
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold
),
),
children: <Widget>[
ListTile(
title: Text(
'data'
),
)
],
),
Run Code Online (Sandbox Code Playgroud)