supabase-flutter icon indicating copy to clipboard operation
supabase-flutter copied to clipboard

feat: Use cupertino http and websocket implementation

Open Vinzent03 opened this issue 7 months ago • 2 comments

What kind of change does this PR introduce?

feature

What is the current behavior?

Uses the implementation from dart:io for http.Client and WebSocketChannel.

What is the new behavior?

Use the classes provided by cupertino_http.

Additional context

I do not own a mac, so I cannot test this. So we can hopefully find a person to verify this actually works on iOS and macOS.

close #147

Vinzent03 avatar Mar 31 '25 20:03 Vinzent03

Pull Request Test Coverage Report for Build 16503910463

Details

  • 4 of 10 (40.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.1%) to 80.503%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/supabase/lib/src/supabase_client_options.dart 1 7 14.29%
<!-- Total: 4 10
Totals Coverage Status
Change from base Build 16305074338: -0.1%
Covered Lines: 3105
Relevant Lines: 3857

💛 - Coveralls

coveralls avatar Mar 31 '25 20:03 coveralls

@Vinzent03 we should make sure we run CI also on macOS, and test the package at least in a iOS build, just saw that we don't to that.

I created an issue for tracking that, https://github.com/supabase/supabase-flutter/issues/1146 feel free to pick it if you want, otherwise I can work on it later.

grdsdev avatar Mar 31 '25 21:03 grdsdev

I'm pretty sure to verify the behavior of the cupertino http client we can't just run the existing ci on a macos build in ci. For iOS we need flutter integration tests to actually run them on a iOS simulator. For macOS I'm unsure if the cupertino http client works if we run widget tests or actually need integratino tests as well. So we would need to write many additional tests sa well.

Vinzent03 avatar Apr 01 '25 14:04 Vinzent03

I see there is an examples folder in https://github.com/supabase/supabase-flutter/tree/main/packages/supabase_flutter/example

Probably just getting all these examples built in CI, would already solve the issue with checking if the library works on all available platforms.

grdsdev avatar May 02 '25 09:05 grdsdev

Hey @Vinzent03 I just merged a few changes to CI, including builds on the macOS runner, can you rebase this PR?

grdsdev avatar May 05 '25 12:05 grdsdev

I think I could get this pr working, but (with the weird error on macos now as well) I'm unsure we really want this pr to land. I think one huge benefit of the supabase packages is the lack of native dependencies, unlike firebase. So the building is a lot let stressful. We already see some supabase unrelated issues because of app_links and its native part.

Since one can already replace the http client, I think it's a better and more composable implementation to allow a custom websocket client in supabase and supabase_flutter to be passed to realtime_client. And publish a guide on how to provide the native http clients. This also means less depencency managment for us. This way the first experience is easier with no native dependency stress, but if a user wants the native clients they can easily add them. What do you think @dshukertjr @DanMossa

Vinzent03 avatar May 27 '25 18:05 Vinzent03

Big fan of just writing a quick example for others to use.

DanMossa avatar May 27 '25 19:05 DanMossa

+1 on Dan here.

dshukertjr avatar Jun 10 '25 02:06 dshukertjr

@dshukertjr Do we want the documentation on how to integrate the cupertino/cronet http/websocket clients in the readme or on the docs website with a link to that in the readme?

The required changes I would note are:

  • Additional packages in the readme
  • Conditional import
  • The platform_http_io.dart file
  • The platform_http_web.dart file
  • The proper initialization of supabase with the methods from these files

Vinzent03 avatar Jun 12 '25 21:06 Vinzent03

We should also double check that the following problem is resolved: https://github.com/supabase/supabase-flutter/issues/1149

DanMossa avatar Jul 02 '25 17:07 DanMossa

@DanMossa Thanks for the reminder. I now tried to reproduce your issue and you were right. Somehow, that http client has a problem with lowercase http methods.

Vinzent03 avatar Jul 18 '25 00:07 Vinzent03

Despite the actual documentation with easy copy-paste solution, this pr is ready. @dshukertjr Would still like to hear your opinion on this comment: https://github.com/supabase/supabase-flutter/pull/1145#issuecomment-2968149173

Vinzent03 avatar Jul 24 '25 17:07 Vinzent03