Skip to content

Commit

Permalink
#6 Added ArcGIS Maps SDK for Flutter and setup for global variables
Browse files Browse the repository at this point in the history
  • Loading branch information
esride-ale committed Oct 18, 2024
1 parent 7d0a4ca commit 7652ff3
Show file tree
Hide file tree
Showing 76 changed files with 856 additions and 3,118 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Exclude arcgis_maps_package
arcgis_maps_package/


# Mono auto generated files
mono_crash.*

Expand Down
2 changes: 2 additions & 0 deletions native-apps/urban-heat-notifier/urban_heat_notifier/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
APIKEY=<your_api_key>
# add more keys here if needed
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Miscellaneous
arcgis_maps_core
*.so
*.class
*.log
*.pyc
Expand Down Expand Up @@ -30,6 +32,8 @@ migrate_working_dir/
.pub-cache/
.pub/
/build/
pubspec.lock
.packages

# Symbolication related
app.*.symbols
Expand All @@ -41,3 +45,7 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release

# Obfuscation related
#.env
env.g.dart
12 changes: 0 additions & 12 deletions native-apps/urban-heat-notifier/urban_heat_notifier/.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,6 @@ migration:
- platform: ios
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: linux
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: macos
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: web
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: windows
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819

# User provided section

Expand Down
75 changes: 67 additions & 8 deletions native-apps/urban-heat-notifier/urban_heat_notifier/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,75 @@
# urban_heat_notifier

A new Flutter project.
## Overview

This project is based on the ArcGIS Maps SDK for Flutter (Beta 2) and ArcGIS Location Platform. Users will be notified when they are in a heat-risk area. They can display POIs with options for cooling down/drinking or where they can get help and can navigate there with a compass.

## Getting Started

This project is a starting point for a Flutter application.
To build this app, you will require the following:

1. Install Flutter: Follow the instructions on the Flutter documentation [get started guide](https://docs.flutter.dev/get-started/install). Xcode and Android Studio are required for their respective platforms, and Visual Studio Code is the recommended IDE.

2. Download the ArcGIS Maps SDK for Flutter beta: Access the beta by registering on Esri’s [Early Adopter website](https://earlyadopter.esri.com/project/home.html?cap=%7Bdd2444fc-5d36-44bb-8384-4a56046b9580%7D). Refer to the documentation there on how to get started.

3. API key: You will require an API key access token to authenticate the basemap services used in this application. Learn how to create one on the Esri [Developers website](https://developers.arcgis.com/documentation/security-and-authentication/api-key-authentication/tutorials/create-an-api-key/)


Step 1: Download ArcGIS Maps SDK for Flutter Beta 2

Unpack the arcgis_maps_package archive into the same parent directory as your app:

parent_directory
|
|__ urban_heat_notifier
|
|__ arcgis_maps_package


Navigate to the `urban_heat_notifier` directory.

```
cd urban_heat_notifier
```

Use `flutter pub upgrade` to configure the dependencies.

```
flutter pub upgrade
```

Step 2: Configure environment variables (based on [ENVied](https://pub.dev/packages/envied))

Edit the .env configuration file

- insert your API Key --> APIKEY=......
-
-

Use `dart run build_runner build` to run the generator:

```
dart run build_runner build
```

Step 3 Run the application

```
flutter run
```

## Licensing

Copyright 2024 Esri Deutschland GmbH

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

A few resources to get you started if this is your first Flutter project:
A copy of the license is available in the repository's LICENSE file.

- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)

For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
[ENVied](https://pub.dev/packages/envied):
MIT © Peter Cinibulk
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ plugins {
}

android {
namespace = "com.example.urban_heat_notifier"
namespace = "com.esridech.urban_heat_notifier"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
ndkVersion = "25.2.9519653"

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -21,10 +21,10 @@ android {

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.example.urban_heat_notifier"
applicationId = "com.esridech.urban_heat_notifier"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion
minSdk = 26
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:label="urban_heat_notifier"
android:name="${applicationName}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.urban_heat_notifier
package com.esridech.urban_heat_notifier

import io.flutter.embedding.android.FlutterActivity

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pluginManagement {
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
id "org.jetbrains.kotlin.android" version "1.9.0" apply false
}

include ":app"
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.urbanHeatNotifier;
PRODUCT_BUNDLE_IDENTIFIER = com.esridech.urbanHeatNotifier;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand All @@ -384,7 +384,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.urbanHeatNotifier.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = com.esridech.urbanHeatNotifier.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -401,7 +401,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.urbanHeatNotifier.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = com.esridech.urbanHeatNotifier.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
Expand All @@ -416,7 +416,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.urbanHeatNotifier.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = com.esridech.urbanHeatNotifier.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
Expand Down Expand Up @@ -547,7 +547,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.urbanHeatNotifier;
PRODUCT_BUNDLE_IDENTIFIER = com.esridech.urbanHeatNotifier;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -569,7 +569,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.urbanHeatNotifier;
PRODUCT_BUNDLE_IDENTIFIER = com.esridech.urbanHeatNotifier;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'package:envied/envied.dart';

part 'env.g.dart';

@Envied(path: '.env')
abstract class Env {
@EnviedField(varName: 'APIKEY', obfuscate: true)
static final String apikey = _Env.apikey;
}
121 changes: 10 additions & 111 deletions native-apps/urban-heat-notifier/urban_heat_notifier/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,125 +1,24 @@
import 'package:flutter/material.dart';
import 'package:arcgis_maps/arcgis_maps.dart';
import 'env/env.dart';

void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});
ArcGISEnvironment.apiKey = Env.apikey;

// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// TRY THIS: Try running your application with "flutter run". You'll see
// the application has a purple toolbar. Then, without quitting the app,
// try changing the seedColor in the colorScheme below to Colors.green
// and then invoke "hot reload" (save your changes or press the "hot
// reload" button in a Flutter-supported IDE, or press "r" if you used
// the command line to start the app).
//
// Notice that the counter didn't reset back to zero; the application
// state is not lost during the reload. To reset the state, use hot
// restart instead.
//
// This works for code too, not just values: Most code changes can be
// tested with just a hot reload.
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
runApp(const MaterialApp(home: MyApp()));
}

class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});

// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.

// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".

final String title;

@override
State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;

void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}
class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// TRY THIS: Try changing the color here to a specific color (to
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
// change color while the other colors stay the same.
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
body: ArcGISMapView(
controllerProvider: () => ArcGISMapView.createController()
..arcGISMap = ArcGISMap.withBasemapStyle(BasemapStyle.arcGISTopographic),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
//
// TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
// action in the IDE, or press "p" in the console), to see the
// wireframe for each widget.
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
}

This file was deleted.

Loading

0 comments on commit 7652ff3

Please sign in to comment.