Skip to content

Commit

Permalink
chore: refactor example app (#1734)
Browse files Browse the repository at this point in the history
Co-authored-by: JaffaKetchup <github@jaffaketchup.dev>
  • Loading branch information
josxha and JaffaKetchup authored Nov 24, 2023
1 parent 2ba0c99 commit 670cb36
Show file tree
Hide file tree
Showing 68 changed files with 1,389 additions and 1,547 deletions.
1 change: 0 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ linter:
type_annotate_public_apis: true
unnecessary_statements: true
use_named_constants: true
use_super_parameters: true
cast_nullable_to_non_nullable: true
only_throw_errors: true
sort_unnamed_constructors_first: true
Expand Down
14 changes: 7 additions & 7 deletions example/.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
# This file should be version controlled and should not be manually edited.

version:
revision: "2524052335ec76bb03e04ede244b071f1b86d190"
channel: "stable"
revision: "0b591f2c82e9f59276ed68c7d4cbd63196f7c865"
channel: "beta"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 2524052335ec76bb03e04ede244b071f1b86d190
base_revision: 2524052335ec76bb03e04ede244b071f1b86d190
- platform: windows
create_revision: 2524052335ec76bb03e04ede244b071f1b86d190
base_revision: 2524052335ec76bb03e04ede244b071f1b86d190
create_revision: 0b591f2c82e9f59276ed68c7d4cbd63196f7c865
base_revision: 0b591f2c82e9f59276ed68c7d4cbd63196f7c865
- platform: android
create_revision: 0b591f2c82e9f59276ed68c7d4cbd63196f7c865
base_revision: 0b591f2c82e9f59276ed68c7d4cbd63196f7c865

# User provided section

Expand Down
32 changes: 5 additions & 27 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,8 @@
include: package:flutter_lints/flutter.yaml

analyzer:
language:
strict-casts: true
strict-inference: true
strict-raw-types: true
errors:
missing_required_param: error
missing_return: error
# match the lint rules from flutter_map
include: ./../analysis_options.yaml

# only specify things that should be different from the package
linter:
rules:
library_private_types_in_public_api: false # Not relevant to the example

always_declare_return_types: true
always_use_package_imports: true
avoid_dynamic_calls: true
cancel_subscriptions: true
close_sinks: false
package_api_docs: true
prefer_constructors_over_static_methods: true
prefer_final_in_for_each: true
prefer_final_locals: true
prefer_int_literals: true
test_types_in_equals: true
throw_in_finally: true
type_annotate_public_apis: true
unnecessary_statements: true
use_named_constants: true
# using the default parameter values are used as explanation and for showcase
avoid_redundant_argument_values: false
2 changes: 2 additions & 0 deletions example/android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ GeneratedPluginRegistrant.java
# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
**/*.keystore
**/*.jks
38 changes: 21 additions & 17 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '6'
Expand All @@ -21,21 +22,27 @@ if (flutterVersionName == null) {
flutterVersionName = '6.0.1'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 33
namespace "dev.fleaflet.flutter_map.example"
compileSdk flutter.compileSdkVersion
ndkVersion flutter.ndkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "me.jpryan.flutter_map_example"
minSdkVersion 16
applicationId "dev.fleaflet.flutter_map.example"
minSdkVersion flutter.minSdkVersion
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand All @@ -48,13 +55,10 @@ android {
signingConfig signingConfigs.debug
}
}
namespace 'me.jpryan.flutter_map_example'
}

flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
dependencies {}
3 changes: 2 additions & 1 deletion example/android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Flutter needs it to communicate with the running application
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
Expand Down
12 changes: 3 additions & 9 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Requried for fetching tiles -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
</queries>
<application
<application
android:label="flutter_map Demo"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported="true"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.jpryan.example
package dev.fleaflet.flutter_map.example

import io.flutter.embedding.android.FlutterActivity

Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions example/android/app/src/main/res/values-night/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
Expand Down
4 changes: 2 additions & 2 deletions example/android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
Expand Down
3 changes: 2 additions & 1 deletion example/android/app/src/profile/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Flutter needs it to communicate with the running application
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
Expand Down
6 changes: 3 additions & 3 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ buildscript {
ext.kotlin_version = '1.8.21'
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
// AGP version is set in settings.gradle.
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
org.gradle.jvmargs=-Xmx4G
android.useAndroidX=true
android.enableJetifier=true
1 change: 0 additions & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Expand Down
30 changes: 22 additions & 8 deletions example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
include ':app'
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}
settings.ext.flutterSdkPath = flutterSdkPath()

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
}

include ":app"
17 changes: 8 additions & 9 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import 'package:flutter/material.dart';
import 'package:flutter_map_example/pages/animated_map_controller.dart';
import 'package:flutter_map_example/pages/bundled_offline_map.dart';
import 'package:flutter_map_example/pages/cancellable_tile_provider.dart';
import 'package:flutter_map_example/pages/circle.dart';
import 'package:flutter_map_example/pages/custom_crs/custom_crs.dart';
import 'package:flutter_map_example/pages/epsg3413_crs.dart';
import 'package:flutter_map_example/pages/epsg4326_crs.dart';
import 'package:flutter_map_example/pages/fallback_url_network_page.dart';
import 'package:flutter_map_example/pages/fallback_url_page.dart';
import 'package:flutter_map_example/pages/home.dart';
import 'package:flutter_map_example/pages/interactive_test_page.dart';
import 'package:flutter_map_example/pages/latlng_to_screen_point.dart';
Expand All @@ -15,21 +16,20 @@ import 'package:flutter_map_example/pages/map_controller.dart';
import 'package:flutter_map_example/pages/map_inside_listview.dart';
import 'package:flutter_map_example/pages/markers.dart';
import 'package:flutter_map_example/pages/moving_markers.dart';
import 'package:flutter_map_example/pages/offline_map.dart';
import 'package:flutter_map_example/pages/overlay_image.dart';
import 'package:flutter_map_example/pages/plugin_scalebar.dart';
import 'package:flutter_map_example/pages/plugin_zoombuttons.dart';
import 'package:flutter_map_example/pages/screen_point_to_latlng.dart';
import 'package:flutter_map_example/pages/polygon.dart';
import 'package:flutter_map_example/pages/polyline.dart';
import 'package:flutter_map_example/pages/reset_tile_layer.dart';
import 'package:flutter_map_example/pages/retina.dart';
import 'package:flutter_map_example/pages/screen_point_to_latlng.dart';
import 'package:flutter_map_example/pages/secondary_tap.dart';
import 'package:flutter_map_example/pages/sliding_map.dart';
import 'package:flutter_map_example/pages/stateful_markers.dart';
import 'package:flutter_map_example/pages/tile_builder.dart';
import 'package:flutter_map_example/pages/tile_loading_error_handle.dart';
import 'package:flutter_map_example/pages/wms_tile_layer.dart';
import 'package:flutter_map_example/plugins/plugin_scalebar.dart';
import 'package:flutter_map_example/plugins/plugin_zoombuttons.dart';
import 'package:url_strategy/url_strategy.dart';

void main() {
Expand All @@ -38,7 +38,7 @@ void main() {
}

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});

@override
Widget build(BuildContext context) {
Expand All @@ -59,7 +59,7 @@ class MyApp extends StatelessWidget {
MarkerPage.route: (context) => const MarkerPage(),
PluginScaleBar.route: (context) => const PluginScaleBar(),
PluginZoomButtons.route: (context) => const PluginZoomButtons(),
OfflineMapPage.route: (context) => const OfflineMapPage(),
BundledOfflineMapPage.route: (context) => const BundledOfflineMapPage(),
MovingMarkersPage.route: (context) => const MovingMarkersPage(),
ManyCirclesPage.route: (context) => const ManyCirclesPage(),
CirclePage.route: (context) => const CirclePage(),
Expand All @@ -82,8 +82,7 @@ class MyApp extends StatelessWidget {
const ScreenPointToLatLngPage(),
LatLngToScreenPointPage.route: (context) =>
const LatLngToScreenPointPage(),
FallbackUrlNetworkPage.route: (context) =>
const FallbackUrlNetworkPage(),
FallbackUrlPage.route: (context) => const FallbackUrlPage(),
SecondaryTapPage.route: (context) => const SecondaryTapPage(),
RetinaPage.route: (context) => const RetinaPage(),
},
Expand Down
10 changes: 10 additions & 0 deletions example/lib/misc/tile_providers.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_map_cancellable_tile_provider/flutter_map_cancellable_tile_provider.dart';

TileLayer get openStreetMapTileLayer => TileLayer(
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
userAgentPackageName: 'dev.fleaflet.flutter_map.example',
// Use the recommended flutter_map_cancellable_tile_provider package to
// support the cancellation of loading tiles.
tileProvider: CancellableNetworkTileProvider(),
);
Loading

0 comments on commit 670cb36

Please sign in to comment.