Skip to content

Commit f76598a

Browse files
feat: create new web an android example setup
1 parent ba760d2 commit f76598a

File tree

12 files changed

+79
-158
lines changed

12 files changed

+79
-158
lines changed

example/.metadata

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
# This file tracks properties of this Flutter project.
22
# Used by Flutter tool to assess capabilities and perform upgrades etc.
33
#
4-
# This file should be version controlled.
4+
# This file should be version controlled and should not be manually edited.
55

66
version:
7-
revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
8-
channel: stable
7+
revision: "80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819"
8+
channel: "stable"
99

1010
project_type: app
1111

1212
# Tracks metadata for the flutter migrate command
1313
migration:
1414
platforms:
1515
- platform: root
16-
create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
17-
base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
16+
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
17+
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
1818
- platform: android
19-
create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
20-
base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
19+
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
20+
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
21+
- platform: web
22+
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
23+
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
2124

2225
# User provided section
2326

example/android/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ gradle-wrapper.jar
77
GeneratedPluginRegistrant.java
88

99
# Remember to never publicly share your keystore.
10-
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
10+
# See https://flutter.dev/to/reference-keystore
1111
key.properties
1212
**/*.keystore
1313
**/*.jks

example/android/app/build.gradle

Lines changed: 19 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,44 @@
1-
def localProperties = new Properties()
2-
def localPropertiesFile = rootProject.file('local.properties')
3-
if (localPropertiesFile.exists()) {
4-
localPropertiesFile.withReader('UTF-8') { reader ->
5-
localProperties.load(reader)
6-
}
7-
}
8-
9-
def flutterRoot = localProperties.getProperty('flutter.sdk')
10-
if (flutterRoot == null) {
11-
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12-
}
13-
14-
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15-
if (flutterVersionCode == null) {
16-
flutterVersionCode = '1'
17-
}
18-
19-
def flutterVersionName = localProperties.getProperty('flutter.versionName')
20-
if (flutterVersionName == null) {
21-
flutterVersionName = '1.0'
1+
plugins {
2+
id "com.android.application"
3+
id "kotlin-android"
4+
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
5+
id "dev.flutter.flutter-gradle-plugin"
226
}
237

24-
apply plugin: 'com.android.application'
25-
apply plugin: 'kotlin-android'
26-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27-
288
android {
29-
namespace "dev.formbuilderfilepicker.example"
30-
compileSdkVersion flutter.compileSdkVersion
31-
ndkVersion flutter.ndkVersion
9+
namespace = "com.example.form_builder_file_picker"
10+
compileSdk = flutter.compileSdkVersion
11+
ndkVersion = flutter.ndkVersion
3212

3313
compileOptions {
34-
sourceCompatibility JavaVersion.VERSION_1_8
35-
targetCompatibility JavaVersion.VERSION_1_8
14+
sourceCompatibility = JavaVersion.VERSION_1_8
15+
targetCompatibility = JavaVersion.VERSION_1_8
3616
}
3717

3818
kotlinOptions {
39-
jvmTarget = '1.8'
40-
}
41-
42-
sourceSets {
43-
main.java.srcDirs += 'src/main/kotlin'
19+
jvmTarget = JavaVersion.VERSION_1_8
4420
}
4521

4622
defaultConfig {
4723
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
48-
applicationId "dev.formbuilderfilepicker.example"
24+
applicationId = "com.example.form_builder_file_picker"
4925
// You can update the following values to match your application needs.
50-
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
51-
minSdkVersion flutter.minSdkVersion
52-
targetSdkVersion flutter.targetSdkVersion
53-
versionCode flutterVersionCode.toInteger()
54-
versionName flutterVersionName
26+
// For more information, see: https://flutter.dev/to/review-gradle-config.
27+
minSdk = flutter.minSdkVersion
28+
targetSdk = flutter.targetSdkVersion
29+
versionCode = flutter.versionCode
30+
versionName = flutter.versionName
5531
}
5632

5733
buildTypes {
5834
release {
5935
// TODO: Add your own signing config for the release build.
6036
// Signing with the debug keys for now, so `flutter run --release` works.
61-
signingConfig signingConfigs.debug
37+
signingConfig = signingConfigs.debug
6238
}
6339
}
6440
}
6541

6642
flutter {
67-
source '../..'
68-
}
69-
70-
dependencies {
71-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
43+
source = "../.."
7244
}

example/android/app/src/main/AndroidManifest.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
22
<application
3-
android:label="example"
3+
android:label="form_builder_file_picker"
44
android:name="${applicationName}"
55
android:icon="@mipmap/ic_launcher">
66
<activity
77
android:name=".MainActivity"
88
android:exported="true"
99
android:launchMode="singleTop"
10+
android:taskAffinity=""
1011
android:theme="@style/LaunchTheme"
1112
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
1213
android:hardwareAccelerated="true"
@@ -30,4 +31,15 @@
3031
android:name="flutterEmbedding"
3132
android:value="2" />
3233
</application>
34+
<!-- Required to query activities that can process text, see:
35+
https://developer.android.com/training/package-visibility and
36+
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
37+
38+
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
39+
<queries>
40+
<intent>
41+
<action android:name="android.intent.action.PROCESS_TEXT"/>
42+
<data android:mimeType="text/plain"/>
43+
</intent>
44+
</queries>
3345
</manifest>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.example.form_builder_file_picker
2+
3+
import io.flutter.embedding.android.FlutterActivity
4+
5+
class MainActivity: FlutterActivity()

example/android/app/src/main/kotlin/dev/formbuilderfilepicker/example/MainActivity.kt

Lines changed: 0 additions & 6 deletions
This file was deleted.

example/android/build.gradle

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,16 @@
1-
buildscript {
2-
ext.kotlin_version = '1.7.10'
3-
repositories {
4-
google()
5-
mavenCentral()
6-
}
7-
8-
dependencies {
9-
classpath 'com.android.tools.build:gradle:7.3.0'
10-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11-
}
12-
}
13-
141
allprojects {
152
repositories {
163
google()
174
mavenCentral()
185
}
196
}
207

21-
rootProject.buildDir = '../build'
8+
rootProject.buildDir = "../build"
229
subprojects {
2310
project.buildDir = "${rootProject.buildDir}/${project.name}"
2411
}
2512
subprojects {
26-
project.evaluationDependsOn(':app')
13+
project.evaluationDependsOn(":app")
2714
}
2815

2916
tasks.register("clean", Delete) {

example/android/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
org.gradle.jvmargs=-Xmx1536M
1+
org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
22
android.useAndroidX=true
33
android.enableJetifier=true

example/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip

example/android/settings.gradle

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1-
include ':app'
1+
pluginManagement {
2+
def flutterSdkPath = {
3+
def properties = new Properties()
4+
file("local.properties").withInputStream { properties.load(it) }
5+
def flutterSdkPath = properties.getProperty("flutter.sdk")
6+
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
7+
return flutterSdkPath
8+
}()
29

3-
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4-
def properties = new Properties()
10+
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
511

6-
assert localPropertiesFile.exists()
7-
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
12+
repositories {
13+
google()
14+
mavenCentral()
15+
gradlePluginPortal()
16+
}
17+
}
818

9-
def flutterSdkPath = properties.getProperty("flutter.sdk")
10-
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11-
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
19+
plugins {
20+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21+
id "com.android.application" version "7.3.0" apply false
22+
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
23+
}
24+
25+
include ":app"

example/web/index.html

Lines changed: 3 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -23,82 +23,16 @@
2323
<!-- iOS meta tags & icons -->
2424
<meta name="apple-mobile-web-app-capable" content="yes">
2525
<meta name="apple-mobile-web-app-status-bar-style" content="black">
26-
<meta name="apple-mobile-web-app-title" content="example">
26+
<meta name="apple-mobile-web-app-title" content="form_builder_file_picker">
2727
<link rel="apple-touch-icon" href="icons/Icon-192.png">
2828

2929
<!-- Favicon -->
3030
<link rel="icon" type="image/png" href="favicon.png"/>
3131

32-
<title>example</title>
32+
<title>form_builder_file_picker</title>
3333
<link rel="manifest" href="manifest.json">
3434
</head>
3535
<body>
36-
<!-- This script installs service_worker.js to provide PWA functionality to
37-
application. For more information, see:
38-
https://developers.google.com/web/fundamentals/primers/service-workers -->
39-
<script>
40-
var serviceWorkerVersion = null;
41-
var scriptLoaded = false;
42-
function loadMainDartJs() {
43-
if (scriptLoaded) {
44-
return;
45-
}
46-
scriptLoaded = true;
47-
var scriptTag = document.createElement('script');
48-
scriptTag.src = 'main.dart.js';
49-
scriptTag.type = 'application/javascript';
50-
document.body.append(scriptTag);
51-
}
52-
53-
if ('serviceWorker' in navigator) {
54-
// Service workers are supported. Use them.
55-
window.addEventListener('load', function () {
56-
// Wait for registration to finish before dropping the <script> tag.
57-
// Otherwise, the browser will load the script multiple times,
58-
// potentially different versions.
59-
var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
60-
navigator.serviceWorker.register(serviceWorkerUrl)
61-
.then((reg) => {
62-
function waitForActivation(serviceWorker) {
63-
serviceWorker.addEventListener('statechange', () => {
64-
if (serviceWorker.state == 'activated') {
65-
console.log('Installed new service worker.');
66-
loadMainDartJs();
67-
}
68-
});
69-
}
70-
if (!reg.active && (reg.installing || reg.waiting)) {
71-
// No active web worker and we have installed or are installing
72-
// one for the first time. Simply wait for it to activate.
73-
waitForActivation(reg.installing || reg.waiting);
74-
} else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
75-
// When the app updates the serviceWorkerVersion changes, so we
76-
// need to ask the service worker to update.
77-
console.log('New service worker available.');
78-
reg.update();
79-
waitForActivation(reg.installing);
80-
} else {
81-
// Existing service worker is still good.
82-
console.log('Loading app from service worker.');
83-
loadMainDartJs();
84-
}
85-
});
86-
87-
// If service worker doesn't succeed in a reasonable amount of time,
88-
// fallback to plaint <script> tag.
89-
setTimeout(() => {
90-
if (!scriptLoaded) {
91-
console.warn(
92-
'Failed to load app from service worker. Falling back to plain <script> tag.',
93-
);
94-
loadMainDartJs();
95-
}
96-
}, 4000);
97-
});
98-
} else {
99-
// Service workers not supported. Just drop the <script> tag.
100-
loadMainDartJs();
101-
}
102-
</script>
36+
<script src="flutter_bootstrap.js" async></script>
10337
</body>
10438
</html>

example/web/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "example",
3-
"short_name": "example",
2+
"name": "form_builder_file_picker",
3+
"short_name": "form_builder_file_picker",
44
"start_url": ".",
55
"display": "standalone",
66
"background_color": "#0175C2",

0 commit comments

Comments
 (0)