Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .fvmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"flutter": "3.27.4"
"flutter": "3.38.9"
}
4 changes: 2 additions & 2 deletions .github/workflows/melos-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ jobs:
secrets: inherit
permissions: write-all
with:
subfolder: '.' # add optional subfolder to run workflow in
flutter_version: 3.27.4
subfolder: "." # add optional subfolder to run workflow in
flutter_version: 3.38.9
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ name: Iconica Standard Component Release Workflow
on:
release:
types: [published]

workflow_dispatch:

jobs:
call-global-iconica-workflow:
uses: Iconica-Development/.github/.github/workflows/component-release.yml@master
secrets: inherit
permissions: write-all
permissions: write-all
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,10 @@ So before setting it to false you need to provide a google maps API key in the A
```dart
LocationMapOptions(
enableOpenMapsTileLayer: true,
tileProvider: CancellableNetworkTileProvider(),
tileProvider: NetworkTileProvider(),
)
```

When using the openmaps tilelayer from the flutter_maps package it is recommended to use the [CancellableNetworkTileProvider](https://pub.dev/packages/flutter_map_cancellable_tile_provider) especially on Web where performance is drastically improved. Because flutter_locations shouldn't depend on flutter_map_cancellable_tile_provider it is not included in the dependencies. You can add it to your pubspec.yaml file like this:

```yaml
dependencies:
flutter_map_cancellable_tile_provider: ^latest_version
```

For the features of this userstory permissions are required for each platform.

Expand Down
2 changes: 2 additions & 0 deletions apps/example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/

# IntelliJ related
Expand Down
47 changes: 20 additions & 27 deletions apps/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import "package:device_preview/device_preview.dart";
import "package:flutter/material.dart";
import "package:flutter_locations/flutter_locations.dart";
import "package:flutter_map_cancellable_tile_provider/flutter_map_cancellable_tile_provider.dart";

void main() {
runApp(
DevicePreview(
enabled: true,
isToolbarVisible: true,
availableLocales: const [
Locale("en_US"),
Locale("nl_NL"),
],
availableLocales: const [Locale("en_US"), Locale("nl_NL")],
builder: (_) => const App(),
),
);
Expand All @@ -22,28 +18,25 @@ class App extends StatelessWidget {

@override
Widget build(BuildContext context) => MaterialApp(
builder: DevicePreview.appBuilder,
locale: DevicePreview.locale(context),
supportedLocales: const [
Locale("en", "US"),
Locale("nl", "NL"),
],
theme: ThemeData.light(),
darkTheme: ThemeData.dark(),
home: LocationsUserStory(
options: LocationsOptions(
respositoryInterface: LocationsLocalRepository(density: 7),
mapOptions: LocationsMapOptions(
zoom: 7,
initialLocation: const Location(
latitude: 52.2056435,
longitude: 5.2,
),
// Openmaps works without an API key
enableOpenMapsTileLayer: true,
tileProvider: CancellableNetworkTileProvider(),
),
builder: DevicePreview.appBuilder,
locale: DevicePreview.locale(context),
supportedLocales: const [Locale("en", "US"), Locale("nl", "NL")],
theme: ThemeData.light(),
darkTheme: ThemeData.dark(),
home: LocationsUserStory(
options: LocationsOptions(
respositoryInterface: LocationsLocalRepository(density: 7),
mapOptions: LocationsMapOptions(
zoom: 7,
initialLocation: const Location(latitude: 52.2056435, longitude: 5.2),
// Open street maps works without an API key
enableOpenMapsTileLayer: true,
tileProvider: NetworkTileProvider(
// Open street maps requires a useragent
headers: {"User-Agent": "TempApp / 0.5"},
),
),
);
),
),
);
}
3 changes: 1 addition & 2 deletions apps/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: "Flutter Locations userstory example app"

version: 1.0.0+1
environment:
sdk: ">=3.4.3 <4.0.0"
sdk: ">=3.8.0 <4.0.0"

dependencies:
device_preview: ^1.2.0
Expand All @@ -12,7 +12,6 @@ dependencies:
flutter_locations:
hosted: https://forgejo.internal.iconica.nl/api/packages/internal/pub
version: ^1.0.0
flutter_map_cancellable_tile_provider: ^3.0.2

dev_dependencies:
flutter_test:
Expand Down
4 changes: 4 additions & 0 deletions packages/flutter_locations/lib/flutter_locations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
library flutter_locations;

export "package:dart_locations_repository_interface/dart_locations_repository_interface.dart";
export "package:flutter_map/flutter_map.dart";

export "src/config/locations_options.dart";
export "src/config/locations_translations.dart";
export "src/config/map/controls_options.dart";
export "src/config/map/map_options.dart";
export "src/ui/widgets/home.dart";
export "src/ui/widgets/map/map.dart";
export "src/userstories.dart";
export "src/util/scope.dart";
19 changes: 19 additions & 0 deletions packages/flutter_locations/lib/src/config/locations_options.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import "package:flutter/material.dart";
import "package:flutter_locations/flutter_locations.dart";
import "package:flutter_locations/src/config/list/list_options.dart";
Expand Down Expand Up @@ -29,6 +30,24 @@ class LocationsOptions {

/// The list options.
final LocationsListOptions listOptions;

LocationsOptions copy(LocationsOptions Function(LocationsOptions old) copy) =>
copy(this);

LocationsOptions copyWith({
LocationsRepositoryInterface? respositoryInterface,
LocationsTranslations? translations,
LocationsBaseScreenBuilder? builder,
LocationsMapOptions? mapOptions,
LocationsListOptions? listOptions,
}) =>
LocationsOptions(
respositoryInterface: respositoryInterface ?? this.respositoryInterface,
translations: translations ?? this.translations,
builder: builder ?? this.builder,
mapOptions: mapOptions ?? this.mapOptions,
listOptions: listOptions ?? this.listOptions,
);
}

///
Expand Down
51 changes: 50 additions & 1 deletion packages/flutter_locations/lib/src/config/map/map_options.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import "package:dart_locations_repository_interface/dart_locations_repository_interface.dart";
import "package:flutter/material.dart";
import "package:flutter_locations/src/config/map/controls_options.dart";
Expand All @@ -9,6 +10,7 @@ import "package:flutter_map/flutter_map.dart";
class LocationsMapOptions {
/// [LocationsMapOptions] constructor
const LocationsMapOptions({
this.controller,
this.zoom,
this.maxZoom = 18.0,
this.minZoom = 3.0,
Expand All @@ -17,13 +19,15 @@ class LocationsMapOptions {
this.onMapReady,
this.searchBuilder = DefaultLocationsMapSearch.builder,
this.markerBuilder = DefaultLocationsMapMarker.builder,
this.markerClusterBuilder = DefaultLocationsMapMarkerCluster.builder,
this.controlsOptions = const LocationsMapControlsOptions.empty(),
this.enableOpenMapsTileLayer = false,
this.tileProvider,
});

///
const LocationsMapOptions.empty({
this.controller,
this.additionalLayers = const [],
this.initialLocation = const Location(latitude: 0, longitude: 0),
this.zoom,
Expand All @@ -32,11 +36,15 @@ class LocationsMapOptions {
this.onMapReady,
this.searchBuilder = DefaultLocationsMapSearch.builder,
this.markerBuilder = DefaultLocationsMapMarker.builder,
this.markerClusterBuilder = DefaultLocationsMapMarkerCluster.builder,
this.controlsOptions = const LocationsMapControlsOptions.empty(),
this.enableOpenMapsTileLayer = false,
this.tileProvider,
});

///
final MapController? controller;

/// The layers containing everything other than the actual tilelayer.
final List<Widget> additionalLayers;

Expand Down Expand Up @@ -67,6 +75,9 @@ class LocationsMapOptions {
///
final LocationMapMarkerBuilder markerBuilder;

///
final LocationMapMarkerClusterBuilder markerClusterBuilder;

///
final LocationsMapControlsOptions controlsOptions;

Expand All @@ -75,9 +86,41 @@ class LocationsMapOptions {
final bool enableOpenMapsTileLayer;

/// [TileProvider] used of the openmaps tile layer. This can be used to add
/// CancellableNetworkTileProvider or other tile providers to improve
/// NetworkTileProvider or other tile providers to improve
/// performance without creating a dependency in flutter_locations.
final TileProvider? tileProvider;

LocationsMapOptions copyWith({
MapController? controller,
List<Widget>? additionalLayers,
Location? initialLocation,
VoidCallback? onMapReady,
double? zoom,
double? maxZoom,
double? minZoom,
LocationMapSearchBuilder? searchBuilder,
LocationMapMarkerBuilder? markerBuilder,
LocationMapMarkerClusterBuilder? markerClusterBuilder,
LocationsMapControlsOptions? controlsOptions,
bool? enableOpenMapsTileLayer,
TileProvider? tileProvider,
}) =>
LocationsMapOptions(
controller: controller ?? this.controller,
additionalLayers: additionalLayers ?? this.additionalLayers,
initialLocation: initialLocation ?? this.initialLocation,
onMapReady: onMapReady ?? this.onMapReady,
zoom: zoom ?? this.zoom,
maxZoom: maxZoom ?? this.maxZoom,
minZoom: minZoom ?? this.minZoom,
searchBuilder: searchBuilder ?? this.searchBuilder,
markerBuilder: markerBuilder ?? this.markerBuilder,
markerClusterBuilder: markerClusterBuilder ?? this.markerClusterBuilder,
controlsOptions: controlsOptions ?? this.controlsOptions,
enableOpenMapsTileLayer:
enableOpenMapsTileLayer ?? this.enableOpenMapsTileLayer,
tileProvider: tileProvider ?? this.tileProvider,
);
}

///
Expand All @@ -92,3 +135,9 @@ typedef LocationMapMarkerBuilder = Widget Function(
BuildContext context,
LocationItem locationItem,
);

///
typedef LocationMapMarkerClusterBuilder = Widget Function(
BuildContext,
List<Marker> markers,
);
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import "package:flutter/material.dart";
import "package:flutter_hooks/flutter_hooks.dart";
import "package:flutter_locations/flutter_locations.dart";
import "package:flutter_locations/src/util/scope.dart";

/// A widget that lists the locations.
class DefaultLocationsList<T extends LocationItem> extends HookWidget {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class DefaultLocationsMapMarker extends StatelessWidget {
LocationItem locationItem,
) =>
DefaultLocationsMapMarker(locationItem: locationItem);

@override
Widget build(BuildContext context) => Center(
child: Container(
Expand All @@ -30,3 +31,36 @@ class DefaultLocationsMapMarker extends StatelessWidget {
),
);
}

///
class DefaultLocationsMapMarkerCluster extends StatelessWidget {
///
const DefaultLocationsMapMarkerCluster({
required this.markers,
super.key,
});

///
final List<Marker> markers;

///
static Widget builder(
BuildContext context,
List<Marker> markers,
) =>
DefaultLocationsMapMarkerCluster(markers: markers);

@override
Widget build(BuildContext context) => DecoratedBox(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Theme.of(context).colorScheme.surfaceTint,
),
child: Center(
child: Text(
markers.length.toString(),
style: const TextStyle(color: Colors.white),
),
),
);
}
Loading