hurshi / dio-http-cache

http cache lib for Flutter dio like RxCache
Apache License 2.0
274 stars 223 forks source link

Migrating to null safety AND android embedding v2 #81

Open shinayser opened 3 years ago

shinayser commented 3 years ago

Migrating the app to null safety (flutter 2.0). Also done the migration of the sample app to Android Embedding v2.

Tiska commented 3 years ago

Hi, in store_meromy.dart, you init an empty list : if (null == subKeyList) subKeyList = List.empty();

Empty list are not growable by default, the next line a add is made on that list, so the code crach

shinayser commented 3 years ago

Hi, in store_meromy.dart, you init an empty list : if (null == subKeyList) subKeyList = List.empty();

Empty list are not growable by default, the next line a add is made on that list, so the code crach

Fixed!

qbait commented 3 years ago

Getting that error when trying to run the app with this PR's version of dio-http-cache

../../.pub-cache/git/dio-http-cache-b68b588030a403b17ffcaef011006e71d89fe84c/lib/src/manager_dio.dart:36:22: Error: The argument type 'dynamic Function(RequestOptions)' can't be assigned to the parameter type 'void Function(RequestOptions, RequestInterceptorHandler)?'.
 - 'RequestOptions' is from 'package:dio/src/options.dart' ('../../.pub-cache/hosted/pub.dartlang.org/dio-4.0.0-prev1/lib/src/options.dart').
 - 'RequestInterceptorHandler' is from 'package:dio/src/interceptor.dart' ('../../.pub-cache/hosted/pub.dartlang.org/dio-4.0.0-prev1/lib/src/interceptor.dart').
          onRequest: _onRequest, onResponse: _onResponse, onError: _onError);

My initialization: dio.interceptors.add(DioCacheManager(CacheConfig(baseUrl: baseUrl)).interceptor);

My dependencies:

  dio: ^4.0.0-prev1
  dio_http_cache:
    git:
      url: git@github.com:shinayser/dio-http-cache.git
      ref: master
  retrofit: 2.0.0-beta1
  json_annotation: ^4.0.0
  json_serializable: ^4.0.3
  build_runner: ^1.11.1
  retrofit_generator: ^2.0.0-beta1
ghenry commented 3 years ago

Is this good for Flutter 2 as well which also incorporates #82 change of MD5 ?

andreystavitsky commented 3 years ago

Migrating the app to null safety (flutter 2.0). Also done the migration of the sample app to Android Embedding v2.

lib/src/store/store_disk.dart:32:23: Warning: Operand of null-aware operation '!' has type 'String' which excludes null. await Directory(path!).create(recursive: true);

andreystavitsky commented 3 years ago

dio: ^4.0.0-prev1

this PR compatible only with dio: 4.0.0-beta4

erickok commented 3 years ago

👋 Thanks for the work but I am a bit confused how how you got this working. The library is indeed technically updated to nullsafety but doesn't even compile as the dio 4 interceptor method signature changed. Did you forget to commit come changes, maybe?

SmarterVision commented 3 years ago

Hi, Would you please check the following errors

/C:/flutter/.pub-cache/git/dio-http-cache-b68b588030a403b17ffcaef011006e71d89fe84c/lib/src/store/store_disk.dart:32:23: Warning: Operand of null-aware operation '!' has type 'String' which excludes null.
      await Directory(path!).create(recursive: true);
                      ^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_cache_manager-3.0.0-nullsafety.1/lib/src/storage/cache_info_repositories/cache_object_provider.dart:208:29: Warning: Operand of null-aware operation '!' has type 'String' which excludes null.
    final oldDbPath = join((await getDatabasesPath())!, '$databaseName.db');
                            ^
shinayser commented 3 years ago

Guys I am on same boat as you... since the maintainer didn't provided a null safety version yet, I tried to do it myself. But seems that https://github.com/hurshi/dio-http-cache/pull/84 has done a work better than mine!