From bd0886e3277613bacd3ce9b919aed3a104a81030 Mon Sep 17 00:00:00 2001 From: Aruhant <125254014+aruhant@users.noreply.github.com> Date: Wed, 6 Dec 2023 20:32:18 -0800 Subject: [PATCH 1/2] Updating the examples to compile with Flutter 3.16 --- example/example_01/.gitignore | 5 +- example/example_01/.metadata | 39 ++++- example/example_01/README.md | 8 +- example/example_01/analysis_options.yaml | 46 ++--- example/example_01/android/.gitignore | 2 + example/example_01/android/app/build.gradle | 38 +++-- .../android/app/src/debug/AndroidManifest.xml | 6 +- .../android/app/src/main/AndroidManifest.xml | 16 +- .../app/src/main/res/values-night/styles.xml | 4 +- .../app/src/main/res/values/styles.xml | 4 +- .../app/src/profile/AndroidManifest.xml | 6 +- example/example_01/android/build.gradle | 11 +- example/example_01/android/gradle.properties | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 3 +- example/example_01/android/settings.gradle | 34 +++- example/example_01/ios/.gitignore | 1 + .../ios/Flutter/AppFrameworkInfo.plist | 2 +- .../ios/Runner.xcodeproj/project.pbxproj | 161 +++++++++++++++++- .../xcshareddata/xcschemes/Runner.xcscheme | 21 ++- example/example_01/ios/Runner/Info.plist | 8 +- .../ios/RunnerTests/RunnerTests.swift | 12 ++ example/example_01/linux/CMakeLists.txt | 43 ++++- .../example_01/linux/flutter/CMakeLists.txt | 1 + example/example_01/linux/my_application.cc | 19 +-- example/example_01/macos/.gitignore | 1 + .../macos/Runner.xcodeproj/project.pbxproj | 133 ++++++++++++++- .../xcshareddata/xcschemes/Runner.xcscheme | 19 ++- .../macos/Runner/Base.lproj/MainMenu.xib | 4 + .../macos/Runner/Configs/AppInfo.xcconfig | 2 +- .../macos/Runner/MainFlutterWindow.swift | 2 +- .../macos/RunnerTests/RunnerTests.swift | 12 ++ example/example_01/pubspec.yaml | 18 +- example/example_01/test/widget_test.dart | 4 +- example/example_01/web/index.html | 89 +++------- example/example_01/web/manifest.json | 12 ++ example/example_01/windows/CMakeLists.txt | 31 +++- .../example_01/windows/flutter/CMakeLists.txt | 10 +- .../example_01/windows/runner/CMakeLists.txt | 26 ++- example/example_01/windows/runner/Runner.rc | 14 +- .../windows/runner/flutter_window.cpp | 17 +- .../windows/runner/flutter_window.h | 10 +- example/example_01/windows/runner/main.cpp | 13 +- .../example_01/windows/runner/run_loop.cpp | 66 ------- example/example_01/windows/runner/run_loop.h | 40 ----- .../windows/runner/runner.exe.manifest | 2 +- example/example_01/windows/runner/utils.cpp | 13 +- .../windows/runner/win32_window.cpp | 55 +++++- .../example_01/windows/runner/win32_window.h | 20 ++- example/example_02/.gitignore | 4 +- example/example_02/.metadata | 39 ++++- example/example_02/README.md | 8 +- example/example_02/analysis_options.yaml | 46 ++--- example/example_02/android/.gitignore | 2 + example/example_02/android/app/build.gradle | 38 +++-- .../android/app/src/debug/AndroidManifest.xml | 6 +- .../android/app/src/main/AndroidManifest.xml | 16 +- .../app/src/main/res/values-night/styles.xml | 4 +- .../app/src/main/res/values/styles.xml | 4 +- .../app/src/profile/AndroidManifest.xml | 6 +- example/example_02/android/build.gradle | 11 +- example/example_02/android/gradle.properties | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 3 +- example/example_02/android/settings.gradle | 34 +++- example/example_02/ios/.gitignore | 1 + .../ios/Flutter/AppFrameworkInfo.plist | 2 +- .../ios/Runner.xcodeproj/project.pbxproj | 161 +++++++++++++++++- .../xcshareddata/xcschemes/Runner.xcscheme | 21 ++- example/example_02/ios/Runner/Info.plist | 8 +- .../ios/RunnerTests/RunnerTests.swift | 12 ++ example/example_02/linux/CMakeLists.txt | 43 ++++- .../example_02/linux/flutter/CMakeLists.txt | 1 + example/example_02/linux/my_application.cc | 19 +-- example/example_02/macos/.gitignore | 1 + .../macos/Runner.xcodeproj/project.pbxproj | 133 ++++++++++++++- .../xcshareddata/xcschemes/Runner.xcscheme | 19 ++- .../macos/Runner/Base.lproj/MainMenu.xib | 4 + .../macos/Runner/Configs/AppInfo.xcconfig | 2 +- .../macos/Runner/MainFlutterWindow.swift | 2 +- .../macos/RunnerTests/RunnerTests.swift | 12 ++ example/example_02/pubspec.yaml | 20 +-- example/example_02/test/widget_test.dart | 4 +- example/example_02/web/index.html | 89 +++------- example/example_02/web/manifest.json | 12 ++ example/example_02/windows/CMakeLists.txt | 31 +++- .../example_02/windows/flutter/CMakeLists.txt | 10 +- .../example_02/windows/runner/CMakeLists.txt | 26 ++- example/example_02/windows/runner/Runner.rc | 14 +- .../windows/runner/flutter_window.cpp | 17 +- .../windows/runner/flutter_window.h | 10 +- example/example_02/windows/runner/main.cpp | 13 +- .../example_02/windows/runner/run_loop.cpp | 66 ------- example/example_02/windows/runner/run_loop.h | 40 ----- .../windows/runner/runner.exe.manifest | 2 +- example/example_02/windows/runner/utils.cpp | 13 +- .../windows/runner/win32_window.cpp | 55 +++++- .../example_02/windows/runner/win32_window.h | 20 ++- example/example_03/.gitignore | 5 +- example/example_03/.metadata | 39 ++++- example/example_03/README.md | 8 +- example/example_03/analysis_options.yaml | 46 ++--- example/example_03/android/.gitignore | 2 + example/example_03/android/app/build.gradle | 38 +++-- .../android/app/src/debug/AndroidManifest.xml | 6 +- .../android/app/src/main/AndroidManifest.xml | 16 +- .../app/src/main/res/values-night/styles.xml | 4 +- .../app/src/main/res/values/styles.xml | 4 +- .../app/src/profile/AndroidManifest.xml | 6 +- example/example_03/android/build.gradle | 11 +- example/example_03/android/gradle.properties | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 3 +- example/example_03/android/settings.gradle | 34 +++- example/example_03/ios/.gitignore | 1 + .../ios/Flutter/AppFrameworkInfo.plist | 2 +- example/example_03/ios/Podfile | 5 +- .../ios/Runner.xcodeproj/project.pbxproj | 161 +++++++++++++++++- .../xcshareddata/xcschemes/Runner.xcscheme | 21 ++- example/example_03/ios/Runner/Info.plist | 8 +- .../ios/RunnerTests/RunnerTests.swift | 12 ++ example/example_03/linux/CMakeLists.txt | 43 ++++- .../example_03/linux/flutter/CMakeLists.txt | 1 + example/example_03/linux/my_application.cc | 19 +-- example/example_03/macos/.gitignore | 1 + example/example_03/macos/Podfile | 5 +- .../macos/Runner.xcodeproj/project.pbxproj | 133 ++++++++++++++- .../xcshareddata/xcschemes/Runner.xcscheme | 19 ++- .../macos/Runner/Base.lproj/MainMenu.xib | 4 + .../macos/Runner/Configs/AppInfo.xcconfig | 2 +- .../macos/Runner/MainFlutterWindow.swift | 2 +- .../macos/RunnerTests/RunnerTests.swift | 12 ++ example/example_03/pubspec.yaml | 22 ++- example/example_03/test/widget_test.dart | 4 +- example/example_03/web/index.html | 89 +++------- example/example_03/web/manifest.json | 12 ++ example/example_03/windows/CMakeLists.txt | 31 +++- .../example_03/windows/flutter/CMakeLists.txt | 10 +- .../example_03/windows/runner/CMakeLists.txt | 26 ++- example/example_03/windows/runner/Runner.rc | 14 +- .../windows/runner/flutter_window.cpp | 17 +- .../windows/runner/flutter_window.h | 10 +- example/example_03/windows/runner/main.cpp | 13 +- .../example_03/windows/runner/run_loop.cpp | 66 ------- example/example_03/windows/runner/run_loop.h | 40 ----- .../windows/runner/runner.exe.manifest | 2 +- example/example_03/windows/runner/utils.cpp | 13 +- .../windows/runner/win32_window.cpp | 55 +++++- .../example_03/windows/runner/win32_window.h | 20 ++- example/example_04/.gitignore | 5 +- example/example_04/.metadata | 39 ++++- example/example_04/README.md | 8 +- example/example_04/analysis_options.yaml | 46 ++--- example/example_04/android/.gitignore | 2 + example/example_04/android/app/build.gradle | 38 +++-- .../android/app/src/debug/AndroidManifest.xml | 6 +- .../android/app/src/main/AndroidManifest.xml | 19 +-- .../app/src/main/res/values-night/styles.xml | 4 +- .../app/src/main/res/values/styles.xml | 4 +- .../app/src/profile/AndroidManifest.xml | 6 +- example/example_04/android/build.gradle | 11 +- example/example_04/android/gradle.properties | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 3 +- example/example_04/android/settings.gradle | 34 +++- example/example_04/ios/.gitignore | 1 + .../ios/Flutter/AppFrameworkInfo.plist | 2 +- example/example_04/ios/Podfile | 5 +- .../ios/Runner.xcodeproj/project.pbxproj | 161 +++++++++++++++++- .../xcshareddata/xcschemes/Runner.xcscheme | 21 ++- example/example_04/ios/Runner/Info.plist | 8 +- .../ios/RunnerTests/RunnerTests.swift | 12 ++ example/example_04/linux/CMakeLists.txt | 43 ++++- .../example_04/linux/flutter/CMakeLists.txt | 1 + example/example_04/linux/my_application.cc | 19 +-- example/example_04/macos/.gitignore | 1 + .../Flutter/GeneratedPluginRegistrant.swift | 2 +- example/example_04/macos/Podfile | 5 +- .../macos/Runner.xcodeproj/project.pbxproj | 133 ++++++++++++++- .../xcshareddata/xcschemes/Runner.xcscheme | 19 ++- .../macos/Runner/Base.lproj/MainMenu.xib | 4 + .../macos/Runner/Configs/AppInfo.xcconfig | 2 +- .../macos/Runner/MainFlutterWindow.swift | 2 +- .../macos/RunnerTests/RunnerTests.swift | 12 ++ example/example_04/pubspec.yaml | 26 ++- example/example_04/test/widget_test.dart | 4 +- example/example_04/web/index.html | 89 +++------- example/example_04/web/manifest.json | 12 ++ example/example_04/windows/CMakeLists.txt | 31 +++- .../example_04/windows/flutter/CMakeLists.txt | 10 +- .../flutter/generated_plugin_registrant.cc | 3 + .../windows/flutter/generated_plugins.cmake | 1 + .../example_04/windows/runner/CMakeLists.txt | 26 ++- example/example_04/windows/runner/Runner.rc | 14 +- .../windows/runner/flutter_window.cpp | 17 +- .../windows/runner/flutter_window.h | 10 +- example/example_04/windows/runner/main.cpp | 13 +- .../example_04/windows/runner/run_loop.cpp | 66 ------- example/example_04/windows/runner/run_loop.h | 40 ----- .../windows/runner/runner.exe.manifest | 2 +- example/example_04/windows/runner/utils.cpp | 13 +- .../windows/runner/win32_window.cpp | 55 +++++- .../example_04/windows/runner/win32_window.h | 20 ++- 199 files changed, 2951 insertions(+), 1511 deletions(-) create mode 100644 example/example_01/ios/RunnerTests/RunnerTests.swift create mode 100644 example/example_01/macos/RunnerTests/RunnerTests.swift delete mode 100644 example/example_01/windows/runner/run_loop.cpp delete mode 100644 example/example_01/windows/runner/run_loop.h create mode 100644 example/example_02/ios/RunnerTests/RunnerTests.swift create mode 100644 example/example_02/macos/RunnerTests/RunnerTests.swift delete mode 100644 example/example_02/windows/runner/run_loop.cpp delete mode 100644 example/example_02/windows/runner/run_loop.h create mode 100644 example/example_03/ios/RunnerTests/RunnerTests.swift create mode 100644 example/example_03/macos/RunnerTests/RunnerTests.swift delete mode 100644 example/example_03/windows/runner/run_loop.cpp delete mode 100644 example/example_03/windows/runner/run_loop.h create mode 100644 example/example_04/ios/RunnerTests/RunnerTests.swift create mode 100644 example/example_04/macos/RunnerTests/RunnerTests.swift delete mode 100644 example/example_04/windows/runner/run_loop.cpp delete mode 100644 example/example_04/windows/runner/run_loop.h diff --git a/example/example_01/.gitignore b/example/example_01/.gitignore index 0fa6b67..29a3a50 100644 --- a/example/example_01/.gitignore +++ b/example/example_01/.gitignore @@ -8,6 +8,7 @@ .buildlog/ .history .svn/ +migrate_working_dir/ # IntelliJ related *.iml @@ -26,14 +27,10 @@ .dart_tool/ .flutter-plugins .flutter-plugins-dependencies -.packages .pub-cache/ .pub/ /build/ -# Web related -lib/generated_plugin_registrant.dart - # Symbolication related app.*.symbols diff --git a/example/example_01/.metadata b/example/example_01/.metadata index ec98142..bbba528 100644 --- a/example/example_01/.metadata +++ b/example/example_01/.metadata @@ -4,7 +4,42 @@ # This file should be version controlled and should not be manually edited. version: - revision: d79295af24c3ed621c33713ecda14ad196fd9c31 - channel: stable + revision: "7f20e5d18ce4cb80c621533090a7c5113f5bdc52" + channel: "stable" project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 7f20e5d18ce4cb80c621533090a7c5113f5bdc52 + base_revision: 7f20e5d18ce4cb80c621533090a7c5113f5bdc52 + - platform: android + create_revision: 7f20e5d18ce4cb80c621533090a7c5113f5bdc52 + base_revision: 7f20e5d18ce4cb80c621533090a7c5113f5bdc52 + - platform: ios + create_revision: 7f20e5d18ce4cb80c621533090a7c5113f5bdc52 + base_revision: 7f20e5d18ce4cb80c621533090a7c5113f5bdc52 + - platform: linux + create_revision: 7f20e5d18ce4cb80c621533090a7c5113f5bdc52 + base_revision: 7f20e5d18ce4cb80c621533090a7c5113f5bdc52 + - platform: macos + create_revision: 7f20e5d18ce4cb80c621533090a7c5113f5bdc52 + base_revision: 7f20e5d18ce4cb80c621533090a7c5113f5bdc52 + - platform: web + create_revision: 7f20e5d18ce4cb80c621533090a7c5113f5bdc52 + base_revision: 7f20e5d18ce4cb80c621533090a7c5113f5bdc52 + - platform: windows + create_revision: 7f20e5d18ce4cb80c621533090a7c5113f5bdc52 + base_revision: 7f20e5d18ce4cb80c621533090a7c5113f5bdc52 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/example/example_01/README.md b/example/example_01/README.md index aabe258..22d1916 100644 --- a/example/example_01/README.md +++ b/example/example_01/README.md @@ -8,9 +8,9 @@ This project is a starting point for a Flutter application. A few resources to get you started if this is your first Flutter project: -- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) +- [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, view our -[online documentation](https://flutter.dev/docs), which offers tutorials, +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. diff --git a/example/example_01/analysis_options.yaml b/example/example_01/analysis_options.yaml index 8212f8d..0d29021 100644 --- a/example/example_01/analysis_options.yaml +++ b/example/example_01/analysis_options.yaml @@ -1,24 +1,28 @@ -include: package:pedantic/analysis_options.yaml +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml -analyzer: - exclude: - - build/** - - "**/*.g.dart" - strong-mode: - implicit-casts: false - errors: - missing_required_param: error - parameter_assignments: error - avoid_relative_lib_imports: error linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. rules: - - always_declare_return_types - - camel_case_types - - empty_constructor_bodies - - annotate_overrides - - avoid_init_to_null - - constant_identifier_names - - one_member_abstracts - - slash_for_doc_comments - - sort_constructors_first - - unnecessary_brace_in_string_interps + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/example/example_01/android/.gitignore b/example/example_01/android/.gitignore index 0a741cb..6f56801 100644 --- a/example/example_01/android/.gitignore +++ b/example/example_01/android/.gitignore @@ -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 diff --git a/example/example_01/android/app/build.gradle b/example/example_01/android/app/build.gradle index 25fcabe..785bd7a 100644 --- a/example/example_01/android/app/build.gradle +++ b/example/example_01/android/app/build.gradle @@ -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()) { @@ -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 = '1' @@ -21,12 +22,19 @@ 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 { - compileSdkVersion 30 + namespace "com.example.example_01" + compileSdkVersion 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' @@ -35,8 +43,10 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.example_01" - minSdkVersion 16 - targetSdkVersion 30 + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName } @@ -54,6 +64,4 @@ flutter { source '../..' } -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" -} +dependencies {} diff --git a/example/example_01/android/app/src/debug/AndroidManifest.xml b/example/example_01/android/app/src/debug/AndroidManifest.xml index d0fa86f..399f698 100644 --- a/example/example_01/android/app/src/debug/AndroidManifest.xml +++ b/example/example_01/android/app/src/debug/AndroidManifest.xml @@ -1,6 +1,6 @@ - - diff --git a/example/example_01/android/app/src/main/AndroidManifest.xml b/example/example_01/android/app/src/main/AndroidManifest.xml index eed1e9f..4fd5b1f 100644 --- a/example/example_01/android/app/src/main/AndroidManifest.xml +++ b/example/example_01/android/app/src/main/AndroidManifest.xml @@ -1,10 +1,11 @@ - - + - - diff --git a/example/example_01/android/app/src/main/res/values-night/styles.xml b/example/example_01/android/app/src/main/res/values-night/styles.xml index 449a9f9..06952be 100644 --- a/example/example_01/android/app/src/main/res/values-night/styles.xml +++ b/example/example_01/android/app/src/main/res/values-night/styles.xml @@ -3,14 +3,14 @@