我创建了一个简单的流,添加了一些元素并监听这个流。但是当我在流上使用地图时,有一个问题。为了简单起见,我只是将值映射到相同的值(我想?)。 当我尝试运行这个程序时,我得到了一个map-error: Uncaught Error: TypeError: Instance of '_MapStream<String, dynamic>': type '_MapStream<String, dynamic>' is not a subtype of type 'Stream<String>' import '
我正在尝试使用Flutter & Firebase构建一个聊天应用程序,我从Github获取了以下代码,并在我的项目中使用了它。在Flutter的早期版本上,它是有效的,在2.0上,它显示了以下错误:The argument type 'StreamTransformer<dynamic, dynamic>' can't be assigned to the parameter type 'StreamTransformer<QuerySnapshot, List<Message>>'
该错误由以下行触发:
.
我正在尝试使用StreamTransformer为InputElement字段应用Dart 2.18.2。我正在经历以下错误:
变压器错误:
Line 18: The argument type 'StreamTransformer<Object?, Object?>' can't be assigned to the parameter type 'StreamTransformer<String?, dynamic>'.
零安全错误:
Line 8: The method 'contains' can'
我正在写一个带有go API的Bloc架构的flutter应用程序,在我检索到用户名和密码是否有效的结果后,当我按下登录按钮时,我会遇到一些问题。如果是错误,我将返回文本“错误用户名和密码无效”。
对不起,我的英语不好。
//my bloc.dart login
class Bloc extends Validators {
final _email = BehaviorSubject<String>();
final _password = BehaviorSubject<String>();
//add to the stram
Stream&
当我尝试从StreamTransform获取一些数据时,我遇到了一些问题 我不能理解什么是正确的数据类型。 未捕获异常: TypeError: Instance of '_StreamHandlerTransformer':类型'_StreamHandlerTransformer‘不是类型'StreamTransformer,dynamic>’的子类型 import 'dart:async';
class Cake{}
class Order{
String type;
Order(this.type);
}
void mai
升级到DARTSDK2.5.0-稳定。运行pub global run webdev serve web:8081 --auto=refresh --release im后,出现严重错误。我知道在这个版本中引入了突破性的更改,但是在阅读了changelog之后,仍然不知道如何修复它。
[INFO] Building new asset graph completed, took 2.3s
[INFO] Checking for unexpected pre-existing outputs. completed, took 1ms
[INFO] Serving `web` on http://
我从一开始就使用,它并没有给我带来任何问题。我刚刚升级了我的颤音,在运行我的项目时,我得到了以下错误:
Compiler message:
file:///Users/alok/flutter/.pub-cache/hosted/pub.dartlang.org/geocoder-0.1.2/lib/services/d
istant_google.dart:38:56: Error: The argument type 'Utf8Decoder' can't be assigned to the
parameter type 'StreamTransforme
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:json_annotation/json_annotation.dart';
part 'http.g.dart';
@JsonSerializable()
class Album {
final int userId;
final int id;
final String title;
Album({this.userId, this.id, t
我不太确定如何表达,但我基本上想写一个这样的函数:
import 'dart:async';
int countBroadcastStreams(List<Stream<Object>> streams) {
return streams.where((s) => s.isBroadcast).length;
}
void main() {
final a = StreamController<int>.broadcast();
final b = StreamController<String>.broad
我已经实现了流转换器。请注意,这只是一个练习(为了学习Dart)。此转换器将整数转换为字符串。我给出了下面的代码,您也可以在上找到它。
// Conceptually, a transformer is simply a function from Stream to Stream that
// is encapsulated into a class.
//
// A transformer is made of:
// - A stream controller. The controller provides the "output" stream that will
我试图将所有与语言更改相关的逻辑集成到一个块中。我使用的是flutter_bloc包,它使我能够访问"BlocProvider“方法。然而,当我尝试扩展我的块时,我得到了一个错误。 下面是错误: Error: Type argument 'TranslationsBloc' doesn't conform to
the bound 'Bloc<dynamic, dynamic>' of the type variable 'T' on 'BlocProvider'. 代码如下: main.dart r
我有一个想要保存到本地存储的对象,但是每当我将该对象写入存储时,我都会得到标题中显示的错误。
这是完整的堆栈跟踪
[VERBOSE-2:ui_dart_state.cc(198)] Unhandled Exception: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'Map<String, double>' in type cast
#0 new Product.fromJson (package:app/src/objects
我对flutter+dart框架非常陌生。我正在努力理解EventChannel是如何工作的。我已经设置了EventChannel来捕获来电号码。
在android方面,我已经设置了一个BroadcastReceiver,如下所示。
public class CallEventHandler extends BroadcastReceiver implements EventChannel.StreamHandler {
private static final String TAG = "[SAMPLE]";
private static final int NUMBER_L
我使用颤振http请求从服务器获取数据,并在用户滚动到屏幕底部时加载更多数据。我收到这个错误“未处理的异常:类型'List‘不是’Product‘’的一个子类型”。请帮帮忙,我整天都在挣扎,但没有成功。
model.dart文件
class Product {
final int id;
final String accountName,
callNumber,
whatsappNumber,
businessLocation,
caption;
final List<Images> productPhoto;
我对Dart很陌生,我试图获得一个类来实现List,使用答案,并尝试使用docs 对这些对象的列表进行排序。为了发布MWE,我删除了大部分代码:
import 'dart:collection';
class Transaction<E> extends ListBase<E>{
DateTime when;
Transaction(this.when);
List innerList = new List();
int get length => innerList.length;
void set le
import 'package:http/http.dart' as http;
class Album {
final int userId;
final int id;
final String title;
Album({this.userId, this.id, this.title});
factory Album.fromJson(Map<String, dynamic> json) {
return Album(
userId: json['userId'],
id: json[
我不确定我是否没有正确理解这一点,但这是我的代码。我试图让StreamTransformer作用于流,但值仍然原封不动地从另一端传出。注意:我添加了.map()函数,它什么也不做,只是为了确保我的问题不是缺少map函数。我把它留在这里以防万一。
import 'dart:async';
void main() {
int count = 0;
var counterController = new StreamController();
counterController.stream.listen((value) => print(value));
voi
在Dart中有检测dynamic类型的方法吗?
我有以下方法:
Stream<T> on<T>() {
if (T is dynamic) { // <-- Is always true
// Return the dynamic Stream.
} else {
// Return the Stream that was cast to Stream<T>.
}
}
我想知道用户是否使用类型参数调用方法on。因此,我想区分对myClass.on()和myClass<MyType>.on()的调用。
这在Dart
我使用以下省道包(json_annotation、json_serializable、build_runner)来根据这个序列化/反序列化json。
这是我的密码:
import 'package:json_annotation/json_annotation.dart';
part 'car_type.g.dart';
@JsonSerializable()
class CarType {
final int id;
@JsonKey(name: 'type_label')
final String label;
fi
我的json序列化有一些问题,我使用json_serializable: ^6.2.0,所以我的代码是:
shift.dart
import 'package:hive/hive.dart';
import 'package:json_annotation/json_annotation.dart';
part 'shift.g.dart';
@HiveType(typeId: 1)
@JsonSerializable()
class Shift extends HiveObject {
@HiveField(0)
final Dat