dio-http-cache icon indicating copy to clipboard operation
dio-http-cache copied to clipboard

Migrating to null safety AND android embedding v2

Open shinayser opened this issue 4 years ago • 9 comments

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

shinayser avatar Mar 03 '21 22:03 shinayser

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

Tiska avatar Mar 14 '21 16:03 Tiska

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!

shinayser avatar Mar 15 '21 16:03 shinayser

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: [email protected]: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

qbait avatar Mar 18 '21 22:03 qbait

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

ghenry avatar Mar 20 '21 21:03 ghenry

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 avatar Mar 22 '21 12:03 andreystavitsky

dio: ^4.0.0-prev1

this PR compatible only with dio: 4.0.0-beta4

andreystavitsky avatar Mar 22 '21 14:03 andreystavitsky

👋 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?

erickok avatar Mar 23 '21 08:03 erickok

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');
                            ^

SmarterVision avatar Mar 23 '21 20:03 SmarterVision

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!

shinayser avatar Mar 23 '21 21:03 shinayser