Skip to content

Serialize private field #537

Closed
Closed
@Nico04

Description

@Nico04

I am very surprised I can't serialize a basic private field, I guess it is by design because as soon as I make it public, it works well.

I have a quite basic use case.
I have a private field storing a global id count, used to generate local id of child objects.
So other object should have access to nextCatId or nextDogId but not _nextId.
And _nextId must be saved and loaded locally in my document-based dababase.

int _nextId = 0;
String get nextCatId => "c${nextId++}";
String get nextDogId => "h${nextId++}";

Any thoughts ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions