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/CHANGELOG.md b/CHANGELOG.md
index 786f911..dc6182f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,13 @@
# Changelog
+## 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
* Fixed: HTTP Methods have misaligned parameters. Now they are called via named parameters to avoid type mismatch exceptions when being used.
diff --git a/README.md b/README.md
index cd005bf..886eec5 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,11 @@
# http_interceptor
+[](https://pub.dev/packages/http_interceptor)
+[](https://github.com/tenhobi/effective_dart)
+[](https://opensource.org/licenses/MIT)
+[](https://codecov.io/gh/CodingAleCR/http_interceptor)
+[](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..c9cf67f
--- /dev/null
+++ b/analysis_options.yml
@@ -0,0 +1 @@
+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 2f9d425..0000000
--- a/android/build.gradle
+++ /dev/null
@@ -1,34 +0,0 @@
-group 'codingalecr.http_interceptor'
-version '1.0-SNAPSHOT'
-
-buildscript {
- repositories {
- google()
- jcenter()
- }
-
- dependencies {
- classpath 'com.android.tools.build:gradle:3.2.1'
- }
-}
-
-rootProject.allprojects {
- repositories {
- google()
- jcenter()
- }
-}
-
-apply plugin: 'com.android.library'
-
-android {
- compileSdkVersion 28
-
- defaultConfig {
- minSdkVersion 16
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
- }
- lintOptions {
- disable 'InvalidPackage'
- }
-}
diff --git a/android/gradle.properties b/android/gradle.properties
deleted file mode 100644
index 8bd86f6..0000000
--- a/android/gradle.properties
+++ /dev/null
@@ -1 +0,0 @@
-org.gradle.jvmargs=-Xmx1536M
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 b4465f7..0000000
--- a/android/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
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/example/.gitignore b/example/.gitignore
index 65aa46d..ae1f183 100644
--- a/example/.gitignore
+++ b/example/.gitignore
@@ -15,56 +15,23 @@
*.iws
.idea/
-# Visual Studio Code related
-.vscode/
+# The .vscode folder contains launch configuration and tasks you configure in
+# VS Code which you may wish to be included in version control, so this line
+# is commented out by default.
+#.vscode/
# Flutter/Dart/Pub related
**/doc/api/
.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/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
\ No newline at end of file
+!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
diff --git a/example/README.md b/example/README.md
index 1aea750..5f5a94d 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/
+
+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
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 ba793fd..0f6a5e5 100644
--- a/example/android/app/build.gradle
+++ b/example/android/app/build.gradle
@@ -22,23 +22,28 @@ 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()
versionName flutterVersionName
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
@@ -55,7 +60,8 @@ 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:runner:1.1.1'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
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..8bc6007 100644
--- a/example/android/app/src/main/AndroidManifest.xml
+++ b/example/android/app/src/main/AndroidManifest.xml
@@ -1,6 +1,5 @@
-
+ package="com.example.example">
-
-
+
+
diff --git a/example/android/app/src/main/java/codingalecr/http_interceptor_example/MainActivity.java b/example/android/app/src/main/java/codingalecr/http_interceptor_example/MainActivity.java
deleted file mode 100644
index 9b3b376..0000000
--- a/example/android/app/src/main/java/codingalecr/http_interceptor_example/MainActivity.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package codingalecr.http_interceptor_example;
-
-import android.os.Bundle;
-import io.flutter.app.FlutterActivity;
-import io.flutter.plugins.GeneratedPluginRegistrant;
-
-public class MainActivity extends FlutterActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- GeneratedPluginRegistrant.registerWith(this);
- }
-}
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
new file mode 100644
index 0000000..1656503
--- /dev/null
+++ b/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt
@@ -0,0 +1,12 @@
+package com.example.example
+
+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 configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
+ GeneratedPluginRegistrant.registerWith(flutterEngine);
+ }
+}
diff --git a/example/android/app/src/profile/AndroidManifest.xml b/example/android/app/src/profile/AndroidManifest.xml
index 828101f..c208884 100644
--- a/example/android/app/src/profile/AndroidManifest.xml
+++ b/example/android/app/src/profile/AndroidManifest.xml
@@ -1,5 +1,5 @@
+ package="com.example.example">
diff --git a/example/android/build.gradle b/example/android/build.gradle
index bb8a303..3100ad2 100644
--- a/example/android/build.gradle
+++ b/example/android/build.gradle
@@ -1,11 +1,13 @@
buildscript {
+ 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 8bd86f6..38c8d45 100644
--- a/example/android/gradle.properties
+++ b/example/android/gradle.properties
@@ -1 +1,4 @@
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/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/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/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
deleted file mode 100644
index c1f0bba..0000000
--- a/example/ios/Podfile
+++ /dev/null
@@ -1,71 +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'
-
-install! 'cocoapods', :disable_input_output_paths => 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
- # 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 packages 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
-
-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/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..0d45b98 100644
--- a/example/ios/Runner.xcodeproj/project.pbxproj
+++ b/example/ios/Runner.xcodeproj/project.pbxproj
@@ -11,12 +11,9 @@
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 +35,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 +59,6 @@
files = (
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
- 3BF671573F6DDF22BE1013F7 /* libPods-Runner.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -93,8 +84,6 @@
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
- C5C6273DF2640D363291C0BB /* Pods */,
- DEDC890A64E743B55DDEB300 /* Frameworks */,
);
sourceTree = "";
};
@@ -109,8 +98,6 @@
97C146F01CF9000F007C117D /* Runner */ = {
isa = PBXGroup;
children = (
- 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */,
- 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */,
97C146FA1CF9000F007C117D /* Main.storyboard */,
97C146FD1CF9000F007C117D /* Assets.xcassets */,
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
@@ -118,6 +105,8 @@
97C146F11CF9000F007C117D /* Supporting Files */,
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
+ 74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
+ 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
);
path = Runner;
sourceTree = "";
@@ -125,30 +114,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 +125,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 +147,18 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 0910;
+ LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "The Chromium Authors";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
CreatedOnToolsVersion = 7.3.1;
+ LastSwiftMigration = 1100;
};
};
};
buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
compatibilityVersion = "Xcode 3.2";
- developmentRegion = English;
+ developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
@@ -213,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 */,
);
@@ -236,25 +203,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 +217,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 +224,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 +265,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;
@@ -369,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;
};
@@ -379,8 +307,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 +320,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 = 5.0;
VERSIONING_SYSTEM = "apple-generic";
};
name = Profile;
@@ -412,12 +342,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 +398,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 +429,8 @@
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;
};
@@ -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 = 5.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 = 5.0;
VERSIONING_SYSTEM = "apple-generic";
};
name = Release;
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 3d43d11..dc9ada4 100644
Binary files a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ
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/example/lib/main.dart b/example/lib/main.dart
index 7468827..318094b 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.
@@ -138,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;
@@ -262,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..de9a6e6 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:
@@ -59,7 +87,7 @@ packages:
path: ".."
relative: true
source: path
- version: "0.1.1"
+ version: "0.2.0"
http_parser:
dependency: transitive
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 710ec6c..0000000
--- a/ios/.gitignore
+++ /dev/null
@@ -1,36 +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
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 4f47795..0000000
--- a/ios/Classes/HttpInterceptorPlugin.m
+++ /dev/null
@@ -1,20 +0,0 @@
-#import "HttpInterceptorPlugin.h"
-
-@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];
-}
-
-- (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/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 0ad89e5..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); // 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/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';
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 4a02338..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,6 +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.2.1"
flutter:
dependency: "direct main"
description: flutter
@@ -53,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:
@@ -81,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:
@@ -134,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:
@@ -149,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 4edbf82..6524b5c 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)
+version: 0.2.0
homepage: https://github.com/CodingAleCR/http_interceptor
environment:
@@ -15,10 +14,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
+ effective_dart: ^1.2.1
flutter:
- plugin:
- androidPackage: codingalecr.http_interceptor
- pluginClass: HttpInterceptorPlugin
-
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..cf72481
--- /dev/null
+++ b/test/models/request_data_test.dart
@@ -0,0 +1,89 @@
+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(
+ method: Method.GET, baseUrl: "https://www.google.com/helloworld");
+
+ // Assert
+ expect(requestData, isNotNull);
+ });
+ test("can be instantiated from HTTP GET 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"));
+ });
+ 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 be instantiated from HTTP GET Request with parameters", () {
+ // 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.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/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);
+ });
+ });
+}
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"));
+ });
+ });
+}