Skip to content

【SharedPreferencesELinux】Unable to save #90

@JGNS

Description

@JGNS

i run main.dart, always "Button tapped 1 time", when i restart App, it become "0 times".I just added some printing:

Future _incrementCounter() async {
final Map<String, Object> values = await prefs.getAll();
final int counter = (values['counter'] as int? ?? 0) + 1;
print('_incrementCounter:values:$values');
setState(() {
_counter = prefs.setValue('Int', 'counter', counter).then((bool success) {
print('_incrementCounter:success:$success');
return counter;
});
});
}

No matter how many times i click,output always:
_incrementCounter:values:{}
_incrementCounter:success:true
...

No error message is reported。
so,where might the problem occur?
Looking forward to your reply,
thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions