simolus3 / drift

Drift is an easy to use, reactive, typesafe persistence library for Dart & Flutter.
https://drift.simonbinder.eu/
MIT License
2.65k stars 371 forks source link

encrypted_moor many incompatible libraries #1039

Closed apoleo88 closed 3 years ago

apoleo88 commented 3 years ago

I am using:

  moor:
  encrypted_moor:
    git:
      url: https://github.com/simolus3/moor.git
      path: extras/encryption

I have tried many time to use the encrypted_moorlibrary, but everytime it gives me conflicts with other ones:

Because no versions of sqlite3 match >=0.1.9-nullsafety <0.1.9-nullsafety.0 and sqlite3 >=0.1.9-nullsafety.0 <0.1.10-nullsafety.0 depends on ffi ^0.2.0-nullsafety, sqlite3 >=0.1.9-nullsafety <0.1.10-nullsafety.0 requires ffi ^0.2.0-nullsafety.
And because sqlite3 >=0.1.10-nullsafety.0 depends on ffi ^0.3.0-nullsafety and path_provider_windows <0.1.0-nullsafety depends on ffi ^0.1.3, sqlite3 >=0.1.9-nullsafety is incompatible with path_provider_windows <0.1.0-nullsafety.
And because audioplayers 0.17.3 depends on path_provider ^1.6.22 which depends on path_provider_windows ^0.0.4, sqlite3 >=0.1.9-nullsafety is incompatible with audioplayers 0.17.3.
And because no versions of audioplayers match >0.17.3 <0.18.0 and moor >=4.0.0-nullsafety.1 depends on sqlite3 ^0.1.9-nullsafety, audioplayers ^0.17.3 is incompatible with moor >=4.0.0-nullsafety.1.
And because no versions of moor match >=4.0.0-nullsafety.0 <4.0.0-nullsafety.1 and every version of encrypted_moor from git depends on moor ^4.0.0-nullsafety.0, audioplayers ^0.17.3 is incompatible with encrypted_moor from git.
So, because _my app_ depends on both encrypted_moor from git and audioplayers ^0.17.3, version solving failed.
pub get failed (1; So, because _my app_ depends on both encrypted_moor from git and audioplayers ^0.17.3, version solving failed.)

Unfortunatly, it is not only with this audioplayers library, I already removed many others that were giving the same error, and I guess if I remove this one I will get another one. It seems incompatible with many audio libraries for some reason.

Any idea?

simolus3 commented 3 years ago

Can you add this to your pubspec and see if it helps at all?

dependencies: # if this doesn't work, try adding this to dependency_overrides
  path_provider: ^2.0.0-nullsafety

From my understanding, pub complains that some of your dependencies don't support the null safe versions of package:ffi, maybe you can ask the maintainers of audioplayers to support the 2.0.0 pre-release of path_provider. I can try to help more if you post a full pubspec.

apoleo88 commented 3 years ago

The error persists, tried both in dependenciesand in dependency_overrides Because audioplayers 0.17.3 depends on path_provider ^1.6.22 and no versions of audioplayers match >0.17.3 <0.18.0, audioplayers ^0.17.3 requires path_provider ^1.6.22. So, because yourapp depends on both path_provider ^2.0.0-nullsafety and audioplayers ^0.17.3, version solving failed. pub get failed (1; So, because yourapp depends on both path_provider ^2.0.0-nullsafety and audioplayers ^0.17.3, version solving failed.)

I tried with flutter_sound too, and the error is the same.


version: 1.0.0+1
publish_to: none

environment:
  sdk: ">=2.6.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_svg: ^0.18.1
  webview_flutter: ^0.3.0

  google_fonts: ^1.1.1
  flutter_bloc: ^6.1.1

  moor:
  encrypted_moor:
    git:
      url: https://github.com/simolus3/moor.git
      path: extras/encryption

  sqlite3_flutter_libs:
  sqflite: ^1.1.7 # Still used to obtain the database location

  path_provider: ^2.0.0-nullsafety
  path:
  provider: ^4.1.2

  shared_preferences:
#  flutter_sound_lite: ^7.6.2+6 #bugged and moor conflict
  audioplayers: ^0.17.3
  #audio_recorder: ^1.0.2 // It is not supported anymore
  record: ^1.0.2

  image_picker:
  multi_image_picker: ^4.6.5
  flutter_image_compress: ^0.7.0
  image: ^2.1.19

  local_auth: ^0.6.3+4
  permission_handler:
  ext_storage:

  rxdart: ^0.25.0
  charts_flutter: ^0.9.0

  timeago: ^2.0.26
  intl: ^0.16.1
  math_expressions: ^2.0.1

  firebase_core:
  firebase_ml_vision: ^0.9.9

  camera: ^0.5.8+2
  file_picker: ^2.0.0

  firebase_analytics: ^6.0.2
  firebase_database: ^4.3.0
  cloud_firestore: ^0.14.3+1
  firebase_messaging: ^7.0.2
  cloud_functions: ^0.6.0

  flutter_secure_storage: ^3.3.3
  cryptography: ^1.4.1

  flutter_archive: ^1.0.2
  archive: ^2.0.13
  flutter_local_notifications: ^3.0.2

  csv: ^4.0.3

  google_sign_in: ^4.5.1
  firebase_auth: ^0.18.0+1
  flutter_signin_button: ^1.0.0
  url_launcher: ^5.5.0
  uni_links: ^0.4.0

  video_player: ^0.10.12
  file: ^5.2.1

dependency_overrides:
  # extra for moor encryption on IOS
  sqflite:
    git:
      url: https://www.github.com/davidmartos96/sqflite_sqlcipher.git
      path: sqflite
      ref: fmdb_override

dev_dependencies:
  flutter_test:
    sdk: flutter

  moor_generator: # ^3.4.0
  build_runner: # ^1.10.2
simolus3 commented 3 years ago

On the latest flutter beta, this works for me:

dependencies:
  flutter:
    sdk: flutter
  flutter_svg: ^0.18.1
  webview_flutter: ^0.3.0

  google_fonts: ^1.1.1
  flutter_bloc: ^6.1.1

  moor:
  encrypted_moor:
    git:
      url: https://github.com/simolus3/moor.git
      path: extras/encryption

  sqlite3_flutter_libs:
  sqflite: ^1.1.7 # Still used to obtain the database location

  path_provider: ^2.0.0-nullsafety
  path:
  provider: ^4.1.2

  shared_preferences:
#  flutter_sound_lite: ^7.6.2+6 #bugged and moor conflict
  audioplayers: ^0.17.3
  #audio_recorder: ^1.0.2 // It is not supported anymore
  record: ^1.0.2

  image_picker:
  multi_image_picker: ^4.6.5
  flutter_image_compress: ^0.7.0
  image: ^2.1.19

  local_auth: ^0.6.3+4
  permission_handler:
  ext_storage:

  rxdart: ^0.25.0
  charts_flutter: ^0.9.0

  timeago: ^2.0.26
  intl: ^0.16.1
  math_expressions: ^2.0.1

  firebase_core:
  firebase_ml_vision: ^0.9.9

  camera: ^0.5.8+2
  file_picker: ^2.0.0

  firebase_analytics: ^6.0.2
  firebase_database: ^4.3.0
  cloud_firestore: ^0.14.3+1
  firebase_messaging: ^7.0.2
  cloud_functions: ^0.6.0

  flutter_secure_storage: ^3.3.3
  cryptography: ^1.4.1

  flutter_archive: ^1.0.2
  archive: ^2.0.13
  flutter_local_notifications: ^3.0.2

  csv: ^4.0.3

  google_sign_in: ^4.5.1
  firebase_auth: ^0.18.0+1
  flutter_signin_button: ^1.0.0
  url_launcher: ^5.5.0
  uni_links: ^0.4.0

  video_player: ^0.10.12
  file: ^6.0.0

dependency_overrides:
  path_provider: ^2.0.0-nullsafety
  # extra for moor encryption on IOS
  sqflite:
    git:
      url: https://www.github.com/davidmartos96/sqflite_sqlcipher.git
      path: sqflite
      ref: fmdb_override

dev_dependencies:
  flutter_test:
    sdk: flutter

  moor_generator: # ^3.4.0
  build_runner: # ^1.10.2
apoleo88 commented 3 years ago

Thank you for your help! This pubspec compiles with pug get, unfortunatly, there are too many breaking changes in the last beta about nullsafety and I can't build.

Many libraries did not migrate and I get too many errors. If I update one to nullsafety then I have to update the next one it depends on and the next until there is one without a nullsafety version. And then two libraries will depends both on the same library, but one to the nullsafety and the other to the not-nullsafety version... : S

I realize it is not a problem related to moor.

simolus3 commented 3 years ago

If I update one to nullsafety then I have to update the next one it depends on and the next until there is one without a nullsafety version

Yeah, the migration can be a pain and I wouldn't recommend it until all of your dependencies have migrated.

Until then, you could use an older version of encrypted_moor by referencing a commit before migrating to null-safety. For instance, you could use 348fb655cefb1ee777c76935cdb0c873886c393e to avoid the dependency conflicts.

apoleo88 commented 3 years ago

Unfortunatly It appears I can't find a combination of dependencies that works, the last beta has the nullOk bug on at least flutter_svg library. The downgraded version of beta( 1.25.0-8.3.pre) does not have that bug, but is not nullsafe compatible and so it doesn't work with encrypted_moor that needs path_provider: ^2.0.0-nullsafety

So, my only solution, for now, would be to use an encrypted_moor version that does not use path_provider: ^2.0.0-nullsafety, but I guess there is not?

I can't migrate a database later on, from moorto encrypted_moor, right?

Edit: I didn't read your last comment, I will try with the suggested commit! : )