flutter_map_dragmarker icon indicating copy to clipboard operation
flutter_map_dragmarker copied to clipboard

null safety

Open barbalex opened this issue 3 years ago • 27 comments

Once I know how to include this plugin into my project (https://github.com/ibrierley/flutter_map_dragmarker/issues/3) I will need it to be sound null safe.

As the project is not very big I could give it a go myself. But beware: I am a dart/flutter noob.

@ibrierley What do you think?

barbalex avatar Jun 10 '21 13:06 barbalex

Let me take a quick look, as I think there's some other dependancies need updating now flutter_map has also, and I'll try and give some feedback how long it will be.

ibrierley avatar Jun 10 '21 14:06 ibrierley

latlong > latlong2

barbalex avatar Jun 10 '21 14:06 barbalex

yes, it needs latlong2, which I'll be doing, but there are some other issues too...

ibrierley avatar Jun 10 '21 14:06 ibrierley

I'm probably going to run out of time today to upgrade to null safety, there's quite a bit to do, but I will do it in time, hopefully by the end of the weekend.

ibrierley avatar Jun 10 '21 15:06 ibrierley

Hopefully - but it's your project and you owe me nothing.

barbalex avatar Jun 10 '21 15:06 barbalex

Hah, no, but I've been putting it off for a while, and I have another plugin which depends on this one.

ibrierley avatar Jun 10 '21 15:06 ibrierley

Oh, just found flutter_map_line_editor. Looks GREAT!

barbalex avatar Jun 10 '21 15:06 barbalex

This is the bit that it depends on :D, so that will be done after.

ibrierley avatar Jun 10 '21 15:06 ibrierley

Bit of a rush job, but I've created a branch nullsafety if you wanted to test it.

(I haven't had time to do the dragmarket_widget_layer.dart, but the dragmarker.dart normal layer like in the example should work)

ibrierley avatar Jun 10 '21 16:06 ibrierley

I added this to my pubspec.yaml:

flutter_map_dragmarker:
  git:
    url: https://github.com/ibrierley/flutter_map_dragmarker
    ref: nullsafety

and got:

Because latlong >=0.6.1 depends on logging >=0.11.3 <1.0.0 and latlong <0.6.1 requires SDK version >=1.8.0 <2.0.0, every version of latlong requires logging >=0.11.3 <1.0.0.


And because build_runner >=2.0.0 depends on logging ^1.0.0 and every version of flutter_map_dragmarker from git depends on latlong any, build_runner >=2.0.0 is incompatible with flutter_map_dragmarker from git.
So, because capturing depends on both flutter_map_dragmarker from git and build_runner ^2.0.2, version solving failed.

pub get failed (1; So, because capturing depends on both flutter_map_dragmarker from git and build_runner ^2.0.2, version solving failed.)
exit code 1

So latlong needs to be replaced with latlong2.

barbalex avatar Jun 10 '21 19:06 barbalex

Think a pubspec didn't update, try now.

Ian

On Thu, Jun 10, 2021 at 8:29 PM Alexander Gabriel @.***> wrote:

I added this to my pubspec.yaml:

flutter_map_dragmarker: git: url: https://github.com/ibrierley/flutter_map_dragmarker ref: nullsafety

and got:

Because latlong >=0.6.1 depends on logging >=0.11.3 <1.0.0 and latlong <0.6.1 requires SDK version >=1.8.0 <2.0.0, every version of latlong requires logging >=0.11.3 <1.0.0.

And because build_runner >=2.0.0 depends on logging ^1.0.0 and every version of flutter_map_dragmarker from git depends on latlong any, build_runner >=2.0.0 is incompatible with flutter_map_dragmarker from git. So, because capturing depends on both flutter_map_dragmarker from git and build_runner ^2.0.2, version solving failed.

pub get failed (1; So, because capturing depends on both flutter_map_dragmarker from git and build_runner ^2.0.2, version solving failed.) exit code 1

So latlong needs to be replaced with latlong2.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ibrierley/flutter_map_dragmarker/issues/4#issuecomment-858956840, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5YN5PGABKEFWFHHEQHWLLTSEHBLANCNFSM46ORRNMQ .

ibrierley avatar Jun 10 '21 21:06 ibrierley

Same result.

Seems that latlong still did not get updated: https://github.com/ibrierley/flutter_map_dragmarker/blob/nullsafety/pubspec.yaml#L30

barbalex avatar Jun 11 '21 10:06 barbalex

actually, slightly different result:

[capturing] flutter pub get
Running "flutter pub get" in capturing...                       
Because every version of flutter_map_dragmarker from git depends on latlong 0.8.0 which doesn't match any versions, flutter_map_dragmarker from git is forbidden.

So, because capturing depends on flutter_map_dragmarker from git, version solving failed.
pub get failed (1; So, because capturing depends on flutter_map_dragmarker from git, version solving failed.)
exit code 1

barbalex avatar Jun 11 '21 10:06 barbalex

Seems that you updated the version to 0.8.0 which is correct for latlong2 but forgot to change latlong to latlong2.

Also, don't forget to update the imports:

import 'package:latlong2/latlong.dart';

instead of:

import 'package:latlong/latlong.dart';

barbalex avatar Jun 11 '21 10:06 barbalex

Oh, you did update the imports: https://github.com/ibrierley/flutter_map_dragmarker/blob/nullsafety/lib/dragmarker.dart#L4

barbalex avatar Jun 11 '21 10:06 barbalex

Yes, I think it's because I've got 2 slightly different versions I'm switching between...can you try again.

ibrierley avatar Jun 11 '21 10:06 ibrierley

Installs now. I'll try to implement it and see if I get it to work now.

barbalex avatar Jun 11 '21 10:06 barbalex

When launching the virtual device I get:

Launching lib\main.dart on sdk gphone x86 64 in debug mode...
lib\main.dart:1
../flutter/.pub-cache/git/flutter_map_dragmarker-e3747e9aa0594e2881ce2b3db197e1bdd9012bc9/lib/dragmarker.dart:65:67: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  DragMarkerWidget({this.mapState, required this.marker, AnchorPos? anchorPos, this.stream, this.options }); //: anchor = Anchor.forPos(anchorPos, marker.width, marker.height);                                                          

I am really just guessing, but could this setting be meant? https://github.com/ibrierley/flutter_map_dragmarker/blob/nullsafety/pubspec.yaml#L17

barbalex avatar Jun 11 '21 11:06 barbalex

Yes: https://dart.dev/tools/pub/pubspec#sdk-constraints

barbalex avatar Jun 11 '21 11:06 barbalex

More to the point: https://dart.dev/guides/language/evolution

barbalex avatar Jun 11 '21 11:06 barbalex

Ok, I've started with a fresh git version pulled from here, so hopefully it will track better. See if this does it.

ibrierley avatar Jun 11 '21 11:06 ibrierley

Btw there should be a null safety branch for flutter_map_line_editor, couple of examples and demo gifs on readme if you wanted to try that as well. Thanks for patience.

ibrierley avatar Jun 11 '21 16:06 ibrierley

Ok, I've started with a fresh git version pulled from here, so hopefully it will track better. See if this does it.

Works fine!

barbalex avatar Jun 11 '21 19:06 barbalex

Btw there should be a null safety branch for flutter_map_line_editor, couple of examples and demo gifs on readme if you wanted to try that as well. Thanks for patience.

I'll leave that for the weekend.

barbalex avatar Jun 11 '21 19:06 barbalex

Can you upadate cupertino_icons to 1.0.3 or any on nullsafe branch ?

Mmisiek avatar Oct 01 '21 18:10 Mmisiek

I'm just testing a new branch panfix as there was another issue with flutter_map 0.14 if you wanted to test that.

ibrierley avatar Oct 02 '21 14:10 ibrierley

Sure I can do that.

On Sat, Oct 2, 2021, 07:43 Ian @.***> wrote:

I'm just testing a new branch panfix as there was another issue with flutter_map 0.14 if you wanted to test that.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ibrierley/flutter_map_dragmarker/issues/4#issuecomment-932763762, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABC7O4N2CUBTHJ75FJRBGYDUE4LB7ANCNFSM46ORRNMQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Mmisiek avatar Oct 02 '21 15:10 Mmisiek

This is not a problem any more. This package is compatible with full sound null safety, and therefore Dart 3 and Flutter 3.10. Closing…

pablojimpas avatar May 17 '23 09:05 pablojimpas