flutterdata / flutter_data

Seamlessly manage persistent data in your Flutter apps
MIT License
410 stars 31 forks source link

LOCAL SAVING #220

Closed meladam20 closed 1 year ago

meladam20 commented 1 year ago

Hello, after user registration, i want to user data to allow this iser to automatically login when he come back on application but my code doesn't work. the data are save locally but when i reload application with "hot reload" or "shift+cmd+F5", all data are delete. Help me please.

Here is my code :

final user = User(
    firstName: firstName.text,
    lastName: lastName.text,
    email: email.text,
    password: password.text);

final userRegistered = await user.save(onSuccess: (a, b, c) async {
  final isUser = await ref.users.findAll(
      params: {'email': email.text, 'password': password.text},
      syncLocal: true,
      remote: true);
  for (var user in isUser!) {
    user.saveLocal();
    print('isUser save');
  }
}
});
meladam20 commented 1 year ago

Hello @frank06 , can you help me please or someone else ?

frank06 commented 1 year ago

I have little time to answer here. For these kind of requests please use Discussions.

I never tried FD on web but here are some ideas:

Your use of onSuccess looks strange... not sure what are you doing with a, b and c. Simply await user.save and continue below.