flutterdata / flutter_data

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

🌐 Saving remotely is not working anymore since 2.0.0 #273

Open musiolmarco opened 6 months ago

musiolmarco commented 6 months ago

Hey @frank06, I am not sure if you are already aware of it, but somehow remote saving is not working for me anymore since 2.0.0:

I am trying it like this (which worked before, so I assume it's a new version issue):

ElevatedButton(
            onPressed: () async {
              await Album(
                userId: 32,
                title: 'Test',
              ).save();
            },
            child: const Text(
              'Add new one',
            ),
          ),

But I always get an exception:

flutter: 24:890 [save/albums@7769878993] DataException: ClientException: HTTP request failed. Client is already closed., uri=http://localhost:8088/api/albums http://localhost:8088/api/albums#0      IOClient.send (package:http/src/io_client.dart:110:7)
#1      _RemoteAdapter.sendRequest (package:flutter_data/src/adapter/remote_adapter.dart:377:39)
<asynchronous suspension>
#2      _RemoteAdapter.save (package:flutter_data/src/adapter/remote_adapter.dart:220:20)
<asynchronous suspension>
#3      DataModelExtension.save (package:flutter_data/src/model/data_model.dart:74:12)
<asynchronous suspension>
#4      HomePage.build.<anonymous closure> (package:new_flutter_data_example/core/presentation/pages/home_page.dart:35:15)
<asynchronous suspension>
musiolmarco commented 6 months ago

Please correct me if I am wrong and if I missed something, but I think everything is implemented as documented. :)

frank06 commented 6 months ago

Thanks for reporting, please note that 2.0 has not been released and far from stable. You should probably be using 1.6.0 until 2.0 comes out

musiolmarco commented 6 months ago

Thanks for reporting, please note that 2.0 has not been released and far from stable. You should probably be using 1.6.0 until 2.0 comes out

All right, no problem.

I think I'll downgrade to the stable version then. Still Thanks for your work and I'm really looking forward to 2.0.0! 🙌

LennyLip commented 1 month ago

currently master branch (I need sqlite)

Screenshot 2024-09-26 105401 Screenshot 2024-09-26 105404 watchOne not fire remote request. Last log is: flutter: 46:149 [watchOne/users##1@4277816743] initializing (and also watching: tasks)

LennyLip commented 1 month ago

watchOne not fire remote request.

sorry, fixed with "remote: true,"

    final state = ref.users.watchOne(
      1, // user ID, an integer
      remote: true,
      params: {'_embed': 'tasks'}, // HTTP param
      alsoWatch: (user) => [user.tasks], // watcher
    );