Closed epiphanatic closed 1 year ago
Hey @epiphanatic, can you just confirm which version you're running? This does look like a serious bug.
@JaffaKetchup Ah yes sorry, it's 8.0.0
Thanks. I can confirm that this has been fixed in v9, but I'll see if I can release a patch for this by the end of today.
nice, thank you @JaffaKetchup and thank you for your all work on this package!
@epiphanatic I've published a patch to resolve this. If this package is helping you, please consider donating!
What is the bug?
Whenever I create a LineRegion, then make that region downloadable, then use the
check()
method to get the tile count, I get the following error:I/flutter (27684): type 'List<List<Object>>' is not a subtype of type 'List<List<LatLng>>
I've put steps below to reproduce as well as a hack that get it to work temporarily. Please let me know if I can provide you with anything else.
How can we reproduce it?
Create a list of LatLng points:
List<LatLng> points = [LatLng(latitude:-37.756213, longitude:144.522503), LatLng(latitude:-37.818282, longitude:144.571009)];
Create region:
final region = LineRegion(points, 0);
Create downloadable region:
final downloadableRegion = region.toDownloadable( 0, 10, TileLayer( urlTemplate: '<my url template>', userAgentPackageName: '<my package name>', ), );
Try to calculate tile size (fails):
int tileSize = await locator<StoreDirectory Function()>() .call() .download .check(downloadableRegion);
This will produce the error above where the check function is receiving List<List< Object >> instead of List<List< LatLng >>
Do you have a potential solution?
As a quick hack I went into the
generateTileLoopsInput
function and instead of:'lineOutline': region.points.slices(4).toList(),
I put:
'lineOutline': [ [ for (var i = 0; i < region.points.length; i++) ...[ LatLng((region.points[i] as LatLng).latitude, (region.points[i] as LatLng).longitude), ] ] ],
Although ugly, it works and it points out what is happening.
I didn't do a PR since I figured there is probably a far more elegant solution for one who is more intimately familiar with the rest of the code.
Platforms
Pixel 4 emulator Android API 33
Severity
Erroneous: Prevents normal functioning and causes errors in the console