Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #38 from it-sam/master
Browse files Browse the repository at this point in the history
Null safety
  • Loading branch information
synw authored Jul 10, 2021
2 parents 598442f + a51c8b3 commit 414d6d6
Show file tree
Hide file tree
Showing 22 changed files with 463 additions and 332 deletions.
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
language: dart

dart:
- 2.3.0
- 2.12.0

install:
- pub get
- gem install coveralls-lcov

script:
pub run test_coverage

after_success:
- coveralls-lcov coverage/lcov.info
script: dart test --coverage=coverage && dart run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --packages=.packages --report-on=lib

branches:
only: [master]

cache:
directories:
- $HOME/.pub-cache
- $HOME/.pub-cache
4 changes: 2 additions & 2 deletions example/dart/functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:geojson/geojson.dart';
// data is from http://www.naturalearthdata.com

void main() async {
await multipolygons();
await multiPolygons();
await lines();
await smallData();
await nestedGeometryCollection();
Expand All @@ -27,7 +27,7 @@ Future<void> smallData() async {
return;
}

Future<void> multipolygons() async {
Future<void> multiPolygons() async {
final file = File("../data/lakes_of_europe.geojson");
final features = await featuresFromGeoJsonFile(file, nameProperty: "label");
for (final feature in features.collection) {
Expand Down
4 changes: 2 additions & 2 deletions example/dart/geofencing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ Future<void> main(List<String> args) async {
value: countryName),
nameProperty: "ADMIN",
verbose: true);
if (geo.multipolygons.isEmpty) {
if (geo.multiPolygons.isEmpty) {
print("Country $countryName not found");
return;
}
final country = geo.multipolygons;
final country = geo.multiPolygons;
print("Loading airports");
await geo.parseFile("../flutter_map/assets/airports.geojson",
disableStream: true);
Expand Down
2 changes: 1 addition & 1 deletion example/dart/stream.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ void main() {

Future<void> parse() async {
final geojson = GeoJson();
geojson.processedMultipolygons.listen((GeoJsonMultiPolygon multiPolygon) {
geojson.processedMultiPolygons.listen((GeoJsonMultiPolygon multiPolygon) {
print("${multiPolygon.name}: ${multiPolygon.polygons.length} polygon(s)");
});
await geojson.parseFile("../flutter_map/assets/countries.geojson",
Expand Down
1 change: 1 addition & 0 deletions example/flutter_mobile/ios/Flutter/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
1 change: 1 addition & 0 deletions example/flutter_mobile/ios/Flutter/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
38 changes: 38 additions & 0 deletions example/flutter_mobile/ios/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
69 changes: 64 additions & 5 deletions example/flutter_mobile/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 50;
objects = {

/* Begin PBXBuildFile section */
008F7E2B1EDB72E7022040B8 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 53A77D298FDD7644AD36E34A /* libPods-Runner.a */; };
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 @@ -32,6 +33,7 @@
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>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
53A77D298FDD7644AD36E34A /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
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 +44,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>"; };
E27537BFC7CBE58E94E49698 /* 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>"; };
EFE248C23785A423AB967699 /* 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>"; };
F84F8BFEDE83CF9F61E29B68 /* 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 = (
008F7E2B1EDB72E7022040B8 /* libPods-Runner.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
6C618AEF82238E5DF3411F9A /* Pods */ = {
isa = PBXGroup;
children = (
EFE248C23785A423AB967699 /* Pods-Runner.debug.xcconfig */,
E27537BFC7CBE58E94E49698 /* Pods-Runner.release.xcconfig */,
F84F8BFEDE83CF9F61E29B68 /* Pods-Runner.profile.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
};
6DA5D5211E50013C80C733E4 /* Frameworks */ = {
isa = PBXGroup;
children = (
53A77D298FDD7644AD36E34A /* libPods-Runner.a */,
);
name = Frameworks;
sourceTree = "<group>";
};
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
Expand All @@ -72,6 +96,8 @@
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
6C618AEF82238E5DF3411F9A /* Pods */,
6DA5D5211E50013C80C733E4 /* Frameworks */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -105,6 +131,7 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
D763BB26A7A181FFC8B408A0 /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
Expand Down Expand Up @@ -197,6 +224,28 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
D763BB26A7A181FFC8B408A0 /* [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;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down Expand Up @@ -290,7 +339,10 @@
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterMobile;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand Down Expand Up @@ -399,7 +451,8 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand All @@ -414,7 +467,10 @@
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterMobile;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand All @@ -433,7 +489,10 @@
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterMobile;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand Down

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

16 changes: 9 additions & 7 deletions example/flutter_mobile/lib/airports/airports.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:rxdart/rxdart.dart';
import 'package:flutter/services.dart' show rootBundle;
import 'package:flutter_map/flutter_map.dart';
import 'package:geojson/geojson.dart';
import 'package:latlong/latlong.dart';
import 'package:latlong2/latlong.dart';

class _AirportsPageState extends State<AirportsPage> {
final polygons = <Polygon>[];
Expand All @@ -16,7 +16,7 @@ class _AirportsPageState extends State<AirportsPage> {
var countriesData = <GeoJsonMultiPolygon>[];
var airportsData = <GeoJsonPoint>[];
final mapController = MapController();
StreamSubscription<GeoJsonPoint> sub;
late StreamSubscription<GeoJsonPoint> sub;
bool isSearching = false;
bool dataIsLoaded = false;
bool showSearchResults = false;
Expand All @@ -37,10 +37,11 @@ class _AirportsPageState extends State<AirportsPage> {
isSearching = false;
}
});
sub = geo.processedPoints.listen((point) {
sub = geo.processedPoints.listen((geojsonPoint) {
// listen for the geofenced airports
final point = geojsonPoint.geoPoint.toLatLng()!;
setState(() => markers.add(Marker(
point: point.geoPoint.toLatLng(),
point: point,
builder: (BuildContext context) => Icon(Icons.local_airport))));
});
}
Expand All @@ -49,7 +50,7 @@ class _AirportsPageState extends State<AirportsPage> {
final data = await rootBundle.loadString('assets/countries.geojson');
await geo.parse(data,
nameProperty: "ADMIN", disableStream: true, verbose: true);
countriesData = geo.multipolygons;
countriesData = geo.multiPolygons;
}

Future<void> loadAirports() async {
Expand All @@ -62,7 +63,8 @@ class _AirportsPageState extends State<AirportsPage> {
print('Searching for countries: $name');
final foundCountries = <GeoJsonMultiPolygon>[];
for (final c in countriesData) {
if (c.name.toLowerCase().startsWith(name.toLowerCase())) {
if (c.name == null) return foundCountries;
if (c.name!.toLowerCase().startsWith(name.toLowerCase())) {
foundCountries.add(c);
}
}
Expand Down Expand Up @@ -131,7 +133,7 @@ class _AirportsPageState extends State<AirportsPage> {
itemBuilder: (BuildContext context, int i) {
return ListTile(
title: GestureDetector(
child: Text(countriesToSelect[i].name),
child: Text(countriesToSelect[i].name ?? ""),
onTap: () {
final country = countriesToSelect[i];
setState(() {
Expand Down
6 changes: 3 additions & 3 deletions example/flutter_mobile/lib/airports/nearby_airports.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart' show rootBundle;
import 'package:geojson/geojson.dart';
import 'package:latlong/latlong.dart';
import 'package:latlong2/latlong.dart';
import 'package:geopoint/geopoint.dart';
import 'package:flutter_map/flutter_map.dart';

Expand All @@ -11,7 +11,7 @@ class _NearbyAirportsPageState extends State<NearbyAirportsPage> {
final markers = <Marker>[];
var airportsData = <GeoJsonPoint>[];
final geo = GeoJson();
StreamSubscription<GeoJsonPoint> sub;
late StreamSubscription<GeoJsonPoint> sub;
final dataIsLoaded = Completer<Null>();
String status = "Loading data ...";

Expand All @@ -25,7 +25,7 @@ class _NearbyAirportsPageState extends State<NearbyAirportsPage> {
sub = geo.processedPoints.listen((point) {
// listen for the geofenced airports
setState(() => markers.add(Marker(
point: point.geoPoint.toLatLng(),
point: point.geoPoint.toLatLng()!,
builder: (BuildContext context) => Icon(Icons.local_airport))));
});
}
Expand Down
8 changes: 5 additions & 3 deletions example/flutter_mobile/lib/countries/countries.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:geojson/geojson.dart';
import 'package:geopoint/geopoint.dart';
import 'package:flutter/services.dart' show rootBundle;
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong/latlong.dart';
import 'package:latlong2/latlong.dart';

class _CountriesPageState extends State<CountriesPage> {
final polygons = <Polygon>[];
Expand All @@ -18,14 +18,16 @@ class _CountriesPageState extends State<CountriesPage> {

Future<void> processData() async {
final geojson = GeoJson();
geojson.processedMultipolygons.listen((GeoJsonMultiPolygon multiPolygon) {
geojson.processedMultiPolygons.listen((GeoJsonMultiPolygon multiPolygon) {
for (final polygon in multiPolygon.polygons) {
final geoSerie = GeoSerie(
type: GeoSerieType.polygon,
name: polygon.geoSeries[0].name,
geoPoints: <GeoPoint>[]);
for (final serie in polygon.geoSeries) {
geoSerie.geoPoints.addAll(serie.geoPoints);
if (serie.geoPoints != null) {
geoSerie.geoPoints?.addAll(serie.geoPoints!);
}
}
final color =
Color((math.Random().nextDouble() * 0xFFFFFF).toInt() << 0)
Expand Down
3 changes: 2 additions & 1 deletion example/flutter_mobile/lib/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class IndexPage extends StatelessWidget {
}

class MainButton extends StatelessWidget {
const MainButton({Key key, this.text, this.icon, this.link})
const MainButton(
{Key? key, required this.text, required this.icon, required this.link})
: super(key: key);

final String text;
Expand Down
Loading

0 comments on commit 414d6d6

Please sign in to comment.