From 0f9b42f4cb7294ea97848d3193a628a5b1ea90f4 Mon Sep 17 00:00:00 2001 From: Alejandro Ulate Date: Wed, 20 Nov 2019 11:27:20 -0600 Subject: [PATCH 01/14] Improving example code. --- example/lib/main.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 7468827..0528620 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,7 +1,6 @@ import 'dart:convert'; import 'package:flutter/material.dart'; -import 'package:http/http.dart'; import 'package:http_interceptor/http_interceptor.dart'; import 'credentials.dart'; // If you are going to run this example you need to replace the key. import 'cities.dart'; // This is just a List of Maps that contains the suggested cities. From faab2f77ce5d880ec0fcebd24b581cef7e8e9763 Mon Sep 17 00:00:00 2001 From: Alejandro Ulate Date: Fri, 22 Nov 2019 18:11:46 -0600 Subject: [PATCH 02/14] Changelog:Migrated base project to swift/kotlin - Added effective dart style. --- .gitignore | 80 +++--------- README.md | 5 + analysis_options.yml | 1 + android/build.gradle | 12 +- android/gradle.properties | 1 + .../gradle/wrapper/gradle-wrapper.properties | 5 + android/src/main/AndroidManifest.xml | 2 +- .../HttpInterceptorPlugin.java | 25 ---- .../http_interceptor/HttpInterceptorPlugin.kt | 25 ++++ example/.gitignore | 7 +- example/android/app/build.gradle | 8 +- .../android/app/src/debug/AndroidManifest.xml | 2 +- .../android/app/src/main/AndroidManifest.xml | 4 +- .../MainActivity.java | 13 -- .../com/example/example/MainActivity.kt | 13 ++ .../http_interceptor_example/MainActivity.kt | 13 ++ .../app/src/profile/AndroidManifest.xml | 2 +- example/android/build.gradle | 2 + example/android/gradle.properties | 1 + example/ios/Flutter/AppFrameworkInfo.plist | 2 +- .../ios/Flutter/flutter_export_environment.sh | 9 -- example/ios/Podfile | 9 +- example/ios/Podfile.lock | 22 ---- example/ios/Runner.xcodeproj/project.pbxproj | 116 +++++------------- .../xcshareddata/xcschemes/Runner.xcscheme | 4 +- .../contents.xcworkspacedata | 3 - .../xcshareddata/IDEWorkspaceChecks.plist | 8 -- .../xcshareddata/WorkspaceSettings.xcsettings | 5 - example/ios/Runner/AppDelegate.h | 6 - example/ios/Runner/AppDelegate.m | 13 -- example/ios/Runner/AppDelegate.swift | 13 ++ .../Icon-App-1024x1024@1x.png | Bin 11112 -> 10932 bytes example/ios/Runner/Info.plist | 4 +- example/ios/Runner/Runner-Bridging-Header.h | 1 + example/ios/Runner/main.m | 9 -- ios/.gitignore | 1 + ios/Classes/HttpInterceptorPlugin.m | 16 +-- ios/Classes/SwiftHttpInterceptorPlugin.swift | 14 +++ pubspec.lock | 7 ++ pubspec.yaml | 1 + 40 files changed, 190 insertions(+), 294 deletions(-) create mode 100644 analysis_options.yml create mode 100644 android/gradle/wrapper/gradle-wrapper.properties delete mode 100644 android/src/main/java/codingalecr/http_interceptor/HttpInterceptorPlugin.java create mode 100644 android/src/main/kotlin/com/example/http_interceptor/HttpInterceptorPlugin.kt delete mode 100644 example/android/app/src/main/java/codingalecr/http_interceptor_example/MainActivity.java create mode 100644 example/android/app/src/main/kotlin/com/example/example/MainActivity.kt create mode 100644 example/android/app/src/main/kotlin/com/example/http_interceptor_example/MainActivity.kt delete mode 100755 example/ios/Flutter/flutter_export_environment.sh delete mode 100644 example/ios/Podfile.lock delete mode 100644 example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist delete mode 100644 example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings delete mode 100644 example/ios/Runner/AppDelegate.h delete mode 100644 example/ios/Runner/AppDelegate.m create mode 100644 example/ios/Runner/AppDelegate.swift create mode 100644 example/ios/Runner/Runner-Bridging-Header.h delete mode 100644 example/ios/Runner/main.m create mode 100644 ios/Classes/SwiftHttpInterceptorPlugin.swift diff --git a/.gitignore b/.gitignore index 07488ba..7fd7b51 100644 --- a/.gitignore +++ b/.gitignore @@ -1,70 +1,24 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp .DS_Store -.atom/ -.buildlog/ -.history -.svn/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# Visual Studio Code related -.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ .dart_tool/ -.flutter-plugins + .packages -.pub-cache/ .pub/ -/build/ -# Android related -**/android/**/gradle-wrapper.jar -**/android/.gradle -**/android/captures/ -**/android/gradlew -**/android/gradlew.bat -**/android/local.properties -**/android/**/GeneratedPluginRegistrant.java +build/ -# iOS/XCode related -**/ios/**/*.mode1v3 -**/ios/**/*.mode2v3 -**/ios/**/*.moved-aside -**/ios/**/*.pbxuser -**/ios/**/*.perspectivev3 -**/ios/**/*sync/ -**/ios/**/.sconsign.dblite -**/ios/**/.tags* -**/ios/**/.vagrant/ -**/ios/**/DerivedData/ -**/ios/**/Icon? -**/ios/**/Pods/ -**/ios/**/.symlinks/ -**/ios/**/profile -**/ios/**/xcuserdata -**/ios/.generated/ -**/ios/Flutter/App.framework -**/ios/Flutter/Flutter.framework -**/ios/Flutter/Generated.xcconfig -**/ios/Flutter/app.flx -**/ios/Flutter/app.zip -**/ios/Flutter/flutter_assets/ -**/ios/ServiceDefinitions.json -**/ios/Runner/GeneratedPluginRegistrant.* -# Exceptions to above rules. -!**/ios/**/default.mode1v3 -!**/ios/**/default.mode2v3 -!**/ios/**/default.pbxuser -!**/ios/**/default.perspectivev3 -!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages +.atom/ +.idea +.vscode +packages/**/ios/ +packages/**/android/ +doc/ +pubspec.lock +.flutter-plugins +*.iml +coverage/ +.test_coverage.dart +*.log +flutter_export_environment.sh +!packages/**/example/ios/ +!packages/**/example/android/ \ No newline at end of file diff --git a/README.md b/README.md index cd005bf..16de5a5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # http_interceptor +[![Pub](https://img.shields.io/pub/v/http_interceptor.svg)](https://pub.dev/packages/http_interceptor) +[![style: effective dart](https://img.shields.io/badge/style-effective_dart-40c4ff.svg)](https://github.com/tenhobi/effective_dart) +[![License: MIT](https://img.shields.io/badge/license-MIT-purple.svg)](https://opensource.org/licenses/MIT) +[![Star on GitHub](https://img.shields.io/github/stars/codingalecr/http_interceptor.svg?style=flat&logo=github&colorB=deeppink&label=stars)](https://github.com/codingalecr/http_interceptor) + A middleware library that lets you modify requests and responses if desired. Based of on [http_middleware](https://github.com/TEDConsulting/http_middleware) ## Getting Started diff --git a/analysis_options.yml b/analysis_options.yml new file mode 100644 index 0000000..30dcb3b --- /dev/null +++ b/analysis_options.yml @@ -0,0 +1 @@ +include: package:effective_dart/analysis_options.1.1.0.yaml \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index 2f9d425..e207aca 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,7 +1,8 @@ -group 'codingalecr.http_interceptor' +group 'com.example.http_interceptor' version '1.0-SNAPSHOT' buildscript { + ext.kotlin_version = '1.2.71' repositories { google() jcenter() @@ -9,6 +10,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:3.2.1' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -20,10 +22,14 @@ rootProject.allprojects { } apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' android { compileSdkVersion 28 + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } defaultConfig { minSdkVersion 16 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -32,3 +38,7 @@ android { disable 'InvalidPackage' } } + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/android/gradle.properties b/android/gradle.properties index 8bd86f6..2bd6f4f 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1 +1,2 @@ org.gradle.jvmargs=-Xmx1536M + diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..019065d --- /dev/null +++ b/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-4.10.2-all.zip diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index b4465f7..8b62ad8 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,3 +1,3 @@ + package="com.example.http_interceptor"> diff --git a/android/src/main/java/codingalecr/http_interceptor/HttpInterceptorPlugin.java b/android/src/main/java/codingalecr/http_interceptor/HttpInterceptorPlugin.java deleted file mode 100644 index 984930c..0000000 --- a/android/src/main/java/codingalecr/http_interceptor/HttpInterceptorPlugin.java +++ /dev/null @@ -1,25 +0,0 @@ -package codingalecr.http_interceptor; - -import io.flutter.plugin.common.MethodCall; -import io.flutter.plugin.common.MethodChannel; -import io.flutter.plugin.common.MethodChannel.MethodCallHandler; -import io.flutter.plugin.common.MethodChannel.Result; -import io.flutter.plugin.common.PluginRegistry.Registrar; - -/** HttpInterceptorPlugin */ -public class HttpInterceptorPlugin implements MethodCallHandler { - /** Plugin registration. */ - public static void registerWith(Registrar registrar) { - final MethodChannel channel = new MethodChannel(registrar.messenger(), "http_interceptor"); - channel.setMethodCallHandler(new HttpInterceptorPlugin()); - } - - @Override - public void onMethodCall(MethodCall call, Result result) { - if (call.method.equals("getPlatformVersion")) { - result.success("Android " + android.os.Build.VERSION.RELEASE); - } else { - result.notImplemented(); - } - } -} diff --git a/android/src/main/kotlin/com/example/http_interceptor/HttpInterceptorPlugin.kt b/android/src/main/kotlin/com/example/http_interceptor/HttpInterceptorPlugin.kt new file mode 100644 index 0000000..83429b8 --- /dev/null +++ b/android/src/main/kotlin/com/example/http_interceptor/HttpInterceptorPlugin.kt @@ -0,0 +1,25 @@ +package com.example.http_interceptor + +import io.flutter.plugin.common.MethodCall +import io.flutter.plugin.common.MethodChannel +import io.flutter.plugin.common.MethodChannel.MethodCallHandler +import io.flutter.plugin.common.MethodChannel.Result +import io.flutter.plugin.common.PluginRegistry.Registrar + +class HttpInterceptorPlugin: MethodCallHandler { + companion object { + @JvmStatic + fun registerWith(registrar: Registrar) { + val channel = MethodChannel(registrar.messenger(), "http_interceptor") + channel.setMethodCallHandler(HttpInterceptorPlugin()) + } + } + + override fun onMethodCall(call: MethodCall, result: Result) { + if (call.method == "getPlatformVersion") { + result.success("Android ${android.os.Build.VERSION.RELEASE}") + } else { + result.notImplemented() + } + } +} diff --git a/example/.gitignore b/example/.gitignore index 65aa46d..95c7e97 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -15,7 +15,9 @@ *.iws .idea/ -# Visual Studio Code related +# 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 @@ -59,6 +61,7 @@ **/ios/Flutter/app.flx **/ios/Flutter/app.zip **/ios/Flutter/flutter_assets/ +**/ios/Flutter/flutter_export_environment.sh **/ios/ServiceDefinitions.json **/ios/Runner/GeneratedPluginRegistrant.* @@ -67,4 +70,4 @@ !**/ios/**/default.mode2v3 !**/ios/**/default.pbxuser !**/ios/**/default.perspectivev3 -!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages \ No newline at end of file +!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index ba793fd..ddeebe6 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -22,18 +22,23 @@ if (flutterVersionName == null) { } apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { compileSdkVersion 28 + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + lintOptions { disable 'InvalidPackage' } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "codingalecr.http_interceptor_example" + applicationId "com.example.example" minSdkVersion 16 targetSdkVersion 28 versionCode flutterVersionCode.toInteger() @@ -55,6 +60,7 @@ flutter { } dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml index 828101f..c208884 100644 --- a/example/android/app/src/debug/AndroidManifest.xml +++ b/example/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.example.example"> diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 693ea72..2877140 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.example.example"> + package="com.example.example"> diff --git a/example/android/build.gradle b/example/android/build.gradle index bb8a303..b7faad8 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,4 +1,5 @@ buildscript { + ext.kotlin_version = '1.2.71' repositories { google() jcenter() @@ -6,6 +7,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:3.2.1' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/example/android/gradle.properties b/example/android/gradle.properties index 8bd86f6..2bd6f4f 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1 +1,2 @@ org.gradle.jvmargs=-Xmx1536M + diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 9367d48..6b4c0f7 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - en + $(DEVELOPMENT_LANGUAGE) CFBundleExecutable App CFBundleIdentifier diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh deleted file mode 100755 index 081f78e..0000000 --- a/example/ios/Flutter/flutter_export_environment.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -# This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/Users/alejandro/Workspaces/flutter/flutter" -export "FLUTTER_APPLICATION_PATH=/Users/alejandro/Workspaces/codingalecr/http_interceptor/example" -export "FLUTTER_TARGET=/Users/alejandro/Workspaces/codingalecr/http_interceptor/example/lib/main.dart" -export "FLUTTER_BUILD_DIR=build" -export "SYMROOT=${SOURCE_ROOT}/../build/ios" -export "FLUTTER_FRAMEWORK_DIR=/Users/alejandro/Workspaces/flutter/flutter/bin/cache/artifacts/engine/ios" -export "TRACK_WIDGET_CREATION=true" diff --git a/example/ios/Podfile b/example/ios/Podfile index c1f0bba..e9286cb 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -4,8 +4,6 @@ # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' -install! 'cocoapods', :disable_input_output_paths => true - project 'Runner', { 'Debug' => :debug, 'Profile' => :release, @@ -35,6 +33,8 @@ def parse_KV_file(file, separator='=') end target 'Runner' do + use_frameworks! + # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock # referring to absolute paths on developers' machines. system('rm -rf .symlinks') @@ -43,7 +43,7 @@ target 'Runner' do # Flutter Pods generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig') if generated_xcode_build_settings.empty? - puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first." + puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first." end generated_xcode_build_settings.map { |p| if p[:name] == 'FLUTTER_FRAMEWORK_DIR' @@ -62,6 +62,9 @@ target 'Runner' do } end +# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. +install! 'cocoapods', :disable_input_output_paths => true + post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock deleted file mode 100644 index d9ab235..0000000 --- a/example/ios/Podfile.lock +++ /dev/null @@ -1,22 +0,0 @@ -PODS: - - Flutter (1.0.0) - - http_interceptor (0.0.1): - - Flutter - -DEPENDENCIES: - - Flutter (from `.symlinks/flutter/ios`) - - http_interceptor (from `.symlinks/plugins/http_interceptor/ios`) - -EXTERNAL SOURCES: - Flutter: - :path: ".symlinks/flutter/ios" - http_interceptor: - :path: ".symlinks/plugins/http_interceptor/ios" - -SPEC CHECKSUMS: - Flutter: 0e3d915762c693b495b44d77113d4970485de6ec - http_interceptor: 35739d2beb6230e975f7015d7c994ebd4698402f - -PODFILE CHECKSUM: 69dacd58e7f88dae6e0d9a63487e87a9fa42b7b5 - -COCOAPODS: 1.6.1 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index ac1507e..7d30b69 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -11,12 +11,10 @@ 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 3BF671573F6DDF22BE1013F7 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C5E8C8FB27501C433EA495FA /* libPods-Runner.a */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; }; - 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; - 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; @@ -38,26 +36,21 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 126FE52FDFC1BDF665A063F7 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; - 23AE0DDE919024A71E32D59E /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; - 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; - 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - 8AE106199467C91CFDB141F3 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - C5E8C8FB27501C433EA495FA /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -67,7 +60,6 @@ files = ( 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, - 3BF671573F6DDF22BE1013F7 /* libPods-Runner.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -93,8 +85,6 @@ 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, - C5C6273DF2640D363291C0BB /* Pods */, - DEDC890A64E743B55DDEB300 /* Frameworks */, ); sourceTree = ""; }; @@ -109,8 +99,6 @@ 97C146F01CF9000F007C117D /* Runner */ = { isa = PBXGroup; children = ( - 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, - 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, 97C146FA1CF9000F007C117D /* Main.storyboard */, 97C146FD1CF9000F007C117D /* Assets.xcassets */, 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, @@ -118,6 +106,8 @@ 97C146F11CF9000F007C117D /* Supporting Files */, 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, ); path = Runner; sourceTree = ""; @@ -125,30 +115,10 @@ 97C146F11CF9000F007C117D /* Supporting Files */ = { isa = PBXGroup; children = ( - 97C146F21CF9000F007C117D /* main.m */, ); name = "Supporting Files"; sourceTree = ""; }; - C5C6273DF2640D363291C0BB /* Pods */ = { - isa = PBXGroup; - children = ( - 126FE52FDFC1BDF665A063F7 /* Pods-Runner.debug.xcconfig */, - 23AE0DDE919024A71E32D59E /* Pods-Runner.release.xcconfig */, - 8AE106199467C91CFDB141F3 /* Pods-Runner.profile.xcconfig */, - ); - name = Pods; - path = Pods; - sourceTree = ""; - }; - DEDC890A64E743B55DDEB300 /* Frameworks */ = { - isa = PBXGroup; - children = ( - C5E8C8FB27501C433EA495FA /* libPods-Runner.a */, - ); - name = Frameworks; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -156,14 +126,12 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( - E6596CFD0A8AB4410DCC306C /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - 76A4C1EFEA83707C69CAB4E4 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -180,17 +148,18 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0910; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "The Chromium Authors"; TargetAttributes = { 97C146ED1CF9000F007C117D = { CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 0910; }; }; }; buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -236,25 +205,6 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; }; - 76A4C1EFEA83707C69CAB4E4 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -269,28 +219,6 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; - E6596CFD0A8AB4410DCC306C /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -298,8 +226,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, - 97C146F31CF9000F007C117D /* main.m in Sources */, + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -340,12 +267,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -379,8 +308,8 @@ baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = S8QB4VV633; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -392,8 +321,10 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = codingalecr.httpInterceptorExample; + PRODUCT_BUNDLE_IDENTIFIER = com.example.example; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 4.0; VERSIONING_SYSTEM = "apple-generic"; }; name = Profile; @@ -412,12 +343,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -466,12 +399,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -495,6 +430,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -505,6 +441,7 @@ baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -517,8 +454,11 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = codingalecr.httpInterceptorExample; + PRODUCT_BUNDLE_IDENTIFIER = com.example.example; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.0; VERSIONING_SYSTEM = "apple-generic"; }; name = Debug; @@ -528,6 +468,7 @@ baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -540,8 +481,10 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = codingalecr.httpInterceptorExample; + PRODUCT_BUNDLE_IDENTIFIER = com.example.example; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 4.0; VERSIONING_SYSTEM = "apple-generic"; }; name = Release; @@ -570,6 +513,7 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + }; rootObject = 97C146E61CF9000F007C117D /* Project object */; } diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 786d6aa..a28140c 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ @@ -46,7 +45,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcworkspace/contents.xcworkspacedata index 21a3cc1..1d526a1 100644 --- a/example/ios/Runner.xcworkspace/contents.xcworkspacedata +++ b/example/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -4,7 +4,4 @@ - - diff --git a/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d9810..0000000 --- a/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings deleted file mode 100644 index 0c67376..0000000 --- a/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/example/ios/Runner/AppDelegate.h b/example/ios/Runner/AppDelegate.h deleted file mode 100644 index 36e21bb..0000000 --- a/example/ios/Runner/AppDelegate.h +++ /dev/null @@ -1,6 +0,0 @@ -#import -#import - -@interface AppDelegate : FlutterAppDelegate - -@end diff --git a/example/ios/Runner/AppDelegate.m b/example/ios/Runner/AppDelegate.m deleted file mode 100644 index 59a72e9..0000000 --- a/example/ios/Runner/AppDelegate.m +++ /dev/null @@ -1,13 +0,0 @@ -#include "AppDelegate.h" -#include "GeneratedPluginRegistrant.h" - -@implementation AppDelegate - -- (BOOL)application:(UIApplication *)application - didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - [GeneratedPluginRegistrant registerWithRegistry:self]; - // Override point for customization after application launch. - return [super application:application didFinishLaunchingWithOptions:launchOptions]; -} - -@end diff --git a/example/ios/Runner/AppDelegate.swift b/example/ios/Runner/AppDelegate.swift new file mode 100644 index 0000000..70693e4 --- /dev/null +++ b/example/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import UIKit +import Flutter + +@UIApplicationMain +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png index 3d43d11e66f4de3da27ed045ca4fe38ad8b48094..dc9ada4725e9b0ddb1deab583e5b5102493aa332 100644 GIT binary patch literal 10932 zcmeHN2~<R zh`|8`A_PQ1nSu(UMFx?8j8PC!!VDphaL#`F42fd#7Vlc`zIE4n%Y~eiz4y1j|NDpi z?<@|pSJ-HM`qifhf@m%MamgwK83`XpBA<+azdF#2QsT{X@z0A9Bq>~TVErigKH1~P zRX-!h-f0NJ4Mh++{D}J+K>~~rq}d%o%+4dogzXp7RxX4C>Km5XEI|PAFDmo;DFm6G zzjVoB`@qW98Yl0Kvc-9w09^PrsobmG*Eju^=3f?0o-t$U)TL1B3;sZ^!++3&bGZ!o-*6w?;oOhf z=A+Qb$scV5!RbG+&2S}BQ6YH!FKb0``VVX~T$dzzeSZ$&9=X$3)_7Z{SspSYJ!lGE z7yig_41zpQ)%5dr4ff0rh$@ky3-JLRk&DK)NEIHecf9c*?Z1bUB4%pZjQ7hD!A0r-@NF(^WKdr(LXj|=UE7?gBYGgGQV zidf2`ZT@pzXf7}!NH4q(0IMcxsUGDih(0{kRSez&z?CFA0RVXsVFw3^u=^KMtt95q z43q$b*6#uQDLoiCAF_{RFc{!H^moH_cmll#Fc^KXi{9GDl{>%+3qyfOE5;Zq|6#Hb zp^#1G+z^AXfRKaa9HK;%b3Ux~U@q?xg<2DXP%6k!3E)PA<#4$ui8eDy5|9hA5&{?v z(-;*1%(1~-NTQ`Is1_MGdQ{+i*ccd96ab$R$T3=% zw_KuNF@vI!A>>Y_2pl9L{9h1-C6H8<)J4gKI6{WzGBi<@u3P6h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%TzdJOGeKj5_QjqR&a3*K@= P-1+_A+?hGkL;m(J7kc&K diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index 114251e..a060db6 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - en + $(DEVELOPMENT_LANGUAGE) CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier @@ -11,7 +11,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleName - http_interceptor_example + example CFBundlePackageType APPL CFBundleShortVersionString diff --git a/example/ios/Runner/Runner-Bridging-Header.h b/example/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 0000000..7335fdf --- /dev/null +++ b/example/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" \ No newline at end of file diff --git a/example/ios/Runner/main.m b/example/ios/Runner/main.m deleted file mode 100644 index dff6597..0000000 --- a/example/ios/Runner/main.m +++ /dev/null @@ -1,9 +0,0 @@ -#import -#import -#import "AppDelegate.h" - -int main(int argc, char* argv[]) { - @autoreleasepool { - return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); - } -} diff --git a/ios/.gitignore b/ios/.gitignore index 710ec6c..aa479fd 100644 --- a/ios/.gitignore +++ b/ios/.gitignore @@ -34,3 +34,4 @@ Icon? .tags* /Flutter/Generated.xcconfig +/Flutter/flutter_export_environment.sh \ No newline at end of file diff --git a/ios/Classes/HttpInterceptorPlugin.m b/ios/Classes/HttpInterceptorPlugin.m index 4f47795..2115192 100644 --- a/ios/Classes/HttpInterceptorPlugin.m +++ b/ios/Classes/HttpInterceptorPlugin.m @@ -1,20 +1,8 @@ #import "HttpInterceptorPlugin.h" +#import @implementation HttpInterceptorPlugin + (void)registerWithRegistrar:(NSObject*)registrar { - FlutterMethodChannel* channel = [FlutterMethodChannel - methodChannelWithName:@"http_interceptor" - binaryMessenger:[registrar messenger]]; - HttpInterceptorPlugin* instance = [[HttpInterceptorPlugin alloc] init]; - [registrar addMethodCallDelegate:instance channel:channel]; + [SwiftHttpInterceptorPlugin registerWithRegistrar:registrar]; } - -- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { - if ([@"getPlatformVersion" isEqualToString:call.method]) { - result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]); - } else { - result(FlutterMethodNotImplemented); - } -} - @end diff --git a/ios/Classes/SwiftHttpInterceptorPlugin.swift b/ios/Classes/SwiftHttpInterceptorPlugin.swift new file mode 100644 index 0000000..5b0cde1 --- /dev/null +++ b/ios/Classes/SwiftHttpInterceptorPlugin.swift @@ -0,0 +1,14 @@ +import Flutter +import UIKit + +public class SwiftHttpInterceptorPlugin: NSObject, FlutterPlugin { + public static func register(with registrar: FlutterPluginRegistrar) { + let channel = FlutterMethodChannel(name: "http_interceptor", binaryMessenger: registrar.messenger()) + let instance = SwiftHttpInterceptorPlugin() + registrar.addMethodCallDelegate(instance, channel: channel) + } + + public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { + result("iOS " + UIDevice.current.systemVersion) + } +} diff --git a/pubspec.lock b/pubspec.lock index 4a02338..5ee37c1 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -29,6 +29,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.14.11" + effective_dart: + dependency: "direct dev" + description: + name: effective_dart + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" flutter: dependency: "direct main" description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index 4edbf82..6033c7d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,6 +15,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + effective_dart: ^1.1.0 flutter: From 0f40635096a3b23c1d103862c08d13f3e9035013 Mon Sep 17 00:00:00 2001 From: Alejandro Ulate Date: Fri, 22 Nov 2019 19:29:00 -0600 Subject: [PATCH 03/14] AndroidX migration --- android/build.gradle | 2 +- android/gradle.properties | 2 ++ example/android/app/build.gradle | 6 +++--- example/android/gradle.properties | 2 ++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index e207aca..f7e5eca 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -32,7 +32,7 @@ android { } defaultConfig { minSdkVersion 16 - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } lintOptions { disable 'InvalidPackage' diff --git a/android/gradle.properties b/android/gradle.properties index 2bd6f4f..bb04111 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,2 +1,4 @@ +android.enableJetifier=true +android.useAndroidX=true org.gradle.jvmargs=-Xmx1536M diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index ddeebe6..2c76e94 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -43,7 +43,7 @@ android { targetSdkVersion 28 versionCode flutterVersionCode.toInteger() versionName flutterVersionName - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { @@ -62,6 +62,6 @@ flutter { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' } diff --git a/example/android/gradle.properties b/example/android/gradle.properties index 2bd6f4f..bb04111 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1,2 +1,4 @@ +android.enableJetifier=true +android.useAndroidX=true org.gradle.jvmargs=-Xmx1536M From a022bda0b7690de783287f3849806d4a7d57a90a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhos=20Istv=C3=A1n?= Date: Sun, 24 Nov 2019 12:08:59 +0100 Subject: [PATCH 04/14] Fix last & not being cut off of parameterized URLs Fixed in http_client_with_interceptor.dart --- lib/http_client_with_interceptor.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/http_client_with_interceptor.dart b/lib/http_client_with_interceptor.dart index 0ad89e5..541054c 100644 --- a/lib/http_client_with_interceptor.dart +++ b/lib/http_client_with_interceptor.dart @@ -136,7 +136,7 @@ class HttpClientWithInterceptor extends http.BaseClient { paramUrl += "$key=$value&"; }); paramUrl = paramUrl.substring( - 0, paramUrl.length); // to remove the last '&' character + 0, paramUrl.length - 1); // to remove the last '&' character } var requestUrl = Uri.parse(paramUrl); From 4fd2ce88c14152ec01f657ec705f248b60e96732 Mon Sep 17 00:00:00 2001 From: Alejandro Ulate Date: Wed, 27 Nov 2019 16:40:27 -0600 Subject: [PATCH 05/14] Adding tests. --- CHANGELOG.md | 7 ++ test/http_methods_test.dart | 142 ++++++++++++++++++++++++++++ test/models/request_data_test.dart | 56 +++++++++++ test/models/response_data_test.dart | 17 ++++ 4 files changed, 222 insertions(+) create mode 100644 test/http_methods_test.dart create mode 100644 test/models/request_data_test.dart create mode 100644 test/models/response_data_test.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 786f911..926e7dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 0.1.2 + +* Added: Unit testing for a few of the files. +* Modified: Android and iOS projects both in the plugin and the example now use Kotlin/Swift. +* Modified: Android projects both in the plugin and the example now use AndroidX namespaces. +* Fixed: Last '&' character was not removed from parametized URLs. + ## 0.1.1 * Fixed: HTTP Methods have misaligned parameters. Now they are called via named parameters to avoid type mismatch exceptions when being used. diff --git a/test/http_methods_test.dart b/test/http_methods_test.dart new file mode 100644 index 0000000..bc0f83e --- /dev/null +++ b/test/http_methods_test.dart @@ -0,0 +1,142 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:http_interceptor/http_methods.dart'; + +main() { + group("Can parse from string", () { + test("with HEAD method", () { + // Arrange + Method method; + String methodString = "HEAD"; + + // Act + method = methodFromString(methodString); + + // Assert + expect(method, equals(Method.HEAD)); + }); + test("with GET method", () { + // Arrange + Method method; + String methodString = "GET"; + + // Act + method = methodFromString(methodString); + + // Assert + expect(method, equals(Method.GET)); + }); + test("with POST method", () { + // Arrange + Method method; + String methodString = "POST"; + + // Act + method = methodFromString(methodString); + + // Assert + expect(method, equals(Method.POST)); + }); + test("with PUT method", () { + // Arrange + Method method; + String methodString = "PUT"; + + // Act + method = methodFromString(methodString); + + // Assert + expect(method, equals(Method.PUT)); + }); + test("with PATCH method", () { + // Arrange + Method method; + String methodString = "PATCH"; + + // Act + method = methodFromString(methodString); + + // Assert + expect(method, equals(Method.PATCH)); + }); + test("with DELETE method", () { + // Arrange + Method method; + String methodString = "DELETE"; + + // Act + method = methodFromString(methodString); + + // Assert + expect(method, equals(Method.DELETE)); + }); + }); + + group("Can parse to string", () { + test("to 'HEAD' string." , () { + // Arrange + String methodString; + Method method = Method.HEAD; + + // Act + methodString = methodToString(method); + + // Assert + expect(methodString, equals("HEAD")); + }); + test("to 'GET' string." , () { + // Arrange + String methodString; + Method method = Method.GET; + + // Act + methodString = methodToString(method); + + // Assert + expect(methodString, equals("GET")); + }); + test("to 'POST' string." , () { + // Arrange + String methodString; + Method method = Method.POST; + + // Act + methodString = methodToString(method); + + // Assert + expect(methodString, equals("POST")); + }); + test("to 'PUT' string." , () { + // Arrange + String methodString; + Method method = Method.PUT; + + // Act + methodString = methodToString(method); + + // Assert + expect(methodString, equals("PUT")); + }); + test("to 'PATCH' string." , () { + // Arrange + String methodString; + Method method = Method.PATCH; + + // Act + methodString = methodToString(method); + + // Assert + expect(methodString, equals("PATCH")); + }); + test("to 'DELETE' string." , () { + // Arrange + String methodString; + Method method = Method.DELETE; + + // Act + methodString = methodToString(method); + + // Assert + expect(methodString, equals("DELETE")); + }); + }); +} diff --git a/test/models/request_data_test.dart b/test/models/request_data_test.dart new file mode 100644 index 0000000..b9a5b39 --- /dev/null +++ b/test/models/request_data_test.dart @@ -0,0 +1,56 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:http/http.dart'; +import 'package:http_interceptor/models/request_data.dart'; +import 'package:http_interceptor/http_methods.dart'; + +main() { + group("Initialization: ", () { + test("can be instantiated", () { + // Arrange + RequestData requestData; + + // Act + requestData = RequestData(); + + // Assert + expect(requestData, isNotNull); + }); + test("can be instantiated from HTTP Request", () { + // Arrange + Uri url = Uri.parse( + "https://www.google.com/helloworld"); + + Request request = Request("GET", url); + RequestData requestData; + + // Act + requestData = RequestData.fromHttpRequest(request); + + // Assert + expect(requestData, isNotNull); + expect(requestData.method, equals(Method.GET)); + expect(requestData.url, equals("https://www.google.com/helloworld?key=123ABC&name=Hugo&type=3")); + expect(requestData.requestUrl, equals("https://www.google.com/helloworld")); + }); + }); + group("Parsing request paramters: ", () { + Uri url; + Request request; + RequestData requestData; + setUpAll(() { + url = Uri.parse( + "https://www.google.com/helloword?key=123ABC&name=Hugo&type=3"); + }); + test("Can parse parameters from GET Request", () { + // Arrange + request = Request("GET", url); + + // Act + requestData = RequestData.fromHttpRequest(request); + + // Assert + expect(requestData.method, equals(Method.GET)); + + }); + }); +} diff --git a/test/models/response_data_test.dart b/test/models/response_data_test.dart new file mode 100644 index 0000000..202b0ed --- /dev/null +++ b/test/models/response_data_test.dart @@ -0,0 +1,17 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:http_interceptor/models/response_data.dart'; + +main() { + group("Initialization", () { + test("ResponseData can be instantiated", () { + // Arrange + ResponseData requestData; + + // Act + requestData = ResponseData(); + + // Assert + expect(requestData, isNotNull); + }); + }); +} From 4dcf15ddc4bcc3949ef303d76c4b011a3f71ed0e Mon Sep 17 00:00:00 2001 From: Alejandro Ulate Date: Wed, 27 Nov 2019 18:10:30 -0600 Subject: [PATCH 06/14] Updating README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 16de5a5..886eec5 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![Pub](https://img.shields.io/pub/v/http_interceptor.svg)](https://pub.dev/packages/http_interceptor) [![style: effective dart](https://img.shields.io/badge/style-effective_dart-40c4ff.svg)](https://github.com/tenhobi/effective_dart) [![License: MIT](https://img.shields.io/badge/license-MIT-purple.svg)](https://opensource.org/licenses/MIT) +[![codecov](https://codecov.io/gh/CodingAleCR/http_interceptor/branch/master/graph/badge.svg)](https://codecov.io/gh/CodingAleCR/http_interceptor) [![Star on GitHub](https://img.shields.io/github/stars/codingalecr/http_interceptor.svg?style=flat&logo=github&colorB=deeppink&label=stars)](https://github.com/codingalecr/http_interceptor) A middleware library that lets you modify requests and responses if desired. Based of on [http_middleware](https://github.com/TEDConsulting/http_middleware) From f9a7b9f8c8b5af07fa5eaf7a9d3eedf2a7134711 Mon Sep 17 00:00:00 2001 From: Alejandro Ulate Date: Tue, 28 Jan 2020 18:03:34 -0600 Subject: [PATCH 07/14] Changelog: - Added tests. - Fixed example. --- analysis_options.yml | 2 +- android/.gitignore | 8 -- android/build.gradle | 44 --------- android/gradle.properties | 4 - .../gradle/wrapper/gradle-wrapper.properties | 5 - android/settings.gradle | 1 - android/src/main/AndroidManifest.xml | 3 - .../http_interceptor/HttpInterceptorPlugin.kt | 25 ----- example/.gitignore | 44 +-------- example/README.md | 2 +- example/android/.gitignore | 7 ++ example/android/app/build.gradle | 4 +- .../android/app/src/main/AndroidManifest.xml | 15 ++- .../com/example/example/MainActivity.kt | 13 ++- .../http_interceptor_example/MainActivity.kt | 13 --- example/android/build.gradle | 4 +- example/android/gradle.properties | 6 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- example/ios/.gitignore | 32 ++++++ example/ios/Flutter/Debug.xcconfig | 1 - example/ios/Flutter/Release.xcconfig | 1 - example/ios/Podfile | 74 -------------- example/ios/Runner.xcodeproj/project.pbxproj | 13 ++- example/lib/main.dart | 14 ++- example/pubspec.lock | 59 ++++++++++- example/pubspec.yaml | 43 +------- ios/.gitignore | 37 ------- ios/Assets/.gitkeep | 0 ios/Classes/HttpInterceptorPlugin.h | 4 - ios/Classes/HttpInterceptorPlugin.m | 8 -- ios/Classes/SwiftHttpInterceptorPlugin.swift | 14 --- ios/http_interceptor.podspec | 21 ---- lib/http_client_with_interceptor.dart | 64 +++++++----- lib/http_with_interceptor.dart | 98 ++++--------------- lib/models/request_data.dart | 39 +++----- lib/utils.dart | 18 ++++ pubspec.lock | 61 ++++++++++-- pubspec.yaml | 6 +- test/models/request_data_test.dart | 65 +++++++++--- test/utlis_test.dart | 33 +++++++ 40 files changed, 363 insertions(+), 544 deletions(-) delete mode 100644 android/.gitignore delete mode 100644 android/build.gradle delete mode 100644 android/gradle.properties delete mode 100644 android/gradle/wrapper/gradle-wrapper.properties delete mode 100644 android/settings.gradle delete mode 100644 android/src/main/AndroidManifest.xml delete mode 100644 android/src/main/kotlin/com/example/http_interceptor/HttpInterceptorPlugin.kt create mode 100644 example/android/.gitignore delete mode 100644 example/android/app/src/main/kotlin/com/example/http_interceptor_example/MainActivity.kt create mode 100644 example/ios/.gitignore delete mode 100644 example/ios/Podfile delete mode 100644 ios/.gitignore delete mode 100644 ios/Assets/.gitkeep delete mode 100644 ios/Classes/HttpInterceptorPlugin.h delete mode 100644 ios/Classes/HttpInterceptorPlugin.m delete mode 100644 ios/Classes/SwiftHttpInterceptorPlugin.swift delete mode 100644 ios/http_interceptor.podspec create mode 100644 lib/utils.dart create mode 100644 test/utlis_test.dart diff --git a/analysis_options.yml b/analysis_options.yml index 30dcb3b..c9cf67f 100644 --- a/analysis_options.yml +++ b/analysis_options.yml @@ -1 +1 @@ -include: package:effective_dart/analysis_options.1.1.0.yaml \ No newline at end of file +include: package:effective_dart/analysis_options.1.2.1.yaml \ No newline at end of file diff --git a/android/.gitignore b/android/.gitignore deleted file mode 100644 index c6cbe56..0000000 --- a/android/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*.iml -.gradle -/local.properties -/.idea/workspace.xml -/.idea/libraries -.DS_Store -/build -/captures diff --git a/android/build.gradle b/android/build.gradle deleted file mode 100644 index f7e5eca..0000000 --- a/android/build.gradle +++ /dev/null @@ -1,44 +0,0 @@ -group 'com.example.http_interceptor' -version '1.0-SNAPSHOT' - -buildscript { - ext.kotlin_version = '1.2.71' - repositories { - google() - jcenter() - } - - dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - -rootProject.allprojects { - repositories { - google() - jcenter() - } -} - -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' - -android { - compileSdkVersion 28 - - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } - defaultConfig { - minSdkVersion 16 - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - lintOptions { - disable 'InvalidPackage' - } -} - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" -} diff --git a/android/gradle.properties b/android/gradle.properties deleted file mode 100644 index bb04111..0000000 --- a/android/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -android.enableJetifier=true -android.useAndroidX=true -org.gradle.jvmargs=-Xmx1536M - diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 019065d..0000000 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip diff --git a/android/settings.gradle b/android/settings.gradle deleted file mode 100644 index 34edcd5..0000000 --- a/android/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'http_interceptor' diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml deleted file mode 100644 index 8b62ad8..0000000 --- a/android/src/main/AndroidManifest.xml +++ /dev/null @@ -1,3 +0,0 @@ - - diff --git a/android/src/main/kotlin/com/example/http_interceptor/HttpInterceptorPlugin.kt b/android/src/main/kotlin/com/example/http_interceptor/HttpInterceptorPlugin.kt deleted file mode 100644 index 83429b8..0000000 --- a/android/src/main/kotlin/com/example/http_interceptor/HttpInterceptorPlugin.kt +++ /dev/null @@ -1,25 +0,0 @@ -package com.example.http_interceptor - -import io.flutter.plugin.common.MethodCall -import io.flutter.plugin.common.MethodChannel -import io.flutter.plugin.common.MethodChannel.MethodCallHandler -import io.flutter.plugin.common.MethodChannel.Result -import io.flutter.plugin.common.PluginRegistry.Registrar - -class HttpInterceptorPlugin: MethodCallHandler { - companion object { - @JvmStatic - fun registerWith(registrar: Registrar) { - val channel = MethodChannel(registrar.messenger(), "http_interceptor") - channel.setMethodCallHandler(HttpInterceptorPlugin()) - } - } - - override fun onMethodCall(call: MethodCall, result: Result) { - if (call.method == "getPlatformVersion") { - result.success("Android ${android.os.Build.VERSION.RELEASE}") - } else { - result.notImplemented() - } - } -} diff --git a/example/.gitignore b/example/.gitignore index 95c7e97..ae1f183 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -18,56 +18,20 @@ # 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/ +#.vscode/ # Flutter/Dart/Pub related **/doc/api/ .dart_tool/ .flutter-plugins +.flutter-plugins-dependencies .packages .pub-cache/ .pub/ /build/ -# Android related -**/android/**/gradle-wrapper.jar -**/android/.gradle -**/android/captures/ -**/android/gradlew -**/android/gradlew.bat -**/android/local.properties -**/android/**/GeneratedPluginRegistrant.java - -# iOS/XCode related -**/ios/**/*.mode1v3 -**/ios/**/*.mode2v3 -**/ios/**/*.moved-aside -**/ios/**/*.pbxuser -**/ios/**/*.perspectivev3 -**/ios/**/*sync/ -**/ios/**/.sconsign.dblite -**/ios/**/.tags* -**/ios/**/.vagrant/ -**/ios/**/DerivedData/ -**/ios/**/Icon? -**/ios/**/Pods/ -**/ios/**/.symlinks/ -**/ios/**/profile -**/ios/**/xcuserdata -**/ios/.generated/ -**/ios/Flutter/App.framework -**/ios/Flutter/Flutter.framework -**/ios/Flutter/Generated.xcconfig -**/ios/Flutter/app.flx -**/ios/Flutter/app.zip -**/ios/Flutter/flutter_assets/ -**/ios/Flutter/flutter_export_environment.sh -**/ios/ServiceDefinitions.json -**/ios/Runner/GeneratedPluginRegistrant.* +# Web related +lib/generated_plugin_registrant.dart # Exceptions to above rules. -!**/ios/**/default.mode1v3 -!**/ios/**/default.mode2v3 -!**/ios/**/default.pbxuser -!**/ios/**/default.perspectivev3 !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages diff --git a/example/README.md b/example/README.md index 1aea750..4ffd48d 100644 --- a/example/README.md +++ b/example/README.md @@ -1,5 +1,4 @@ # OpenWeatherApp -**http_interceptor example** Demonstrates how to use the http_interceptor plugin. @@ -8,4 +7,5 @@ Demonstrates how to use the http_interceptor plugin. This app implements the usage of the http_interceptor plugin. It uses the OpenWeatherAPI and intercepts the requests done to add the App Id Key and the unit system desired for the response. Notice that this example is for **show purposes only, it is not intended as a full testable implementation**. ### Running the example + In order to run this example locally you will need to replace the API Key in the `credentials.dart`. You can get your own at https://openweathermap.org/ diff --git a/example/android/.gitignore b/example/android/.gitignore new file mode 100644 index 0000000..bc2100d --- /dev/null +++ b/example/android/.gitignore @@ -0,0 +1,7 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 2c76e94..0f6a5e5 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -62,6 +62,6 @@ flutter { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test.ext:junit:1.1.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' + androidTestImplementation 'androidx.test:runner:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' } diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 2877140..8bc6007 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - - + + diff --git a/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt b/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt index e2c0fd3..1656503 100644 --- a/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt +++ b/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt @@ -1,13 +1,12 @@ package com.example.example -import android.os.Bundle - -import io.flutter.app.FlutterActivity +import androidx.annotation.NonNull; +import io.flutter.embedding.android.FlutterActivity +import io.flutter.embedding.engine.FlutterEngine import io.flutter.plugins.GeneratedPluginRegistrant class MainActivity: FlutterActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - GeneratedPluginRegistrant.registerWith(this) - } + override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { + GeneratedPluginRegistrant.registerWith(flutterEngine); + } } diff --git a/example/android/app/src/main/kotlin/com/example/http_interceptor_example/MainActivity.kt b/example/android/app/src/main/kotlin/com/example/http_interceptor_example/MainActivity.kt deleted file mode 100644 index 11012ad..0000000 --- a/example/android/app/src/main/kotlin/com/example/http_interceptor_example/MainActivity.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.example.http_interceptor_example - -import android.os.Bundle - -import io.flutter.app.FlutterActivity -import io.flutter.plugins.GeneratedPluginRegistrant - -class MainActivity: FlutterActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - GeneratedPluginRegistrant.registerWith(this) - } -} diff --git a/example/android/build.gradle b/example/android/build.gradle index b7faad8..3100ad2 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.2.71' + ext.kotlin_version = '1.3.50' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' + classpath 'com.android.tools.build:gradle:3.5.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/example/android/gradle.properties b/example/android/gradle.properties index bb04111..38c8d45 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1,4 +1,4 @@ -android.enableJetifier=true -android.useAndroidX=true org.gradle.jvmargs=-Xmx1536M - +android.enableR8=true +android.useAndroidX=true +android.enableJetifier=true diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 2819f02..296b146 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip diff --git a/example/ios/.gitignore b/example/ios/.gitignore new file mode 100644 index 0000000..e96ef60 --- /dev/null +++ b/example/ios/.gitignore @@ -0,0 +1,32 @@ +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/example/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig index e8efba1..592ceee 100644 --- a/example/ios/Flutter/Debug.xcconfig +++ b/example/ios/Flutter/Debug.xcconfig @@ -1,2 +1 @@ -#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Flutter/Release.xcconfig b/example/ios/Flutter/Release.xcconfig index 399e934..592ceee 100644 --- a/example/ios/Flutter/Release.xcconfig +++ b/example/ios/Flutter/Release.xcconfig @@ -1,2 +1 @@ -#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Podfile b/example/ios/Podfile deleted file mode 100644 index e9286cb..0000000 --- a/example/ios/Podfile +++ /dev/null @@ -1,74 +0,0 @@ -# Uncomment this line to define a global platform for your project -# platform :ios, '9.0' - -# CocoaPods analytics sends network stats synchronously affecting flutter build latency. -ENV['COCOAPODS_DISABLE_STATS'] = 'true' - -project 'Runner', { - 'Debug' => :debug, - 'Profile' => :release, - 'Release' => :release, -} - -def parse_KV_file(file, separator='=') - file_abs_path = File.expand_path(file) - if !File.exists? file_abs_path - return []; - end - pods_ary = [] - skip_line_start_symbols = ["#", "/"] - File.foreach(file_abs_path) { |line| - next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } - plugin = line.split(pattern=separator) - if plugin.length == 2 - podname = plugin[0].strip() - path = plugin[1].strip() - podpath = File.expand_path("#{path}", file_abs_path) - pods_ary.push({:name => podname, :path => podpath}); - else - puts "Invalid plugin specification: #{line}" - end - } - return pods_ary -end - -target 'Runner' do - use_frameworks! - - # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock - # referring to absolute paths on developers' machines. - system('rm -rf .symlinks') - system('mkdir -p .symlinks/plugins') - - # Flutter Pods - generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig') - if generated_xcode_build_settings.empty? - puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first." - end - generated_xcode_build_settings.map { |p| - if p[:name] == 'FLUTTER_FRAMEWORK_DIR' - symlink = File.join('.symlinks', 'flutter') - File.symlink(File.dirname(p[:path]), symlink) - pod 'Flutter', :path => File.join(symlink, File.basename(p[:path])) - end - } - - # Plugin Pods - plugin_pods = parse_KV_file('../.flutter-plugins') - plugin_pods.map { |p| - symlink = File.join('.symlinks', 'plugins', p[:name]) - File.symlink(p[:path], symlink) - pod p[:name], :path => File.join(symlink, 'ios') - } -end - -# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. -install! 'cocoapods', :disable_input_output_paths => true - -post_install do |installer| - installer.pods_project.targets.each do |target| - target.build_configurations.each do |config| - config.build_settings['ENABLE_BITCODE'] = 'NO' - end - end -end diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 7d30b69..0d45b98 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -14,7 +14,6 @@ 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; @@ -153,7 +152,7 @@ TargetAttributes = { 97C146ED1CF9000F007C117D = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 0910; + LastSwiftMigration = 1100; }; }; }; @@ -182,7 +181,6 @@ files = ( 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, - 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */, 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, ); @@ -298,6 +296,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -324,7 +323,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.example.example; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; }; name = Profile; @@ -430,6 +429,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; @@ -458,7 +458,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; }; name = Debug; @@ -484,7 +484,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.example.example; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; }; name = Release; @@ -513,7 +513,6 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ - }; rootObject = 97C146E61CF9000F007C117D /* Project object */; } diff --git a/example/lib/main.dart b/example/lib/main.dart index 0528620..318094b 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -137,14 +137,15 @@ class WeatherSearch extends SearchDelegate { return FutureBuilder( future: repo.fetchCityWeather(city["id"]), builder: (context, snapshot) { - if (!snapshot.hasData) { + if (snapshot.hasError) { return Center( - child: CircularProgressIndicator(), + child: Text(snapshot.error), ); } - if (snapshot.hasError) { + + if (!snapshot.hasData) { return Center( - child: Text(snapshot.error), + child: CircularProgressIndicator(), ); } final weather = snapshot.data; @@ -261,7 +262,10 @@ class WeatherRepository { if (response.statusCode == 200) { parsedWeather = json.decode(response.body); } else { - throw Exception("Error while fetching. \n ${response.body}"); + return Future.error( + "Error while fetching.", + StackTrace.fromString("${response.body}"), + ); } } catch (e) { print(e); diff --git a/example/pubspec.lock b/example/pubspec.lock index 71d5064..7eaf55f 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,13 +1,27 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + archive: + dependency: transitive + description: + name: archive + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.11" + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "1.5.2" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.3.0" + version: "2.4.0" boolean_selector: dependency: transitive description: @@ -29,6 +43,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.14.11" + convert: + dependency: transitive + description: + name: convert + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.3" cupertino_icons: dependency: "direct main" description: @@ -67,20 +95,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.3" + image: + dependency: transitive + description: + name: image + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.4" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.5" + version: "0.12.6" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.7" + version: "1.1.8" path: dependency: transitive description: @@ -95,6 +130,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0+1" + petitparser: + dependency: transitive + description: + name: petitparser + url: "https://pub.dartlang.org" + source: hosted + version: "2.4.0" quiver: dependency: transitive description: @@ -148,7 +190,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.5" + version: "0.2.11" typed_data: dependency: transitive description: @@ -163,5 +205,12 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.8" + xml: + dependency: transitive + description: + name: xml + url: "https://pub.dartlang.org" + source: hosted + version: "3.5.0" sdks: - dart: ">=2.2.2 <3.0.0" + dart: ">=2.4.0 <3.0.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 05b761a..e04274b 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,5 +1,6 @@ name: http_interceptor_example description: Demonstrates how to use the http_interceptor plugin. +version: 0.0.1+1 publish_to: 'none' environment: @@ -8,9 +9,6 @@ environment: dependencies: flutter: sdk: flutter - - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^0.1.2 dev_dependencies: @@ -20,44 +18,5 @@ dev_dependencies: http_interceptor: path: ../ -# For information on the generic Dart part of this file, see the -# following page: https://www.dartlang.org/tools/pub/pubspec - -# The following section is specific to Flutter. 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.io/assets-and-images/#resolution-aware. - - # For details regarding adding assets from package dependencies, see - # https://flutter.io/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.io/custom-fonts/#from-packages diff --git a/ios/.gitignore b/ios/.gitignore deleted file mode 100644 index aa479fd..0000000 --- a/ios/.gitignore +++ /dev/null @@ -1,37 +0,0 @@ -.idea/ -.vagrant/ -.sconsign.dblite -.svn/ - -.DS_Store -*.swp -profile - -DerivedData/ -build/ -GeneratedPluginRegistrant.h -GeneratedPluginRegistrant.m - -.generated/ - -*.pbxuser -*.mode1v3 -*.mode2v3 -*.perspectivev3 - -!default.pbxuser -!default.mode1v3 -!default.mode2v3 -!default.perspectivev3 - -xcuserdata - -*.moved-aside - -*.pyc -*sync/ -Icon? -.tags* - -/Flutter/Generated.xcconfig -/Flutter/flutter_export_environment.sh \ No newline at end of file diff --git a/ios/Assets/.gitkeep b/ios/Assets/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/ios/Classes/HttpInterceptorPlugin.h b/ios/Classes/HttpInterceptorPlugin.h deleted file mode 100644 index 0f1f54b..0000000 --- a/ios/Classes/HttpInterceptorPlugin.h +++ /dev/null @@ -1,4 +0,0 @@ -#import - -@interface HttpInterceptorPlugin : NSObject -@end diff --git a/ios/Classes/HttpInterceptorPlugin.m b/ios/Classes/HttpInterceptorPlugin.m deleted file mode 100644 index 2115192..0000000 --- a/ios/Classes/HttpInterceptorPlugin.m +++ /dev/null @@ -1,8 +0,0 @@ -#import "HttpInterceptorPlugin.h" -#import - -@implementation HttpInterceptorPlugin -+ (void)registerWithRegistrar:(NSObject*)registrar { - [SwiftHttpInterceptorPlugin registerWithRegistrar:registrar]; -} -@end diff --git a/ios/Classes/SwiftHttpInterceptorPlugin.swift b/ios/Classes/SwiftHttpInterceptorPlugin.swift deleted file mode 100644 index 5b0cde1..0000000 --- a/ios/Classes/SwiftHttpInterceptorPlugin.swift +++ /dev/null @@ -1,14 +0,0 @@ -import Flutter -import UIKit - -public class SwiftHttpInterceptorPlugin: NSObject, FlutterPlugin { - public static func register(with registrar: FlutterPluginRegistrar) { - let channel = FlutterMethodChannel(name: "http_interceptor", binaryMessenger: registrar.messenger()) - let instance = SwiftHttpInterceptorPlugin() - registrar.addMethodCallDelegate(instance, channel: channel) - } - - public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { - result("iOS " + UIDevice.current.systemVersion) - } -} diff --git a/ios/http_interceptor.podspec b/ios/http_interceptor.podspec deleted file mode 100644 index e7d8d93..0000000 --- a/ios/http_interceptor.podspec +++ /dev/null @@ -1,21 +0,0 @@ -# -# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html -# -Pod::Spec.new do |s| - s.name = 'http_interceptor' - s.version = '0.0.1' - s.summary = 'A new flutter plugin project.' - s.description = <<-DESC -A new flutter plugin project. - DESC - s.homepage = 'http://example.com' - s.license = { :file => '../LICENSE' } - s.author = { 'Your Company' => 'email@example.com' } - s.source = { :path => '.' } - s.source_files = 'Classes/**/*' - s.public_header_files = 'Classes/**/*.h' - s.dependency 'Flutter' - - s.ios.deployment_target = '8.0' -end - diff --git a/lib/http_client_with_interceptor.dart b/lib/http_client_with_interceptor.dart index 541054c..cd9c959 100644 --- a/lib/http_client_with_interceptor.dart +++ b/lib/http_client_with_interceptor.dart @@ -6,6 +6,7 @@ import 'package:http/http.dart' as http; import 'package:http/http.dart'; import 'package:http_interceptor/models/models.dart'; import 'package:http_interceptor/interceptor_contract.dart'; +import 'package:http_interceptor/utils.dart'; import 'http_methods.dart'; @@ -42,11 +43,13 @@ class HttpClientWithInterceptor extends http.BaseClient { HttpClientWithInterceptor._internal({this.interceptors, this.requestTimeout}); factory HttpClientWithInterceptor.build({ - List interceptors, + @required List interceptors, Duration requestTimeout, }) { + assert(interceptors != null); + //Remove any value that is null. - interceptors?.removeWhere((interceptor) => interceptor == null); + interceptors.removeWhere((interceptor) => interceptor == null); return HttpClientWithInterceptor._internal( interceptors: interceptors, requestTimeout: requestTimeout, @@ -123,25 +126,15 @@ class HttpClientWithInterceptor extends http.BaseClient { Future _sendUnstreamed({ @required Method method, - @required String url, + @required url, @required Map headers, Map params, dynamic body, Encoding encoding, }) async { - String paramUrl = url; - if (params != null && params.length > 0) { - paramUrl += "?"; - params.forEach((key, value) { - paramUrl += "$key=$value&"; - }); - paramUrl = paramUrl.substring( - 0, paramUrl.length - 1); // to remove the last '&' character - } - - var requestUrl = Uri.parse(paramUrl); - var request = new Request(methodToString(method), requestUrl); + if (url is String) url = Uri.parse(addParametersToUrl(url, params)); + Request request = new Request(methodToString(method), url); if (headers != null) request.headers.addAll(headers); if (encoding != null) request.encoding = encoding; if (body != null) { @@ -156,13 +149,8 @@ class HttpClientWithInterceptor extends http.BaseClient { } } - //Perform request interception - for (InterceptorContract interceptor in interceptors) { - RequestData interceptedData = await interceptor.interceptRequest( - data: RequestData.fromHttpRequest(request), - ); - request = interceptedData.toHttpRequest(); - } + // Intercept request + await _interceptRequest(request); var stream = requestTimeout == null ? await send(request) @@ -170,12 +158,10 @@ class HttpClientWithInterceptor extends http.BaseClient { var response = await Response.fromStream(stream); - var responseData = ResponseData.fromHttpResponse(response); - for (InterceptorContract interceptor in interceptors) { - responseData = await interceptor.interceptResponse(data: responseData); - } + // Intercept response + response = await _interceptResponse(response); - return responseData.toHttpResponse(); + return response; } void _checkResponseSuccess(url, Response response) { @@ -188,6 +174,30 @@ class HttpClientWithInterceptor extends http.BaseClient { throw new ClientException("$message.", url); } + /// This internal function intercepts the request. + Future _interceptRequest(Request request) async { + for (InterceptorContract interceptor in interceptors) { + RequestData interceptedData = await interceptor.interceptRequest( + data: RequestData.fromHttpRequest(request), + ); + request = interceptedData.toHttpRequest(); + } + + return request; + } + + /// This internal function intercepts the response. + Future _interceptResponse(Response response) async { + for (InterceptorContract interceptor in interceptors) { + ResponseData responseData = await interceptor.interceptResponse( + data: ResponseData.fromHttpResponse(response), + ); + response = responseData.toHttpResponse(); + } + + return response; + } + void close() { _client.close(); } diff --git a/lib/http_with_interceptor.dart b/lib/http_with_interceptor.dart index 15ac2e9..19e9b55 100644 --- a/lib/http_with_interceptor.dart +++ b/lib/http_with_interceptor.dart @@ -3,8 +3,7 @@ import 'dart:convert'; import 'dart:typed_data'; import 'package:flutter/foundation.dart'; import 'package:http/http.dart'; -import 'package:http_interceptor/http_methods.dart'; -import 'package:http_interceptor/models/models.dart'; +import 'package:http_interceptor/http_interceptor.dart'; import 'package:http_interceptor/interceptor_contract.dart'; ///Class to be used by the user as a replacement for 'http' with interceptor supported. @@ -36,69 +35,48 @@ class HttpWithInterceptor { }); factory HttpWithInterceptor.build({ - List interceptors, + @required List interceptors, Duration requestTimeout, }) { + assert(interceptors != null); + //Remove any value that is null. interceptors?.removeWhere((interceptor) => interceptor == null); return new HttpWithInterceptor._internal( - interceptors: interceptors, requestTimeout: requestTimeout); + interceptors: interceptors, + requestTimeout: requestTimeout, + ); } Future head(url, {Map headers}) async { - await _sendInterception(method: Method.HEAD, headers: headers, url: url); return _withClient((client) => client.head(url, headers: headers)); } Future get(url, {Map headers, Map params}) async { - RequestData data = await _sendInterception( - method: Method.GET, headers: headers, url: url, params: params); - return _withClient( - (client) => client.get(data.requestUrl, headers: data.headers)); + return _withClient((client) => client.get(url, headers: headers, params: params)); } Future post(url, {Map headers, body, Encoding encoding}) async { - RequestData data = await _sendInterception( - method: Method.POST, - headers: headers, - url: url, - body: body, - encoding: encoding); - return _withClient((client) => client.post(data.url, - headers: data.headers, body: data.body, encoding: data.encoding)); + return _withClient((client) => + client.post(url, headers: headers, body: body, encoding: encoding)); } Future put(url, {Map headers, body, Encoding encoding}) async { - RequestData data = await _sendInterception( - method: Method.PUT, - headers: headers, - url: url, - body: body, - encoding: encoding); - return _withClient((client) => client.put(data.url, - headers: data.headers, body: data.body, encoding: data.encoding)); + return _withClient((client) => + client.put(url, headers: headers, body: body, encoding: encoding)); } Future patch(url, {Map headers, body, Encoding encoding}) async { - RequestData data = await _sendInterception( - method: Method.PATCH, - headers: headers, - url: url, - body: body, - encoding: encoding); - return _withClient((client) => client.patch(data.url, - headers: data.headers, body: data.body, encoding: data.encoding)); + return _withClient((client) => + client.patch(url, headers: headers, body: body, encoding: encoding)); } Future delete(url, {Map headers}) async { - RequestData data = await _sendInterception( - method: Method.DELETE, headers: headers, url: url); - return _withClient( - (client) => client.delete(data.url, headers: data.headers)); + return _withClient((client) => client.delete(url, headers: headers)); } Future read(url, {Map headers}) { @@ -108,48 +86,14 @@ class HttpWithInterceptor { Future readBytes(url, {Map headers}) => _withClient((client) => client.readBytes(url, headers: headers)); - Future _sendInterception({ - @required Method method, - @required String url, - @required Map headers, - Map params, - dynamic body, - Encoding encoding, - }) async { - RequestData data = RequestData( - method: method, - encoding: encoding, - body: body, - url: url, - headers: headers ?? {}, - params: params ?? {}, + Future _withClient( + Future fn(HttpClientWithInterceptor client)) async { + var client = new HttpClientWithInterceptor.build( + interceptors: interceptors, + requestTimeout: requestTimeout, ); - - //Perform request interception - for (InterceptorContract interceptor in interceptors) { - data = await interceptor.interceptRequest( - data: data, - ); - } - return data; - } - - Future _withClient(Future fn(Client client)) async { - var client = new Client(); try { - T response = requestTimeout == null - ? await fn(client) - : await fn(client).timeout(requestTimeout); - if (response is Response) { - var responseData = ResponseData.fromHttpResponse(response); - for (InterceptorContract interceptor in interceptors) { - responseData = - await interceptor.interceptResponse(data: responseData); - } - - return responseData.toHttpResponse() as T; - } - return response; + return await fn(client); } finally { client.close(); } diff --git a/lib/models/request_data.dart b/lib/models/request_data.dart index 101aa2f..04de9e2 100644 --- a/lib/models/request_data.dart +++ b/lib/models/request_data.dart @@ -1,62 +1,51 @@ import 'dart:convert'; +import 'package:flutter/foundation.dart'; import 'package:http/http.dart'; import 'package:http_interceptor/http_methods.dart'; +import 'package:http_interceptor/utils.dart'; class RequestData { Method method; - String url; + String baseUrl; Map headers; Map params; dynamic body; Encoding encoding; RequestData({ - this.method, - this.url, + @required this.method, + @required this.baseUrl, this.headers, this.params, this.body, this.encoding, - }); + }) : assert(method != null), + assert(baseUrl != null); - String get requestUrl { - var paramUrl = url; - if (params != null && params.length > 0) { - paramUrl += "?"; - params.forEach((key, value) { - paramUrl += "$key=$value&"; - }); - paramUrl = paramUrl.substring(0, paramUrl.length); - } - return paramUrl; - } + String get url => addParametersToUrl(baseUrl, params); factory RequestData.fromHttpRequest(Request request) { var params = Map(); request.url.queryParameters.forEach((key, value) { params[key] = value; }); + String baseUrl = request.url.origin + request.url.path; return RequestData( method: methodFromString(request.method), encoding: request.encoding, body: request.body, - url: request.url.toString(), + baseUrl: baseUrl, headers: request.headers ?? {}, params: params ?? {}, ); } Request toHttpRequest() { - var paramUrl = url; - if (params != null && params.length > 0) { - paramUrl += "?"; - params.forEach((key, value) { - paramUrl += "$key=$value&"; - }); - paramUrl = paramUrl.substring(0, paramUrl.length); - } - var request = new Request(methodToString(method), Uri.parse(paramUrl)); + var reqUrl = Uri.parse(addParametersToUrl(baseUrl, params)); + + Request request = new Request(methodToString(method), reqUrl); + if (headers != null) request.headers.addAll(headers); if (encoding != null) request.encoding = encoding; if (body != null) { diff --git a/lib/utils.dart b/lib/utils.dart new file mode 100644 index 0000000..25a3cbf --- /dev/null +++ b/lib/utils.dart @@ -0,0 +1,18 @@ +/// When having an URL as String and no parameters sent then it adds +/// them to the string. +String addParametersToUrl(String url, Map parameters) { + if (parameters == null) return url; + + String paramUrl = url; + if (parameters != null && parameters.length > 0) { + if (paramUrl.contains("?")) + paramUrl += "&"; + else + paramUrl += "?"; + parameters.forEach((key, value) { + paramUrl += "$key=$value&"; + }); + paramUrl = paramUrl.substring(0, paramUrl.length - 1); + } + return paramUrl; +} diff --git a/pubspec.lock b/pubspec.lock index 5ee37c1..873f69e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,13 +1,27 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + archive: + dependency: transitive + description: + name: archive + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.11" + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "1.5.2" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.3.0" + version: "2.4.0" boolean_selector: dependency: transitive description: @@ -29,13 +43,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.14.11" + convert: + dependency: transitive + description: + name: convert + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.3" effective_dart: dependency: "direct dev" description: name: effective_dart url: "https://pub.dartlang.org" source: hosted - version: "1.1.1" + version: "1.2.1" flutter: dependency: "direct main" description: flutter @@ -60,20 +88,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.3" + image: + dependency: transitive + description: + name: image + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.4" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.5" + version: "0.12.6" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.7" + version: "1.1.8" path: dependency: transitive description: @@ -88,6 +123,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0+1" + petitparser: + dependency: transitive + description: + name: petitparser + url: "https://pub.dartlang.org" + source: hosted + version: "2.4.0" quiver: dependency: transitive description: @@ -141,7 +183,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.5" + version: "0.2.11" typed_data: dependency: transitive description: @@ -156,5 +198,12 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.8" + xml: + dependency: transitive + description: + name: xml + url: "https://pub.dartlang.org" + source: hosted + version: "3.5.0" sdks: - dart: ">=2.2.2 <3.0.0" + dart: ">=2.4.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 6033c7d..e78a7ab 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,11 +15,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - effective_dart: ^1.1.0 + effective_dart: ^1.2.1 flutter: - plugin: - androidPackage: codingalecr.http_interceptor - pluginClass: HttpInterceptorPlugin - diff --git a/test/models/request_data_test.dart b/test/models/request_data_test.dart index b9a5b39..cf72481 100644 --- a/test/models/request_data_test.dart +++ b/test/models/request_data_test.dart @@ -10,15 +10,15 @@ main() { RequestData requestData; // Act - requestData = RequestData(); + requestData = RequestData( + method: Method.GET, baseUrl: "https://www.google.com/helloworld"); // Assert expect(requestData, isNotNull); }); - test("can be instantiated from HTTP Request", () { + test("can be instantiated from HTTP GET Request", () { // Arrange - Uri url = Uri.parse( - "https://www.google.com/helloworld"); + Uri url = Uri.parse("https://www.google.com/helloworld"); Request request = Request("GET", url); RequestData requestData; @@ -29,28 +29,61 @@ main() { // Assert expect(requestData, isNotNull); expect(requestData.method, equals(Method.GET)); - expect(requestData.url, equals("https://www.google.com/helloworld?key=123ABC&name=Hugo&type=3")); - expect(requestData.requestUrl, equals("https://www.google.com/helloworld")); + expect(requestData.url, equals("https://www.google.com/helloworld")); }); - }); - group("Parsing request paramters: ", () { - Uri url; - Request request; - RequestData requestData; - setUpAll(() { - url = Uri.parse( - "https://www.google.com/helloword?key=123ABC&name=Hugo&type=3"); + test("can be instantiated from HTTP GET Request with long path", () { + // Arrange + Uri url = Uri.parse("https://www.google.com/helloworld/foo/bar"); + + Request request = Request("GET", url); + RequestData requestData; + + // Act + requestData = RequestData.fromHttpRequest(request); + + // Assert + expect(requestData, isNotNull); + expect(requestData.method, equals(Method.GET)); + expect(requestData.url, equals("https://www.google.com/helloworld/foo/bar")); }); - test("Can parse parameters from GET Request", () { + test("can be instantiated from HTTP GET Request with parameters", () { // Arrange - request = Request("GET", url); + Uri url = Uri.parse( + "https://www.google.com/helloworld?key=123ABC&name=Hugo&type=3"); + + Request request = Request("GET", url); + RequestData requestData; // Act requestData = RequestData.fromHttpRequest(request); // Assert + expect(requestData, isNotNull); expect(requestData.method, equals(Method.GET)); + expect(requestData.baseUrl, equals("https://www.google.com/helloworld")); + expect( + requestData.url, + equals( + "https://www.google.com/helloworld?key=123ABC&name=Hugo&type=3")); + }); + test("correctly creates the request URL string", () { + // Arrange + Uri url = Uri.parse( + "https://www.google.com/helloworld?key=123ABC&name=Hugo&type=3"); + Request request = Request("GET", url); + RequestData requestData; + + // Act + requestData = RequestData.fromHttpRequest(request); + + // Assert + expect(requestData, isNotNull); + expect(requestData.method, equals(Method.GET)); + expect( + requestData.url, + equals( + "https://www.google.com/helloworld?key=123ABC&name=Hugo&type=3")); }); }); } diff --git a/test/utlis_test.dart b/test/utlis_test.dart new file mode 100644 index 0000000..4d7032c --- /dev/null +++ b/test/utlis_test.dart @@ -0,0 +1,33 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:http_interceptor/utils.dart'; + +main() { + group("addParametersToUrl", () { + test("Adds parameters to a URL string without parameters", () { + // Arrange + String url = "https://www.google.com/helloworld"; + Map parameters = {"foo": "bar", "num": "0"}; + + // Act + String parameterUrl = addParametersToUrl(url, parameters); + + // Assert + expect(parameterUrl, + equals("https://www.google.com/helloworld?foo=bar&num=0")); + }); + test("Adds parameters to a URL string with parameters", () { + // Arrange + String url = "https://www.google.com/helloworld?foo=bar&num=0"; + Map parameters = {"extra": "1", "extra2": "anotherone"}; + + // Act + String parameterUrl = addParametersToUrl(url, parameters); + + // Assert + expect( + parameterUrl, + equals( + "https://www.google.com/helloworld?foo=bar&num=0&extra=1&extra2=anotherone")); + }); + }); +} From 1dad13fb7473e7f306a16e0bea4a06038be5f42f Mon Sep 17 00:00:00 2001 From: Alejandro Ulate Date: Tue, 28 Jan 2020 18:04:21 -0600 Subject: [PATCH 08/14] Changelog: - Fixed README. --- example/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/README.md b/example/README.md index 4ffd48d..5f5a94d 100644 --- a/example/README.md +++ b/example/README.md @@ -8,4 +8,4 @@ This app implements the usage of the http_interceptor plugin. It uses the OpenWe ### Running the example -In order to run this example locally you will need to replace the API Key in the `credentials.dart`. You can get your own at https://openweathermap.org/ +In order to run this example locally you will need to replace the API Key in the `credentials.dart`. You can get your own at From 8c56e07ab00a16b8fb16ac7e6ce4707113432a0e Mon Sep 17 00:00:00 2001 From: Alejandro Ulate Date: Tue, 28 Jan 2020 18:11:18 -0600 Subject: [PATCH 09/14] Changelog: - Updated author. --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index e78a7ab..bd122d6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: http_interceptor description: A lightweight, simple plugin that allows you to intercept request and response objects and modify them if desired. version: 0.1.1 -author: Alejandro Ulate (codingalecr) +author: Alejandro Ulate (codingalecr) homepage: https://github.com/CodingAleCR/http_interceptor environment: From fb824654b00559e315000ff1e71e298ce6adbc55 Mon Sep 17 00:00:00 2001 From: Alejandro Ulate Date: Tue, 28 Jan 2020 18:13:27 -0600 Subject: [PATCH 10/14] Changelog: - Formatting models.dart --- lib/models/models.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/models/models.dart b/lib/models/models.dart index 0510593..f03bc76 100644 --- a/lib/models/models.dart +++ b/lib/models/models.dart @@ -1,2 +1,2 @@ export 'request_data.dart'; -export 'response_data.dart'; \ No newline at end of file +export 'response_data.dart'; From eb33c8261e35e90aee539a17be8d6b3647bb51fa Mon Sep 17 00:00:00 2001 From: Alejandro Ulate Date: Tue, 28 Jan 2020 19:01:06 -0600 Subject: [PATCH 11/14] Changelog: - Renamed utlis_test to utils_test. - Removed author section no longer needed. --- pubspec.yaml | 1 - test/utlis_test.dart | 33 --------------------------------- 2 files changed, 34 deletions(-) delete mode 100644 test/utlis_test.dart diff --git a/pubspec.yaml b/pubspec.yaml index bd122d6..a539e80 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,6 @@ name: http_interceptor description: A lightweight, simple plugin that allows you to intercept request and response objects and modify them if desired. version: 0.1.1 -author: Alejandro Ulate (codingalecr) homepage: https://github.com/CodingAleCR/http_interceptor environment: diff --git a/test/utlis_test.dart b/test/utlis_test.dart deleted file mode 100644 index 4d7032c..0000000 --- a/test/utlis_test.dart +++ /dev/null @@ -1,33 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; -import 'package:http_interceptor/utils.dart'; - -main() { - group("addParametersToUrl", () { - test("Adds parameters to a URL string without parameters", () { - // Arrange - String url = "https://www.google.com/helloworld"; - Map parameters = {"foo": "bar", "num": "0"}; - - // Act - String parameterUrl = addParametersToUrl(url, parameters); - - // Assert - expect(parameterUrl, - equals("https://www.google.com/helloworld?foo=bar&num=0")); - }); - test("Adds parameters to a URL string with parameters", () { - // Arrange - String url = "https://www.google.com/helloworld?foo=bar&num=0"; - Map parameters = {"extra": "1", "extra2": "anotherone"}; - - // Act - String parameterUrl = addParametersToUrl(url, parameters); - - // Assert - expect( - parameterUrl, - equals( - "https://www.google.com/helloworld?foo=bar&num=0&extra=1&extra2=anotherone")); - }); - }); -} From de3aed0bd88919b0063a086ead11adcddf921c42 Mon Sep 17 00:00:00 2001 From: Alejandro Ulate Date: Tue, 28 Jan 2020 19:01:17 -0600 Subject: [PATCH 12/14] Changelog: - Renamed utlis_test to utils_test. - Removed author section no longer needed. --- test/utils_test.dart | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/utils_test.dart diff --git a/test/utils_test.dart b/test/utils_test.dart new file mode 100644 index 0000000..4d7032c --- /dev/null +++ b/test/utils_test.dart @@ -0,0 +1,33 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:http_interceptor/utils.dart'; + +main() { + group("addParametersToUrl", () { + test("Adds parameters to a URL string without parameters", () { + // Arrange + String url = "https://www.google.com/helloworld"; + Map parameters = {"foo": "bar", "num": "0"}; + + // Act + String parameterUrl = addParametersToUrl(url, parameters); + + // Assert + expect(parameterUrl, + equals("https://www.google.com/helloworld?foo=bar&num=0")); + }); + test("Adds parameters to a URL string with parameters", () { + // Arrange + String url = "https://www.google.com/helloworld?foo=bar&num=0"; + Map parameters = {"extra": "1", "extra2": "anotherone"}; + + // Act + String parameterUrl = addParametersToUrl(url, parameters); + + // Assert + expect( + parameterUrl, + equals( + "https://www.google.com/helloworld?foo=bar&num=0&extra=1&extra2=anotherone")); + }); + }); +} From f250712b87ea50e56c3cf96bf8b4484cd945f0d1 Mon Sep 17 00:00:00 2001 From: Alejandro Ulate Date: Tue, 28 Jan 2020 19:12:20 -0600 Subject: [PATCH 13/14] Changelog: - Updated the changelog to include proper version and notes. --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 926e7dd..dc6182f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,12 @@ # Changelog -## 0.1.2 +## 0.2.0 * Added: Unit testing for a few of the files. * Modified: Android and iOS projects both in the plugin and the example now use Kotlin/Swift. * Modified: Android projects both in the plugin and the example now use AndroidX namespaces. * Fixed: Last '&' character was not removed from parametized URLs. +* Fixed: Duplicate GET parameters when using `get`. ## 0.1.1 From bc6ff58fd62f9a284cd989e3caa8f1601af4a9c6 Mon Sep 17 00:00:00 2001 From: Alejandro Ulate Date: Tue, 28 Jan 2020 19:23:46 -0600 Subject: [PATCH 14/14] Version bump --- example/pubspec.lock | 2 +- pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 7eaf55f..de9a6e6 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -87,7 +87,7 @@ packages: path: ".." relative: true source: path - version: "0.1.1" + version: "0.2.0" http_parser: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index a539e80..6524b5c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: http_interceptor description: A lightweight, simple plugin that allows you to intercept request and response objects and modify them if desired. -version: 0.1.1 +version: 0.2.0 homepage: https://github.com/CodingAleCR/http_interceptor environment: