小编Ari*_*old的帖子

Please help me understand fromMap and toMap from this code?

I got this code from the internet and I can not seem to understand it or find anything on the internet for it.

In the code below toMap is a method that returns 2 items, How is that possible?

fromMap 是什么,它是用户创建的方法吗?我认为方法使用了 {} 或 => 所以它有点令人困惑。

另外,地图的关键是什么?地图只能存储2类物品吗?一是关键,二是价值。或者它可以有一个键但有多个类别的值。

例如,可能有一个唯一的键,它可以帮助取出任务标题、时间、提醒数据、注释等作为地图的值。

class Task {
  String title;
  bool completed;

  Task({
    this.title,
    this.completed = false,
  });

  Task.fromMap(Map<String, dynamic> map): title = map['title'],completed = map['completed'];

  updateTitle(title) {
    this.title = title;
  }

  Map toMap() {
    return {
      'title': …
Run Code Online (Sandbox Code Playgroud)

dart flutter

8
推荐指数
2
解决办法
1万
查看次数

标签 统计

dart ×1

flutter ×1