Skip to content

Commit

Permalink
Upgrade to sound null-safety (#870)
Browse files Browse the repository at this point in the history
* Add actions/stale@v3 GitHub Action

patched version

* updated to latest master version

* updated dependcies to compile again

* updated latlong import

* migrated to unsound null safety

* removed .packages from repository

* small fixes

* Update lib/src/core/point.dart

Co-authored-by: Sata51 <vm.mathieu@gmail.com>

* Update pubspec.yaml

Co-authored-by: Sata51 <vm.mathieu@gmail.com>

* Update lib/src/gestures/latlng_tween.dart

Co-authored-by: Sata51 <vm.mathieu@gmail.com>

* type '_ControllerStream<LatLng?>' is not a subtype of type 'Stream<LatLng>' of 'stream'

* changes according to review

* made key nullable

* made rebuild nullable again

* Fix polyline border drawing

* corrected typo in dependency_overrides

* Removed unnecessary null-checks

* Limit number of purges in TileLayer and cancel pending on dispose

* Fix error messages in mocked classes

* Set ready to true always (state is never null)

* make bounds, getBounds and getCenter null safe

* use http.RetryClient instead of flutter_image

* formatting

* add change notes

* Added example page for NetworkTileProvider

* Added dependency on null safe version 0.17.0 of package intl (would not build without it)

* Changed to master branch of flutter_image that is now null-safe

* Change override of package flutter_image to new location in flutter packages

* Update git repo link

* Fix typos

* Sort dependencies

* Reformat and improve pub score

* Upgraded to flutter_image ^4.0.1

* Reformatted files to standard settings

* Reformatted crs.dart that wasn't changed using command line

* Random Fixes Everywhere (#910)

* Update git repo link

* Fix typos

* Sort dependencies

* Improve pub score

* remove TODO

* Clarification of all options available for offline mapping (#913)

* Update README.md

- Clarified all options for offline mapping
- Fixed some capitalisation inconsistencies.

* Update README.md

* fix Group Layer Options constructor wrong nullability (#921)

Co-authored-by: 6y <tlserver6y@gmail.com>

* null check regex in template()

* re-apply #913 into null safety branch

* Review comments from issues/829-nullsafety (#919)

* fix: remove deprecated properties

Removes deprecated properties, updates documentation and changed
bounds getCenter to a getter.

* fix: simplify center getter

* docs: improve documentation for NetworkTileProvider

* docs: update documentation for tileProvider

* dart format

* make urlTemplate required, make throttleSTreamTransformerWithTrailingCall updateInterval required.

* use late final where possible

* revert making urlTemplate non-nullable

Co-authored-by: John Ryan <ryjohn@google.com>
Co-authored-by: escamoteur <github@burkharts.net>
Co-authored-by: Sata51 <vm.mathieu@gmail.com>
Co-authored-by: alt <ali.tazik@gmail.com>
Co-authored-by: Ahmed-gubara <ahmed.gubara93@gmail.com>
Co-authored-by: josxha <34318751+josxha@users.noreply.github.com>
Co-authored-by: Nico Mexis <nico.mexis@kabelmail.de>
Co-authored-by: Luka S <58115698+JaffaKetchup@users.noreply.github.com>
Co-authored-by: 6y <tlserver@yahoo.com>
Co-authored-by: 6y <tlserver6y@gmail.com>
Co-authored-by: André Andersson <andre.andersson@zenon.se>
  • Loading branch information
12 people committed Jun 4, 2021
1 parent f9397d0 commit 368e3b7
Show file tree
Hide file tree
Showing 53 changed files with 1,005 additions and 694 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,19 @@
## [0.13.0] - xx/xx/2021
This version has support for sound null safety. For this purpose, some inactive packages were exchanged with active forks.

- Sound null safety migration (#851, #870)
- requires flutter version 2.0.0 or higher
- latlong is replaced with latlong2
- ready-flag on map has been removed
- Remove the package flutter_image and add http instead (#894)
- http has to be version 0.13.2 or higher for this package (#894)
- Removed deprecated properties
- debug property has been removed
- interactive has been replaced by interactiveFlags
- Bounds getCenter has been replaced by center getter

Thanks to escamoteur, ThexXTURBOXx, Sata51, tazik561, kengu, passsy, Ahmed-gubara, johnpryan, josxha and andreandersson for this release!

## [0.12.0] - 3/16/2021
TileLayerOptions now takes some additional options, templateFunction,
tileBuilder, tilesContainerBuilder, and evictErrorTileStrategy
Expand Down
79 changes: 68 additions & 11 deletions README.md
Expand Up @@ -243,18 +243,71 @@ See the `example/` folder for a working example app.
To run it, in a terminal cd into the folder. Then execute `ulimit -S -n 2048`
([ref][ulimit-comment]). Then execute `flutter run` with a running emulator.

## Preconfigured offline maps
## Downloading and caching offline maps

This method is only to use preconfigured and prepackaged offline maps. For
advanced caching and ability to dynamically download an area, see the
[flutter_map_tile_caching][flutter_map_tile_caching] plugin.
This section provides an overview of the available caching tile providers. If
you would like to provide preconfigured and prepackaged map tiles to your app
users, see the 'Preconfigured Offline Maps' section below.

First, find which tiles you would like to use through a service such as
[tilemill][tilemill]. You should have tiles exported into the `.mbtiles` format.
The two available options included in flutter_map

Then use [mbtilesToPng][mbtilesToPngs] to unpack into `/{z}/{x}/{y}.png`. Move
this to the assets folder and add the asset directories to `pubspec.yaml`. The
minimum required fields for offline maps are:
### 1. Use `NetworkImage` by using `NonCachingNetworkTileProvider`

Whilst the name might make you think differently, it is designed to prevent you
from using it and expecting it to cache; because it doesn't.

The `FlutterMap` `NonCachingNetworkTileProvider` implementaion uses
`NetworkImage` which should cache images in memory until the app restart
(through `Image.network`). See the [Image.network][Image.network] docs and
[NetworkImage][NetworkImage-caching] docs for more details.

### 2. Using the `cached_network_image` dependency

This dependency has an `ImageProvider` that caches images to disk, which means
the cache persists through an app restart. You'll need to [include the
package](https://pub.dev/packages/cached_network_image/install) in your
`pubspec.yaml`.

Create your own provider using the code below:
```dart
import 'package:cached_network_image/cached_network_image.dart';
class CachedTileProvider extends TileProvider {
const CachedTileProvider();
@override
ImageProvider getImage(Coords<num> coords, TileLayerOptions options) {
return CachedNetworkImageProvider(
getTileUrl(coords, options),
//Now you can set options that determine how the image gets cached via whichever plugin you use.
);
}
}
```
Then, add the `CachedTileProvider` `TileProvider` to the appropriate
`TileLayerOptions`:

```dart
TileLayerOptions(
urlTemplate: 'https://example.com/{x}/{y}/{z}',
tileProvider: const CachedTileProvider()
)
```

## Offline Maps using TileMill

This section provides instructions for preconfigured and prepackaged offline
maps. To see how to setup caching and downloading, see the 'Dynamically
Downloading & Caching Offline Maps' section above.

This guide uses an open source program called [TileMill][tilemill-homepage].

First, [install TileMill][install-tilemill] on your machine. Then, follow [these
instructions][tilemill].

Once you have your map exported to `.mbtiles`, you can use
[mbtilesToPng][mbTilesToPngs] to unpack into `/{z}/{x}/{y}.png`.

Move this to assets folder and add the appropriate asset directories to
`pubspec.yaml`. Minimum required fields for this solution are:

```dart
Widget build(ctx) {
Expand Down Expand Up @@ -300,13 +353,17 @@ See also `FileTileProvider()`, which loads tiles from the filesystem.
For the latest roadmap, please see the [Issue Tracker]

[Issue Tracker]: https://github.com/johnpryan/flutter_map/issues
[Leaflet]: http://leafletjs.com/
[Leaflet]: https://leafletjs.com/
[Mapbox]: https://www.mapbox.com/
[azure-maps-instructions]: https://docs.microsoft.com/en-us/azure/azure-maps/quick-demo-map-app
[custom-crs-readme]: ./example/lib/pages/custom_crs/Readme.md
[flutter_map_tile_caching]: https://github.com/JaffaKetchup/flutter_map_tile_caching
[mbTilesToPng]: https://github.com/alfanhui/mbtilesToPngs
[open-street-map]: https://openstreetmap.org
[proj4dart]: https://github.com/maRci002/proj4dart
[tilemill]: https://tilemill-project.github.io/tilemill/docs/guides/osm-bright-mac-quickstart/
[install-tilemill]: https://tilemill-project.github.io/tilemill/docs/install/
[ulimit-comment]: https://github.com/trentpiercy/trace/issues/1#issuecomment-404494469
[proj4dart]: https://github.com/maRci002/proj4dart
[Image.network]: https://api.flutter.dev/flutter/widgets/Image/Image.network.html
[NetworkImage-caching]: https://flutter.dev/docs/cookbook/images/network-image#placeholders-and-caching
[tilemill-homepage]: https://tilemill-project.github.io/tilemill/
1 change: 1 addition & 0 deletions analysis_options.yaml
Expand Up @@ -36,6 +36,7 @@ linter:
- prefer_null_aware_operators
- prefer_single_quotes
- prefer_typing_uninitialized_variables
- sort_pub_dependencies
- test_types_in_equals
- throw_in_finally
- unnecessary_brace_in_string_interps
Expand Down
1 change: 1 addition & 0 deletions example/ios/Flutter/Debug.xcconfig
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
1 change: 1 addition & 0 deletions example/ios/Flutter/Release.xcconfig
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
68 changes: 68 additions & 0 deletions example/ios/Runner.xcodeproj/project.pbxproj
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
127B2300FA5CE87549434CC2 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A72EECE5117AE803156E244 /* Pods_Runner.framework */; };
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
Expand All @@ -31,7 +32,9 @@
/* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
3A72EECE5117AE803156E244 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
4928082F7E2BC0BADA4A6955 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
Expand All @@ -42,19 +45,41 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
CF9AFCBF84244C1D44C2E795 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
E1DF330ADC8450B8B567025E /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
97C146EB1CF9000F007C117D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
127B2300FA5CE87549434CC2 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
13FB0627975E846BA76A343C /* Pods */ = {
isa = PBXGroup;
children = (
CF9AFCBF84244C1D44C2E795 /* Pods-Runner.debug.xcconfig */,
4928082F7E2BC0BADA4A6955 /* Pods-Runner.release.xcconfig */,
E1DF330ADC8450B8B567025E /* Pods-Runner.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
1DB0744A0D67D7FBC7C14ADA /* Frameworks */ = {
isa = PBXGroup;
children = (
3A72EECE5117AE803156E244 /* Pods_Runner.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
Expand All @@ -72,6 +97,8 @@
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
13FB0627975E846BA76A343C /* Pods */,
1DB0744A0D67D7FBC7C14ADA /* Frameworks */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -105,12 +132,14 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
2655651DCB6AEB0882B90CC1 /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
C1C85694F6D3CCB2E45E23F9 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -169,6 +198,28 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
2655651DCB6AEB0882B90CC1 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -197,6 +248,23 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
C1C85694F6D3CCB2E45E23F9 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down
3 changes: 3 additions & 0 deletions example/ios/Runner.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions example/lib/main.dart
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_map_example/pages/network_tile_provider.dart';

import './pages/animated_map_controller.dart';
import './pages/circle.dart';
Expand Down Expand Up @@ -40,6 +41,7 @@ class MyApp extends StatelessWidget {
),
home: HomePage(),
routes: <String, WidgetBuilder>{
NetworkTileProviderPage.route: (context) => NetworkTileProviderPage(),
WidgetsPage.route: (context) => WidgetsPage(),
TapToAddPage.route: (context) => TapToAddPage(),
EsriPage.route: (context) => EsriPage(),
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/animated_map_controller.dart
Expand Up @@ -29,7 +29,7 @@ class AnimatedMapControllerPageState extends State<AnimatedMapControllerPage>
static LatLng paris = LatLng(48.8566, 2.3522);
static LatLng dublin = LatLng(53.3498, -6.2603);

MapController mapController;
late final MapController mapController;

@override
void initState() {
Expand Down
12 changes: 6 additions & 6 deletions example/lib/pages/custom_crs/custom_crs.dart
Expand Up @@ -14,30 +14,30 @@ class CustomCrsPage extends StatefulWidget {
}

class _CustomCrsPageState extends State<CustomCrsPage> {
Proj4Crs epsg3413CRS;
late final Proj4Crs epsg3413CRS;

double maxZoom;
double? maxZoom;

// Define start center
proj4.Point point = proj4.Point(x: 65.05166470332148, y: -19.171744826394896);

String initText = 'Map centered to';

proj4.Projection epsg4326;
late final proj4.Projection epsg4326;

proj4.Projection epsg3413;
late final proj4.Projection epsg3413;

@override
void initState() {
super.initState();

// EPSG:4326 is a predefined projection ships with proj4dart
epsg4326 = proj4.Projection('EPSG:4326');
epsg4326 = proj4.Projection.get('EPSG:4326')!;

// EPSG:3413 is a user-defined projection from a valid Proj4 definition string
// From: http://epsg.io/3413, proj definition: http://epsg.io/3413.proj4
// Find Projection by name or define it if not exists
epsg3413 = proj4.Projection('EPSG:3413') ??
epsg3413 = proj4.Projection.get('EPSG:3413') ??
proj4.Projection.add('EPSG:3413',
'+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs');

Expand Down
6 changes: 3 additions & 3 deletions example/lib/pages/interactive_test_page.dart
Expand Up @@ -16,12 +16,12 @@ class InteractiveTestPage extends StatefulWidget {
}

class _InteractiveTestPageState extends State<InteractiveTestPage> {
MapController mapController;
late final MapController mapController;

// Enable pinchZoom and doubleTapZoomBy by default
int flags = InteractiveFlag.pinchZoom | InteractiveFlag.doubleTapZoom;

StreamSubscription<MapEvent> subscription;
late final StreamSubscription<MapEvent> subscription;

@override
void initState() {
Expand Down Expand Up @@ -159,7 +159,7 @@ class _InteractiveTestPageState extends State<InteractiveTestPage> {
}

return Text(
'Current event: ${snapshot.data.runtimeType}\nSource: ${snapshot.data.source}',
'Current event: ${snapshot.data.runtimeType}\nSource: ${snapshot.data!.source}',
textAlign: TextAlign.center,
);
},
Expand Down

0 comments on commit 368e3b7

Please sign in to comment.