Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for Dependencies update #54

Closed
sesha-codeprism opened this issue Mar 4, 2021 · 12 comments
Closed

Request for Dependencies update #54

sesha-codeprism opened this issue Mar 4, 2021 · 12 comments
Assignees

Comments

@sesha-codeprism
Copy link

Can the dependencies for the project be updated?

Flutter 2.0 for Stable channel has been released and many packages have been updated to null safety versions. This package has dependency on http and updating http package requires updating http_interceptor, so version solving fails.
But, firebase_core depends on http latest version so that can't be updated either.

This package is mandatory for my project's implementation, so cannot remove it but now it's preventing me from updating any other packages, mainly firebase packages.

So any chance for the dependencies to be updated?

@CodingAleCR
Copy link
Owner

Yes, I will update them today and give you an update.

@CodingAleCR
Copy link
Owner

Hi, just an update. Since version 0.13.0 of http includes a couple of breaking changes I have to change a bit the way the interceptors work so... The bad news is that it'll take me a bit more, but the good news is that I can have it ready by Saturday without faults.

I apologize for the inconveniences this may be causing to your work or anyone else's. 🙏🏼😔

@p0wl90
Copy link

p0wl90 commented Mar 5, 2021

Thanks, that's great news (and also fast in my opinion)! Do you also plan on migrating to null-safety soon?

@sesha-codeprism
Copy link
Author

No problem at all mate, you can take your time and do it at your convenience. No inconvenience as such, it's just that I can't update to latest packages, that's all.

You want/need more time, I'm a-okay with it.

Will be waiting for the update..Thanks a lot for the hard work mate!

@CodingAleCR
Copy link
Owner

Thanks, that's great news (and also fast in my opinion)! Do you also plan on migrating to null-safety soon?

Yes, the update will include null safety and hopefully proper web support.

@basti1253
Copy link

Hi there,

first of all thank you very much for all the time you've spent on creating and maintaining this lib.

I've forked and updated your code base to sound null safety. I've made quite a few changes so I don't know if you like my approach. E.g. I've replaced effective_dart by pedantic and dropped support for using Strings as URIs as there's no union type in dart.

If you want me to create a PR, just give me a ping. It's still utterly untested, but I'll include it within my app by tomorrow and update that to sound null safety as well.

You could try it yourself by changing your pubspec like this:

  http_interceptor:
    git:
      url: https://github.com/basti1253/http_interceptor
      ref: master

This repository hopefully won't exist very long, so don't rely on it ;)

kind regards and all the best

Sebastian

@CodingAleCR
Copy link
Owner

You're the best haha. Although I already have a local branch done as well, just testing it out to avoid adding breaking changes. Thanks a lot Sebastian and I will definitely check it out to see if there's something I missed that you already have.

Also, this weekend I've reflected upon the future of the plugin, I will release stable 1.0.0 really soon but it will include a couple of breaking changes so I'm trying to set out the foundations for that side. I'm happy that you took interest and will reach out once I'm done if you want to check it out.

@CodingAleCR
Copy link
Owner

Hi, this should be solved once 0.4.0 is published, please take a look at the migration guide in order to fix any issues caused by the update. Here's the PR with the changes as well if you are curious as well: #57

@basti1253
Copy link

basti1253 commented Mar 9, 2021

Nice! Thank you very mich for the update!
May I suggest a slight change in the code base? As a consumer of the library it'd be easier if RequestData params and headers are not nullable.

like:

 class RequestData {
   Method method;
   String baseUrl;
-  Map<String, String>? headers;
-  Map<String, String>? params;
+  Map<String, String> headers;
+  Map<String, String> params;
   dynamic? body;
   Encoding? encoding;
 
   RequestData({
     required this.method,
     required this.baseUrl,
-    this.headers,
-    this.params,
+    Map<String, String>? headers,
+    Map<String, String>? params,
     this.body,
     this.encoding,
-  });
+  })  : headers = headers ?? {},
+        params = params ?? {};
 
   String get url => buildUrlString(baseUrl, params);
 
@@ -45,7 +46,7 @@ class RequestData {
 
     Request request = new Request(methodToString(method), reqUrl.toUri());
 
-    if (headers != null) request.headers.addAll(headers!);
+    request.headers.addAll(headers);

Just a little more comfort as the consumer doesn't need to initialize headers/params.

At the moment my request interceptor looks like this:

  @override
  Future<RequestData> interceptRequest({
    required RequestData data,
  }) async {
    var jwt = await this.getToken();
    if (jwt.isEmpty) {
      throw UnauthorizedException('no token found');
    }
    data.headers = data.headers ?? {};
    data.headers!['Authorization'] = 'Bearer $jwt';
    return data;
  }

@CodingAleCR
Copy link
Owner

Yes, that makes complete sense and I probably missed it while migrating to null safety, will send a patch release soon 😉

@basti1253
Copy link

Thank you :)

@CodingAleCR
Copy link
Owner

You are very welcome. Let me know if there's other ideas you might have or needs you think we could cover with the library. Also, feel free to checkout our roadmap 🙌🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants