-
Use the
late
keyword:class Foo { late int count; // No error void bar() => count = 0; }
-
Make variable nullable:
class Foo { int? count; // No error void bar() => count = 0; }
Non-nullable instance field must be initialized
最新推荐文章于 2024-11-08 16:14:48 发布