我如何访问变量?

How I can acess to varibles?

我尝试使用@frezzed 技术。在我使用 DB-firbase 的 flutter 项目中。

如何访问 class 变量进行操作?

import 'package:freezed_annotation/freezed_annotation.dart';
part 'Person.freezed.dart';

@freezed
class Person with _$Person {
  const Person._(); // Added constructor
  const factory Person(String name, {int? age}) = _Person;
  const factory Person.manager(String? ttt) = Manager;
  
  void method() {
    print('hello world');
    Person p = Person("name");
    p.  
  }
}
@freezed
class Person with _$Person {
  factory Person({ String? name, int? age }) = _Person;
}

然后允许你写:

var person = Person(name: 'Remi', age: 24);
print(person.name); // Remi
print(person.age); // 24

来源 - freezed docs