当我从 Flutter 移动设备转移到 Web 设备时,我注意到控制台上打印的日志没有帮助,因为它们不针对我的 IDE (Android Studio) 中的代码 在移动设备上:
======= Exception caught by widgets library =======================================================
The following message was thrown building PhoneSignUpPage(state: _PhoneSignUpPageState#b52e9):
some error
The relevant error-causing widget was:
PhoneSignUpPage file:///Users/me/AndroidStudioProjects/myproject/lib/services/routing_service.dart:30:14
When the exception was thrown, this was the stack:
#0 PhonePageViewState.initState (package:my_app/common/phone/phone_page_view.dart:63:5) // this was clickable
#1 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4711:57)
#2 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4548:5)
#3 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3611:14)
#4 Element.updateChild (package:flutter/src/widgets/framework.dart:3360:20)
...
Run Code Online (Sandbox Code Playgroud)
在网络上:
======== Exception caught by widgets library =======================================================
The following message was thrown building PhoneSignUpPage(state: _PhoneSignUpPageState#fb057):
some …
Run Code Online (Sandbox Code Playgroud) 我想更新这样的文档:
db.collection('users').doc(user_id).update({foo:'bar'})
Run Code Online (Sandbox Code Playgroud)
但是,如果doc user_id不存在,则上面的代码将引发错误.因此,如果不存在,如何告诉Firestore创建学生,换句话说,行为如下:
db.collection('users').doc(user_id).set({foo:'bar'})
Run Code Online (Sandbox Code Playgroud) 我发现使用AngularFireAuthModule
from '@angular/fire/auth';
会导致内存泄漏,导致 20 小时后浏览器崩溃。
版本:
我使用今天更新的最新版本,对所有软件包使用 ncu -u。
角火: "@angular/fire": "^5.2.3",
Firebase 版本: "firebase": "^7.5.0"
,
如何重现:
我在StackBliztz 编辑器上做了一个最小的可重现代码
这里是直接测试bug的链接StackBlizt test
症状:
您可以自己检查代码是否没有任何作用。它只是打印 hello world。但是,Angular App 使用的 JavaScript 内存增加了11 kb/s(Chrome 任务管理器 CRTL+ESC)。打开浏览器 10 小时后,使用的内存达到约800 mb(内存占用量约为1.6 Gb 的两倍!)
结果,浏览器内存不足,chrome 选项卡崩溃。
在性能选项卡下使用chrome的内存分析进一步调查后,我清楚地注意到侦听器的数量每秒增加2个,因此JS堆相应增加。
导致内存泄漏的代码:
我发现使用该AngularFireAuthModule
模块会导致内存泄漏,无论是在component
构造函数中还是在service
.
import { Component } from '@angular/core';
import {AngularFireAuth} from '@angular/fire/auth';
import {AngularFirestore} from '@angular/fire/firestore';
@Component({
selector: 'app-root',
templateUrl: …
Run Code Online (Sandbox Code Playgroud) Dart、Kotlin 和 Swift 有一个延迟初始化关键字,主要出于可维护性的原因,可以让您避免使用可选类型。
// Using null safety:
class Coffee {
late String _temperature;
void heat() { _temperature = 'hot'; }
void chill() { _temperature = 'iced'; }
String serve() => _temperature + ' coffee';
}
Run Code Online (Sandbox Code Playgroud)
TypeScript 有什么等价物?
null initialization lazy-initialization typescript option-type
在Javascript中,我将使用传播运算符:
现在我对Flutter遇到了同样的问题:
Widget build(BuildContext context) {
return Column(
children: <Widget>[
MyHeader(),
_buildListOfWidgetForBody(), // <- how to spread this <Widget>[] ????
MyCustomFooter(),
],
);
}
Run Code Online (Sandbox Code Playgroud) 在Python 3.7 int(x-1) == x
是 True
对于x = 5e+17
为什么会这样?我如何防止这种错误?
要进行复制,请将其粘贴到您的Python控制台中:
int(5e+17-1) == 5e+17
>True
Run Code Online (Sandbox Code Playgroud)
(我正在使用,int
因为x是除法的结果,我需要将其解析为int。)
在开发 Flutter 应用程序时 - 我最感兴趣的是我创建的日志消息print()
- 在本例中调用记录器I/flutter
(图中的第 4 行)。
但我收到了许多其他记录器的垃圾邮件,如下所示。
除了关闭和打开之外,是否有一种简单的方法可以打开所有其他记录器I/flutter
?
我用最少的代码在StackBlitz上重现了这个问题。
第一步:点击文字
第 2 步:专注于文本字段
第 3 步:输入 Enter 并检查控制台是否有此错误
错误:ExpressionChangedAfterItHasBeenCheckedError:检查后表达式已更改。以前的值:'ng-untouched: true'。当前值:'ng-untouched:false'。
我有一个创建缓存的任务
- task: Cache@2
inputs:
key: 'sonarCache'
path: $(SONAR_CACHE)
cacheHitVar: CACHE_RESTORED
displayName: Cache Sonar packages
Run Code Online (Sandbox Code Playgroud)
但是,缓存已损坏。那么我如何运行这个管道,同时告诉它忽略任何现有的缓存?
由于某种原因,我无法更改缓存键sonarCache
pipeline azure azure-devops azure-pipelines azure-pipelines-yaml
flutter ×4
dart ×3
angular ×2
firebase ×2
angularfire ×1
azure ×1
azure-devops ×1
flutter-web ×1
node.js ×1
null ×1
option-type ×1
pipeline ×1
python ×1
typescript ×1