1

I follow the Amplify tutorial to make a todo app and got this error in return on the fist run anyone know why ? I have read another similar question on Stackoverflow but it didn't solve the problem for me so is there any other way. enter image description here

user18309290
  • 5,777
  • 2
  • 4
  • 22
Ken
  • 57
  • 6
  • Take a look at how to initialize Amplify: https://docs.amplify.aws/lib/project-setup/create-application/q/platform/flutter/#4-initialize-amplify-in-the-application. – user18309290 Oct 01 '22 at 05:27
  • Thank you for your answer, it didn't gave out the error but I got some thing wrong in the console. There is one that said: "E/SurfaceSyncer( 5435): Failed to find sync for id=0" and one that said "W/Parcel ( 5435): Expecting binder but got null!". Do you know why – Ken Oct 02 '22 at 08:33

1 Answers1

1

The problem of your code is that it starts to use the DataStore without first initializing it.

The DataStore works as a plugin of the whole Amplify Flutter framework. So besides creating one DataStore plugin which you have done at line:47 of your code, you still have to plug the plugin to Amplify.

The solution is to move the creation of DataStore plugin into initState then add few more lines of code after that.

void initState(){

  // Your code of creating plugin
  final _dataStorePlugin = AmplifyDataStore(modelProvider: ModelProvide.instance)

  // add Amplify plugins
  Amplify.addPlugins([_dataStorePlugin]).then((_) {

    // configure Amplify
    //
    // note that Amplify cannot be configured more than once!
    return Amplify.configure(amplifyconfig);
});

}

Or follow the tutorial here

ColaFanta
  • 1,010
  • 2
  • 8
  • Thank you for your answer, it didn't gave out the error but I got some thing wrong in the console. There is one that said: "E/SurfaceSyncer( 5435): Failed to find sync for id=0" and one that said "W/Parcel ( 5435): Expecting binder but got null!". Do you know why – Ken Oct 02 '22 at 08:33
  • Seems that the Amplify didn’t find a backend to sync with. You can still use the offline mode and ignoring the error, or provision a backend with amplify. https://docs.amplify.aws/lib/datastore/sync/q/platform/flutter/ – ColaFanta Oct 04 '22 at 03:58