我一直在寻找一些时间来获取和如何将新的硬件配置文件导入Android Studio,或手动构建新的硬件配置文件,但一直没有成功.有人能指出我允许我这样做的资源吗?具体来说,我在Android Studio中讨论这个领域.
我正在使用 flutter 完成许多关于 bloc 的教程,但遇到了一些不一致的情况。
我正在使用 Android studio 并使用 Intellij v1.6.0 的插件创建块代码。
对于 bloc_event,我继续看到类似这样的示例。
@immutable
abstract class FruitEvent extends Equatable {
FruitEvent([List props = const []]) : super(props);
}
Run Code Online (Sandbox Code Playgroud)
当我生成 bloc 文件并查看生成的初始 _event 文件时,它看起来像这样。
@immutable
abstract class SongEvent extends Equatable {
const SongEvent();
}
Run Code Online (Sandbox Code Playgroud)
如果我修改生成的代码以包含以下内容...
[List props = const []]) : super(props)
Run Code Online (Sandbox Code Playgroud)
然后我收到以下错误“位置参数太多,预期 0 个,找到 1 个”,该错误引用了上面显示的行末尾的 props。
如果我保留由 bloc 插件生成的代码,然后尝试通过添加以下内容来实现我的事件...
class AddSong extends SongEvent {}
Run Code Online (Sandbox Code Playgroud)
然后我收到错误“缺少‘getter Equatable.props’的具体实现”
这是我当前的 bloc/song_event.dart
import 'package:equatable/equatable.dart';
import 'package:meta/meta.dart';
@immutable
abstract class SongEvent extends Equatable …Run Code Online (Sandbox Code Playgroud) 更新 我已经构建了一个小示例并将所有代码添加到这篇文章中。我必须相信对此有答案/解释,并希望有人能告诉我我所缺少的东西。类型对象的类字段没有被转换,我不明白为什么。
这是我正在使用的模型类。
import 'package:json_annotation/json_annotation.dart';
part 'parent.g.dart';
@JsonSerializable()
class Parent {
int id;
final String name;
final int age;
List<Child> children;
Job job;
Parent({this.name, this.age, this.children, this.job});
factory Parent.fromJson(Map<String, dynamic> json) => _$ParentFromJson(json);
Map<String, dynamic> toJson() => _$ParentToJson(this);
}
@JsonSerializable()
class Child{
int id;
final String name;
final int age;
Child({this.name, this.age});
factory Child.fromJson(Map<String, dynamic> json) => _$ChildFromJson(json);
Map<String, dynamic> toJson() => _$ChildToJson(this);
}
@JsonSerializable()
class Job{
int id;
String title;
Job({this.title});
factory Job.fromJson(Map<String, dynamic> json) => _$JobFromJson(json);
Map<String, dynamic> …Run Code Online (Sandbox Code Playgroud) 我想通过输入到搜索字段中的文本过滤列表视图。在线和本网站上有许多示例,但所有示例都在一个有状态的小部件中过度简化和/或看起来有点混乱,可能不是构建事物的最佳方式。我有一个简单的应用程序,它使用 Provider、一个模型类 (Dog) 和一个 Dogs 类,其中包含我正在使用的列表。
目标:按输入的文本过滤狗列表。
狗模型
class Dog {
final String breed;
final String name;
final int age;
Dog({this.breed, this.name, this.age});
}
Run Code Online (Sandbox Code Playgroud)
狗类
import 'package:flutter/cupertino.dart';
import 'dart:collection';
import '../models/dog.dart';
class Dogs extends ChangeNotifier {
final List<Dog> _myDogs = [
Dog(name: 'Mackie', age: 8, breed: 'Rottweiler'),
Dog(name: 'Riley', age: 8, breed: 'Rottweiler'),
Dog(name: 'Tank', age: 7, breed: 'Mastiff'),
Dog(name: 'Tanner', age: 7, breed: 'Mastiff'),
Dog(name: 'Rocky', age: 10, breed: 'Rottweiler'),
Dog(name: 'Angel', age: 11, breed: 'Poodle'),
Dog(name: 'Roxie', age: …Run Code Online (Sandbox Code Playgroud)