diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 49021c544..4c60520c3 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -29,7 +29,7 @@ jobs:
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
- flutter-version: 3.22
+ flutter-version: 3.24
cache: true
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:"
cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:"
diff --git a/docs/docs.sh b/docs/docs.sh
index a99490ac7..e5144a4ac 100755
--- a/docs/docs.sh
+++ b/docs/docs.sh
@@ -77,6 +77,13 @@ if [ $arg1 == "build" ]; then
echo "Failed to build the example project"
exit 1
fi
+ # Run build_runner to generate files in the `test` directory
+ dart run build_runner build
+ if [ $? -ne 0 ]; then
+ echo "Failed to build the example project"
+ exit 1
+ fi
+
flutter build web --base-href "/examples/app/" --no-web-resources-cdn
if [ $? -ne 0 ]; then
echo "Failed to build the example project"
diff --git a/docs/docs/Examples/flutter.md b/docs/docs/Examples/flutter.md
new file mode 100644
index 000000000..422b2ad97
--- /dev/null
+++ b/docs/docs/Examples/flutter.md
@@ -0,0 +1,17 @@
+---
+
+title: Flutter
+description: An example app using drift in a Flutter app
+
+---
+
+For a comprehensive example of a cross-platform Flutter app that incorporates drift and follows best practices, refer to the [app example](https://github.com/simolus3/drift/tree/develop/examples/app) in drift's repository.
+
+This example serves as an excellent starting point for users interested in exploring how to integrate drift into a Flutter app with a modern architecture.
+
+
+
+
+[:simple-github: Github](https://github.com/simolus3/drift/tree/develop/examples/app){ .md-button .md-button--primary }
+
+
diff --git a/docs/mkdocs/mkdocs.yml b/docs/mkdocs/mkdocs.yml
index fc529bb1a..0a49aef27 100644
--- a/docs/mkdocs/mkdocs.yml
+++ b/docs/mkdocs/mkdocs.yml
@@ -134,11 +134,11 @@ nav:
- upgrading.md
- Examples:
- Examples/index.md
+ - Examples/flutter.md
- Examples/relationships.md
- Examples/tracing.md
- Examples/server_sync.md
- Examples/existing_databases.md
- - Examples/more.md
- Tools:
- Tools/index.md
- Tools/devtools.md
diff --git a/examples/app/.metadata b/examples/app/.metadata
index 391c336b2..009f8afe9 100644
--- a/examples/app/.metadata
+++ b/examples/app/.metadata
@@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.
version:
- revision: "5874a72aa4c779a02553007c47dacbefba2374dc"
+ revision: "efbf63d9c66b9f6ec30e9ad4611189aa80003d31"
channel: "stable"
project_type: app
@@ -13,26 +13,26 @@ project_type: app
migration:
platforms:
- platform: root
- create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
- base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
+ create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
+ base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
- platform: android
- create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
- base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
+ create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
+ base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
- platform: ios
- create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
- base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
+ create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
+ base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
- platform: linux
- create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
- base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
+ create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
+ base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
- platform: macos
- create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
- base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
+ create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
+ base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
- platform: web
- create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
- base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
+ create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
+ base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
- platform: windows
- create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
- base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
+ create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
+ base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
# User provided section
diff --git a/examples/app/android/.gitignore b/examples/app/android/.gitignore
index 55afd919c..6f568019d 100644
--- a/examples/app/android/.gitignore
+++ b/examples/app/android/.gitignore
@@ -7,7 +7,7 @@ gradle-wrapper.jar
GeneratedPluginRegistrant.java
# Remember to never publicly share your keystore.
-# See https://flutter.dev/to/reference-keystore
+# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
**/*.keystore
**/*.jks
diff --git a/examples/app/android/app/build.gradle b/examples/app/android/app/build.gradle
index 54b6d53c0..afc95aa05 100644
--- a/examples/app/android/app/build.gradle
+++ b/examples/app/android/app/build.gradle
@@ -1,44 +1,72 @@
-plugins {
- id "com.android.application"
- id "kotlin-android"
- // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
- id "dev.flutter.flutter-gradle-plugin"
+def localProperties = new Properties()
+def localPropertiesFile = rootProject.file('local.properties')
+if (localPropertiesFile.exists()) {
+ localPropertiesFile.withReader('UTF-8') { reader ->
+ localProperties.load(reader)
+ }
+}
+
+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 = '1'
+}
+
+def flutterVersionName = localProperties.getProperty('flutter.versionName')
+if (flutterVersionName == null) {
+ flutterVersionName = '1.0'
}
+apply plugin: 'com.android.application'
+apply plugin: 'kotlin-android'
+apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
+
android {
- namespace = "com.example.app"
- compileSdk = flutter.compileSdkVersion
- ndkVersion = flutter.ndkVersion
+ compileSdkVersion flutter.compileSdkVersion
compileOptions {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
- jvmTarget = JavaVersion.VERSION_1_8
+ 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 = "com.example.app"
- // 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
- targetSdk = flutter.targetSdkVersion
- versionCode = flutter.versionCode
- versionName = flutter.versionName
+ applicationId "com.example.app"
+ minSdkVersion flutter.minSdkVersion
+ targetSdkVersion flutter.targetSdkVersion
+ versionCode flutterVersionCode.toInteger()
+ versionName flutterVersionName
+
+ ndk {
+ abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64'
+ }
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
- signingConfig = signingConfigs.debug
+ signingConfig signingConfigs.debug
}
}
}
flutter {
- source = "../.."
+ source '../..'
+}
+
+dependencies {
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
diff --git a/examples/app/android/app/src/debug/AndroidManifest.xml b/examples/app/android/app/src/debug/AndroidManifest.xml
index 399f6981d..99f406bd5 100644
--- a/examples/app/android/app/src/debug/AndroidManifest.xml
+++ b/examples/app/android/app/src/debug/AndroidManifest.xml
@@ -1,6 +1,6 @@
-
-
diff --git a/examples/app/android/app/src/main/AndroidManifest.xml b/examples/app/android/app/src/main/AndroidManifest.xml
index 6ee3df00c..3f2d4034f 100644
--- a/examples/app/android/app/src/main/AndroidManifest.xml
+++ b/examples/app/android/app/src/main/AndroidManifest.xml
@@ -1,5 +1,6 @@
-
-
+
@@ -7,7 +8,6 @@
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
- android:taskAffinity=""
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
@@ -31,15 +31,4 @@
android:name="flutterEmbedding"
android:value="2" />
-
-
-
-
-
-
-
diff --git a/examples/app/android/app/src/main/kotlin/com/example/app/MainActivity.kt b/examples/app/android/app/src/main/kotlin/com/example/app/MainActivity.kt
index 026d9a938..461fcfba3 100644
--- a/examples/app/android/app/src/main/kotlin/com/example/app/MainActivity.kt
+++ b/examples/app/android/app/src/main/kotlin/com/example/app/MainActivity.kt
@@ -2,4 +2,5 @@ package com.example.app
import io.flutter.embedding.android.FlutterActivity
-class MainActivity: FlutterActivity()
+class MainActivity: FlutterActivity() {
+}
diff --git a/examples/app/android/app/src/main/res/values-night/styles.xml b/examples/app/android/app/src/main/res/values-night/styles.xml
index 06952be74..3db14bb53 100644
--- a/examples/app/android/app/src/main/res/values-night/styles.xml
+++ b/examples/app/android/app/src/main/res/values-night/styles.xml
@@ -3,7 +3,7 @@
diff --git a/examples/app/android/build.gradle b/examples/app/android/build.gradle
index d2ffbffa4..5da9e951e 100644
--- a/examples/app/android/build.gradle
+++ b/examples/app/android/build.gradle
@@ -1,3 +1,17 @@
+
+buildscript {
+ ext.kotlin_version = '1.6.10'
+ repositories {
+ google()
+ mavenCentral()
+ }
+
+ dependencies {
+ classpath 'com.android.tools.build:gradle:7.4.2'
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ }
+}
+
allprojects {
repositories {
google()
@@ -5,12 +19,12 @@ allprojects {
}
}
-rootProject.buildDir = "../build"
+rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
- project.evaluationDependsOn(":app")
+ project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
diff --git a/examples/app/android/gradle.properties b/examples/app/android/gradle.properties
index 259717082..94adc3a3f 100644
--- a/examples/app/android/gradle.properties
+++ b/examples/app/android/gradle.properties
@@ -1,3 +1,3 @@
-org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
+org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
diff --git a/examples/app/android/gradle/wrapper/gradle-wrapper.properties b/examples/app/android/gradle/wrapper/gradle-wrapper.properties
index e1ca574ef..6b665338b 100644
--- a/examples/app/android/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/app/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,6 @@
+#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
diff --git a/examples/app/android/settings.gradle b/examples/app/android/settings.gradle
index 536165d35..44e62bcf0 100644
--- a/examples/app/android/settings.gradle
+++ b/examples/app/android/settings.gradle
@@ -1,25 +1,11 @@
-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
- }()
+include ':app'
- includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
+def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
+def properties = new Properties()
- repositories {
- google()
- mavenCentral()
- gradlePluginPortal()
- }
-}
+assert localPropertiesFile.exists()
+localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
-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
-}
-
-include ":app"
+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"
diff --git a/examples/app/pubspec.yaml b/examples/app/pubspec.yaml
index a5cbd6563..13454edd6 100644
--- a/examples/app/pubspec.yaml
+++ b/examples/app/pubspec.yaml
@@ -1,6 +1,6 @@
name: app
description: A cross-platform todo tracker built with drift.
-publish_to: 'none'
+publish_to: "none"
version: 1.0.0+1