Notification在Android O中发送时,我必须指定NotificationChannel要发送到.
如果我使用这样的旧方法(不设置任何通道)NotificationCompat.Builder(this),Notification则不会显示.
这同样适用于这样一个无效的信道NotificationCompat.Builder(this, "invalid")或NotificationCompat.Builder(this, "").
当我通过Firebase Cloud Messaging发送通知并且我的应用程序在后台没有指定通知通道时,它将是"其他"通道中的通知.
当我尝试在上面提到的前景中做同样的事情时,这将不起作用,也不会创建名为"Miscellaneous"和id "{package} .MISCELLANEOUS"的通知通道,然后通过它发送.当我这样做时会发生以下情况:
如何在没有像FCM这样的频道的情况下发送通知,那么它是否会进入常规的"杂项"频道?
正如我上面提到的,它发生在FCM通知中,但例如Gmail也使用杂项频道.那我该怎么用呢?
我相信如果它通常无法使用,他们会删除杂项频道.
为什么此代码未向"其他"通知渠道发送通知,实际上并未发送任何通知(仅在Android O上,代码适用于较低的Android版本).
(getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).notify(1, NotificationCompat.Builder(this, NotificationChannel.DEFAULT_CHANNEL_ID)
.setSmallIcon(R.drawable.small_icon)
.setContentTitle(URLDecoder.decode("Title", "UTF-8"))
.setContentText(URLDecoder.decode("Text", "UTF-8"))
.setColor(ContextCompat.getColor(applicationContext, R.color.color))
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setContentIntent(PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT))
.build())
Run Code Online (Sandbox Code Playgroud) 我有一个屏幕,其中包含一个Form带有StreamBuilder. 当我从 加载初始数据时StreamBuilder,TextFormField按预期显示数据。
当我点击 内部时TextFormField,软件键盘会出现,这会导致小部件重建。当键盘再次按下时,同样的情况再次发生。
不幸的是,StreamBuilder再次订阅了并且文本框值被替换为初始值。
这是我的代码:
@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: _bloc.inputObservable(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return TextFormField(
// ...
);
}
return const Center(
child: CircularProgressIndicator(),
);
},
);
}
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
此屏幕是一个抽屉屏幕,它采用身份验证块,以便为用户提供信息并使其能够注销。虽然我使用了正确的提供程序,但我收到了这个错误
The following ProviderNotFoundError was thrown building Pets4allDrawer(dirty):
I/flutter (32011): Error: Could not find the correct Provider<AuthService> above this Pets4allDrawer Widget
I/flutter (32011): To fix, please:
I/flutter (32011): * Ensure the Provider<AuthService> is an ancestor to this Pets4allDrawer Widget
I/flutter (32011): * Provide types to Provider<AuthService>
I/flutter (32011): * Provide types to Consumer<AuthService>
I/flutter (32011): * Provide types to Provider.of<AuthService>()
I/flutter (32011): * Ensure the correct `context` is being used.
Run Code Online (Sandbox Code Playgroud)
我想知道为什么使用 Provider.of(context) 不起作用的问题,调用它时找不到它。
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:pets4all/blocs/authBloc.dart';
import …Run Code Online (Sandbox Code Playgroud) 我对 Dart 很陌生,如果我没有看到这部分,请原谅。
我想为函数输入创建一个联合类型。在 TS 中,这将是:
let variableInput: string | number
Run Code Online (Sandbox Code Playgroud)
typedef 并没有真正定义类型,但函数和枚举也没有真正的帮助。
另一方面,当函数返回两种类型中的一种或另一种时,它应该是什么样子?这里一定有什么我没看到的东西。
我意识到仍然可以调用新的Callable Cloud Functions,就像它们是HTTP事件一样,即它们仍然可以在下面进行调用http://us-central1-$projectname.cloudfunctions.net/$functionname.这样做时,我在云功能日志中收到错误消息:
Request has invalid method. GET
Run Code Online (Sandbox Code Playgroud)
这意味着HTTP-GET不起作用,但有没有办法调用这些函数?也许他们正在使用HTTP-CONNECT.
我可以使用以下示例绘制半圆: Flutter how to draw semicircle (half circle)
但是,该Paint对象似乎只接受 a Color(using Paint.color)。我想添加一个RadialGradient或LinearGradient作为Color. 那可能吗?
我正在尝试使用基本的Textfields在这里构建一个简单的登录屏幕,但我无法让键盘出现在模拟器中.
通过物理键盘输入工作正常,但在iOS模拟器中没有键盘可见.我是否必须明确地打开它或什么?
感觉就像我在这里遗漏了一些非常基本的东西.
buildLoginScreen() {
return new Container(
padding: EdgeInsets.only(left: 50.0, right: 50.0),
child: new Column(
children: <Widget>[
new TextField(
style: new TextStyle(color: Colors.white),
autofocus: true,
autocorrect: false,
decoration: new InputDecoration(
labelText: 'Login',
),
onChanged: (text) { _userLoginEmail = text; },
),
new TextField(
autofocus: false,
autocorrect: false,
obscureText: true,
decoration: new InputDecoration(
labelText: 'Password'
),
onChanged: (text) { _userLoginPassword = text; },
)
],
),
);
}
Run Code Online (Sandbox Code Playgroud)
解决方案 如果硬件键盘已连接,则会抑制软键盘.cmd + shift + k断开硬件键盘或cmd + k切换软件键盘.
因此,在我的 flutter 应用程序中,我创建 TextFormField 用作输入,如下所示(并将其返回到脚手架中):
final password = TextFormField(
controller: passController,
autofocus: false,
obscureText: true,
decoration: InputDecoration(hintText: 'Password'),
style: new TextStyle(color: Colors.orange),
);
Run Code Online (Sandbox Code Playgroud)
我想更改stylea 内的属性themeData,但找不到要指定的属性。
我能找到的最接近的一个是textTheme: new TextTheme(body1: new TextStyle(color: Colors.orange)),但是这个对我的 TextFormField 没有任何作用。
如何设置 TextFormField 样式?请帮忙,我对 Dart 和编程都很陌生。我现在 13 岁,没有人能帮我解决这些事情。
PS:如果需要,完整的代码位于 GitHub 上: https: //github.com/Legolaszstudio/novynotifier