Add a skeleton package:ok_http (#1212)
diff --git a/.github/workflows/okhttp.yaml b/.github/workflows/okhttp.yaml new file mode 100644 index 0000000..9cf39b5 --- /dev/null +++ b/.github/workflows/okhttp.yaml
@@ -0,0 +1,47 @@ +name: package:ok_http CI + +on: + push: + branches: + - main + - master + paths: + - '.github/workflows/okhttp.yml' + - 'pkgs/ok_http/**' + - 'pkgs/http_client_conformance_tests/**' + pull_request: + paths: + - '.github/workflows/okhttp.yml' + - 'pkgs/ok_http/**' + - 'pkgs/http_client_conformance_tests/**' + schedule: + - cron: "0 0 * * 0" + +env: + PUB_ENVIRONMENT: bot.github + +jobs: + verify: + name: Format & Analyze & Test + runs-on: ubuntu-latest + defaults: + run: + working-directory: pkgs/ok_http + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 + with: + distribution: 'zulu' + java-version: '17' + - uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 + with: + channel: 'stable' + - id: install + name: Install dependencies + run: flutter pub get + - name: Check formatting + if: always() && steps.install.outcome == 'success' + run: dart format --output=none --set-exit-if-changed . + - name: Analyze code + if: always() && steps.install.outcome == 'success' + run: flutter analyze --fatal-infos
diff --git a/pkgs/ok_http/.gitignore b/pkgs/ok_http/.gitignore new file mode 100644 index 0000000..ac5aa98 --- /dev/null +++ b/pkgs/ok_http/.gitignore
@@ -0,0 +1,29 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +build/
diff --git a/pkgs/ok_http/.metadata b/pkgs/ok_http/.metadata new file mode 100644 index 0000000..f72bdaa --- /dev/null +++ b/pkgs/ok_http/.metadata
@@ -0,0 +1,30 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "a14f74ff3a1cbd521163c5f03d68113d50af93d3" + channel: "stable" + +project_type: plugin_ffi + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 + base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 + - platform: android + create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 + base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 + + # 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/pkgs/ok_http/CHANGELOG.md b/pkgs/ok_http/CHANGELOG.md new file mode 100644 index 0000000..0cbc610 --- /dev/null +++ b/pkgs/ok_http/CHANGELOG.md
@@ -0,0 +1,3 @@ +## 0.1.0-wip + +* Initial release.
diff --git a/pkgs/ok_http/LICENSE b/pkgs/ok_http/LICENSE new file mode 100644 index 0000000..afd9a64 --- /dev/null +++ b/pkgs/ok_http/LICENSE
@@ -0,0 +1,27 @@ +Copyright 2014, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file
diff --git a/pkgs/ok_http/README.md b/pkgs/ok_http/README.md new file mode 100644 index 0000000..cca48a3 --- /dev/null +++ b/pkgs/ok_http/README.md
@@ -0,0 +1,22 @@ +[](https://pub.dev/packages/ok_http) +[](https://pub.dev/packages/ok_http/publisher) + +An Android Flutter plugin that provides access to the +[OkHttp][] HTTP client. + +## Status: experimental + +**NOTE**: This package is currently experimental and published under the +[labs.dart.dev](https://dart.dev/dart-team-packages) pub publisher in order to +solicit feedback. + +For packages in the labs.dart.dev publisher we generally plan to either graduate +the package into a supported publisher (dart.dev, tools.dart.dev) after a period +of feedback and iteration, or discontinue the package. These packages have a +much higher expected rate of API and breaking changes. + +Your feedback is valuable and will help us evolve this package. For general +feedback, suggestions, and comments, please file an issue in the +[bug tracker](https://github.com/dart-lang/http/issues). + +[OkHttp]: https://square.github.io/okhttp/
diff --git a/pkgs/ok_http/analysis_options.yaml b/pkgs/ok_http/analysis_options.yaml new file mode 100644 index 0000000..f04c6cf --- /dev/null +++ b/pkgs/ok_http/analysis_options.yaml
@@ -0,0 +1 @@ +include: ../../analysis_options.yaml
diff --git a/pkgs/ok_http/android/.gitignore b/pkgs/ok_http/android/.gitignore new file mode 100644 index 0000000..161bdcd --- /dev/null +++ b/pkgs/ok_http/android/.gitignore
@@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.cxx
diff --git a/pkgs/ok_http/android/build.gradle b/pkgs/ok_http/android/build.gradle new file mode 100644 index 0000000..5385875 --- /dev/null +++ b/pkgs/ok_http/android/build.gradle
@@ -0,0 +1,65 @@ +// The Android Gradle Plugin builds the native code with the Android NDK. + +group = "com.example.ok_http" +version = "1.0" + +buildscript { + repositories { + google() + mavenCentral() + } + + dependencies { + // The Android Gradle Plugin knows how to build native code with the NDK. + classpath("com.android.tools.build:gradle:7.3.0") + } +} + +rootProject.allprojects { + repositories { + google() + mavenCentral() + } +} + +apply plugin: "com.android.library" + +android { + if (project.android.hasProperty("namespace")) { + namespace = "com.example.ok_http" + } + + // Bumping the plugin compileSdk version requires all clients of this plugin + // to bump the version in their app. + compileSdk = 34 + + // Use the NDK version + // declared in /android/app/build.gradle file of the Flutter project. + // Replace it with a version number if this plugin requires a specific NDK version. + // (e.g. ndkVersion "23.1.7779620") + ndkVersion = android.ndkVersion + + // Invoke the shared CMake build with the Android Gradle Plugin. + externalNativeBuild { + cmake { + path = "../src/CMakeLists.txt" + + // The default CMake version for the Android Gradle Plugin is 3.10.2. + // https://developer.android.com/studio/projects/install-ndk#vanilla_cmake + // + // The Flutter tooling requires that developers have CMake 3.10 or later + // installed. You should not increase this version, as doing so will cause + // the plugin to fail to compile for some customers of the plugin. + // version "3.10.2" + } + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + defaultConfig { + minSdk = 21 + } +}
diff --git a/pkgs/ok_http/android/settings.gradle b/pkgs/ok_http/android/settings.gradle new file mode 100644 index 0000000..64c0d94 --- /dev/null +++ b/pkgs/ok_http/android/settings.gradle
@@ -0,0 +1 @@ +rootProject.name = 'ok_http'
diff --git a/pkgs/ok_http/android/src/main/AndroidManifest.xml b/pkgs/ok_http/android/src/main/AndroidManifest.xml new file mode 100644 index 0000000..c4b1857 --- /dev/null +++ b/pkgs/ok_http/android/src/main/AndroidManifest.xml
@@ -0,0 +1,3 @@ +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.example.ok_http"> +</manifest>
diff --git a/pkgs/ok_http/example/.gitignore b/pkgs/ok_http/example/.gitignore new file mode 100644 index 0000000..29a3a50 --- /dev/null +++ b/pkgs/ok_http/example/.gitignore
@@ -0,0 +1,43 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release
diff --git a/pkgs/ok_http/example/README.md b/pkgs/ok_http/example/README.md new file mode 100644 index 0000000..44f9e18 --- /dev/null +++ b/pkgs/ok_http/example/README.md
@@ -0,0 +1,16 @@ +# ok_http_example + +Demonstrates how to use the ok_http plugin. + +## Getting Started + +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://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.
diff --git a/pkgs/ok_http/example/analysis_options.yaml b/pkgs/ok_http/example/analysis_options.yaml new file mode 100644 index 0000000..0d29021 --- /dev/null +++ b/pkgs/ok_http/example/analysis_options.yaml
@@ -0,0 +1,28 @@ +# 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 + +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: + # 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/pkgs/ok_http/example/android/.gitignore b/pkgs/ok_http/example/android/.gitignore new file mode 100644 index 0000000..6f56801 --- /dev/null +++ b/pkgs/ok_http/example/android/.gitignore
@@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +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/pkgs/ok_http/example/android/app/build.gradle b/pkgs/ok_http/example/android/app/build.gradle new file mode 100644 index 0000000..77ac8ef --- /dev/null +++ b/pkgs/ok_http/example/android/app/build.gradle
@@ -0,0 +1,58 @@ +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 flutterVersionCode = localProperties.getProperty("flutter.versionCode") +if (flutterVersionCode == null) { + flutterVersionCode = "1" +} + +def flutterVersionName = localProperties.getProperty("flutter.versionName") +if (flutterVersionName == null) { + flutterVersionName = "1.0" +} + +android { + namespace = "com.example.ok_http_example" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId = "com.example.ok_http_example" + // 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. + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutterVersionCode.toInteger() + versionName = flutterVersionName + } + + 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 + } + } +} + +flutter { + source = "../.." +}
diff --git a/pkgs/ok_http/example/android/app/src/debug/AndroidManifest.xml b/pkgs/ok_http/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/pkgs/ok_http/example/android/app/src/debug/AndroidManifest.xml
@@ -0,0 +1,7 @@ +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + <!-- 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"/> +</manifest>
diff --git a/pkgs/ok_http/example/android/app/src/main/AndroidManifest.xml b/pkgs/ok_http/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..800e9df --- /dev/null +++ b/pkgs/ok_http/example/android/app/src/main/AndroidManifest.xml
@@ -0,0 +1,45 @@ +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + <application + android:label="ok_http_example" + android:name="${applicationName}" + android:icon="@mipmap/ic_launcher"> + <activity + 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" + android:windowSoftInputMode="adjustResize"> + <!-- Specifies an Android theme to apply to this Activity as soon as + the Android process has started. This theme is visible to the user + while the Flutter UI initializes. After that, this theme continues + to determine the Window background behind the Flutter UI. --> + <meta-data + android:name="io.flutter.embedding.android.NormalTheme" + android:resource="@style/NormalTheme" + /> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER"/> + </intent-filter> + </activity> + <!-- Don't delete the meta-data below. + This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --> + <meta-data + android:name="flutterEmbedding" + android:value="2" /> + </application> + <!-- Required to query activities that can process text, see: + https://developer.android.com/training/package-visibility and + https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT. + + In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. --> + <queries> + <intent> + <action android:name="android.intent.action.PROCESS_TEXT"/> + <data android:mimeType="text/plain"/> + </intent> + </queries> +</manifest>
diff --git a/pkgs/ok_http/example/android/app/src/main/kotlin/com/example/ok_http_example/MainActivity.kt b/pkgs/ok_http/example/android/app/src/main/kotlin/com/example/ok_http_example/MainActivity.kt new file mode 100644 index 0000000..7b47f28 --- /dev/null +++ b/pkgs/ok_http/example/android/app/src/main/kotlin/com/example/ok_http_example/MainActivity.kt
@@ -0,0 +1,5 @@ +package com.example.ok_http_example + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity()
diff --git a/pkgs/ok_http/example/android/app/src/main/res/drawable-v21/launch_background.xml b/pkgs/ok_http/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/pkgs/ok_http/example/android/app/src/main/res/drawable-v21/launch_background.xml
@@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Modify this file to customize your launch splash screen --> +<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:drawable="?android:colorBackground" /> + + <!-- You can insert your own image assets here --> + <!-- <item> + <bitmap + android:gravity="center" + android:src="@mipmap/launch_image" /> + </item> --> +</layer-list>
diff --git a/pkgs/ok_http/example/android/app/src/main/res/drawable/launch_background.xml b/pkgs/ok_http/example/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..304732f --- /dev/null +++ b/pkgs/ok_http/example/android/app/src/main/res/drawable/launch_background.xml
@@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Modify this file to customize your launch splash screen --> +<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:drawable="@android:color/white" /> + + <!-- You can insert your own image assets here --> + <!-- <item> + <bitmap + android:gravity="center" + android:src="@mipmap/launch_image" /> + </item> --> +</layer-list>
diff --git a/pkgs/ok_http/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/pkgs/ok_http/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..db77bb4 --- /dev/null +++ b/pkgs/ok_http/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ
diff --git a/pkgs/ok_http/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/pkgs/ok_http/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..17987b7 --- /dev/null +++ b/pkgs/ok_http/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ
diff --git a/pkgs/ok_http/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/pkgs/ok_http/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..09d4391 --- /dev/null +++ b/pkgs/ok_http/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differ
diff --git a/pkgs/ok_http/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/pkgs/ok_http/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..d5f1c8d --- /dev/null +++ b/pkgs/ok_http/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differ
diff --git a/pkgs/ok_http/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/pkgs/ok_http/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..4d6372e --- /dev/null +++ b/pkgs/ok_http/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png Binary files differ
diff --git a/pkgs/ok_http/example/android/app/src/main/res/values-night/styles.xml b/pkgs/ok_http/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..06952be --- /dev/null +++ b/pkgs/ok_http/example/android/app/src/main/res/values-night/styles.xml
@@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <!-- 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 + 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> + </style> +</resources>
diff --git a/pkgs/ok_http/example/android/app/src/main/res/values/styles.xml b/pkgs/ok_http/example/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..cb1ef88 --- /dev/null +++ b/pkgs/ok_http/example/android/app/src/main/res/values/styles.xml
@@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <!-- 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 + 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> + </style> +</resources>
diff --git a/pkgs/ok_http/example/android/app/src/profile/AndroidManifest.xml b/pkgs/ok_http/example/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/pkgs/ok_http/example/android/app/src/profile/AndroidManifest.xml
@@ -0,0 +1,7 @@ +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + <!-- 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"/> +</manifest>
diff --git a/pkgs/ok_http/example/android/build.gradle b/pkgs/ok_http/example/android/build.gradle new file mode 100644 index 0000000..d2ffbff --- /dev/null +++ b/pkgs/ok_http/example/android/build.gradle
@@ -0,0 +1,18 @@ +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = "../build" +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(":app") +} + +tasks.register("clean", Delete) { + delete rootProject.buildDir +}
diff --git a/pkgs/ok_http/example/android/gradle.properties b/pkgs/ok_http/example/android/gradle.properties new file mode 100644 index 0000000..3b5b324 --- /dev/null +++ b/pkgs/ok_http/example/android/gradle.properties
@@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError +android.useAndroidX=true +android.enableJetifier=true
diff --git a/pkgs/ok_http/example/android/gradle/wrapper/gradle-wrapper.properties b/pkgs/ok_http/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..e1ca574 --- /dev/null +++ b/pkgs/ok_http/example/android/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@ +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
diff --git a/pkgs/ok_http/example/android/settings.gradle b/pkgs/ok_http/example/android/settings.gradle new file mode 100644 index 0000000..536165d --- /dev/null +++ b/pkgs/ok_http/example/android/settings.gradle
@@ -0,0 +1,25 @@ +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 + }() + + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +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"
diff --git a/pkgs/ok_http/example/lib/main.dart b/pkgs/ok_http/example/lib/main.dart new file mode 100644 index 0000000..772d29a --- /dev/null +++ b/pkgs/ok_http/example/lib/main.dart
@@ -0,0 +1,69 @@ +import 'package:flutter/material.dart'; +import 'dart:async'; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatefulWidget { + const MyApp({super.key}); + + @override + State<MyApp> createState() => _MyAppState(); +} + +class _MyAppState extends State<MyApp> { + late int sumResult; + late Future<int> sumAsyncResult; + + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + const textStyle = TextStyle(fontSize: 25); + const spacerSmall = SizedBox(height: 10); + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Native Packages'), + ), + body: SingleChildScrollView( + child: Container( + padding: const EdgeInsets.all(10), + child: Column( + children: [ + const Text( + '', + style: textStyle, + textAlign: TextAlign.center, + ), + spacerSmall, + Text( + 'sum(1, 2) = $sumResult', + style: textStyle, + textAlign: TextAlign.center, + ), + spacerSmall, + FutureBuilder<int>( + future: sumAsyncResult, + builder: (BuildContext context, AsyncSnapshot<int> value) { + final displayValue = + (value.hasData) ? value.data : 'loading'; + return Text( + 'await sumAsync(3, 4) = $displayValue', + style: textStyle, + textAlign: TextAlign.center, + ); + }, + ), + ], + ), + ), + ), + ), + ); + } +}
diff --git a/pkgs/ok_http/example/pubspec.yaml b/pkgs/ok_http/example/pubspec.yaml new file mode 100644 index 0000000..3cf6fc8 --- /dev/null +++ b/pkgs/ok_http/example/pubspec.yaml
@@ -0,0 +1,97 @@ +name: ok_http_example +description: "Demonstrates how to use the ok_http plugin." +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +# In Windows, build-name is used as the major, minor, and patch parts +# of the product and file versions while build-number is used as the build suffix. +version: 1.0.0+1 + +environment: + sdk: '>=3.4.1 <4.0.0' + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + + ok_http: + # When depending on this package from a real application you should use: + # ok_http: ^x.y.z + # See https://dart.dev/tools/pub/dependencies#version-constraints + # The example app is bundled with the plugin so we use a path dependency on + # the parent directory to use the current plugin's version. + path: ../ + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.6 + +dev_dependencies: + flutter_test: + sdk: flutter + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^3.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages
diff --git a/pkgs/ok_http/lib/ok_http.dart b/pkgs/ok_http/lib/ok_http.dart new file mode 100644 index 0000000..4b81882 --- /dev/null +++ b/pkgs/ok_http/lib/ok_http.dart
@@ -0,0 +1,3 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file.
diff --git a/pkgs/ok_http/pubspec.yaml b/pkgs/ok_http/pubspec.yaml new file mode 100644 index 0000000..2a7a21f --- /dev/null +++ b/pkgs/ok_http/pubspec.yaml
@@ -0,0 +1,24 @@ +name: ok_http +version: 0.1.0-wip +description: >- + An Android Flutter plugin that provides access to the OkHttp HTTP client. +repository: https://github.com/dart-lang/http/tree/master/pkgs/ok_http +publish_to: none + +environment: + sdk: ^3.4.0 + flutter: '>=3.22.0' + +dependencies: + flutter: + sdk: flutter + plugin_platform_interface: ^2.0.2 + +dev_dependencies: + dart_flutter_team_lints: ^2.0.0 + +flutter: + plugin: + platforms: + android: + ffiPlugin: true