-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a flutter example application that uses multiple client implem…
…entations (#1040)
- Loading branch information
1 parent
a2f3c1d
commit b2717ba
Showing
138 changed files
with
5,061 additions
and
57 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
migrate_working_dir/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
**/doc/api/ | ||
**/ios/Flutter/.last_build_id | ||
.dart_tool/ | ||
.flutter-plugins | ||
.flutter-plugins-dependencies | ||
.packages | ||
.pub-cache/ | ||
.pub/ | ||
/build/ | ||
|
||
# Symbolication related | ||
app.*.symbols | ||
|
||
# Obfuscation related | ||
app.*.map.json | ||
|
||
# Android Studio will place build artifacts here | ||
/android/app/debug | ||
/android/app/profile | ||
/android/app/release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
|
||
version: | ||
revision: "367f9ea16bfae1ca451b9cc27c1366870b187ae2" | ||
channel: "stable" | ||
|
||
project_type: app | ||
|
||
# Tracks metadata for the flutter migrate command | ||
migration: | ||
platforms: | ||
- platform: root | ||
create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 | ||
base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 | ||
- platform: android | ||
create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 | ||
base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 | ||
- platform: ios | ||
create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 | ||
base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 | ||
- platform: linux | ||
create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 | ||
base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 | ||
- platform: macos | ||
create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 | ||
base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 | ||
- platform: web | ||
create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 | ||
base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 | ||
- platform: windows | ||
create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 | ||
base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 | ||
|
||
# User provided section | ||
|
||
# List of Local paths (relative to this file) that should be | ||
# ignored by the migrate tool. | ||
# | ||
# Files that are not part of the templates will be ignored by default. | ||
unmanaged_files: | ||
- 'lib/main.dart' | ||
- 'ios/Runner.xcodeproj/project.pbxproj' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# flutter_http_example | ||
|
||
A Flutter sample app that illustrates how to configure and use | ||
[`package:http`](https://pub.dev/packages/http). | ||
|
||
## Goals for this sample | ||
|
||
* Provide you with example code for using `package:http` in Flutter, | ||
including: | ||
|
||
* configuration for multiple platforms. | ||
* using `runWithClient` and `package:provider` to pass `Client`s through | ||
an application. | ||
* writing tests using `MockClient`. | ||
|
||
## The important bits | ||
|
||
### `http_client_factory.dart` | ||
|
||
This library used to create `package:http` `Client`s when the app is run inside | ||
the Dart virtual machine, meaning all platforms except the web browser. | ||
|
||
### `http_client_factory_web.dart` | ||
|
||
This library used to create `package:http` `Client`s when the app is run inside | ||
a web browser. | ||
|
||
Web configuration must be done in a seperate library because Dart code cannot | ||
import `dart:ffi` or `dart:io` when run in a web browser. | ||
|
||
### `main.dart` | ||
|
||
This library demonstrates how to: | ||
|
||
* import `http_client_factory.dart` or `http_client_factory_web.dart`, | ||
depending on whether we are targeting the web browser or not. | ||
* share a `package:http` `Client` by using `runWithClient` and | ||
`package:provider`. | ||
* call `package:http` functions. | ||
|
||
### `widget_test.dart` | ||
|
||
This library demonstrates how to construct tests using `MockClient`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
gradle-wrapper.jar | ||
/.gradle | ||
/captures/ | ||
/gradlew | ||
/gradlew.bat | ||
/local.properties | ||
GeneratedPluginRegistrant.java | ||
|
||
# Remember to never publicly share your keystore. | ||
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app | ||
key.properties | ||
**/*.keystore | ||
**/*.jks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
plugins { | ||
id "com.android.application" | ||
id "kotlin-android" | ||
id "dev.flutter.flutter-gradle-plugin" | ||
} | ||
|
||
def localProperties = new Properties() | ||
def localPropertiesFile = rootProject.file('local.properties') | ||
if (localPropertiesFile.exists()) { | ||
localPropertiesFile.withReader('UTF-8') { reader -> | ||
localProperties.load(reader) | ||
} | ||
} | ||
|
||
def flutterVersionCode = localProperties.getProperty('flutter.versionCode') | ||
if (flutterVersionCode == null) { | ||
flutterVersionCode = '1' | ||
} | ||
|
||
def flutterVersionName = localProperties.getProperty('flutter.versionName') | ||
if (flutterVersionName == null) { | ||
flutterVersionName = '1.0' | ||
} | ||
|
||
android { | ||
namespace "com.example.flutter_http_example" | ||
compileSdkVersion flutter.compileSdkVersion | ||
ndkVersion flutter.ndkVersion | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
|
||
sourceSets { | ||
main.java.srcDirs += 'src/main/kotlin' | ||
} | ||
|
||
defaultConfig { | ||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). | ||
applicationId "com.example.flutter_http_example" | ||
// You can update the following values to match your application needs. | ||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. | ||
minSdkVersion flutter.minSdkVersion | ||
targetSdkVersion flutter.targetSdkVersion | ||
versionCode flutterVersionCode.toInteger() | ||
versionName flutterVersionName | ||
} | ||
|
||
buildTypes { | ||
release { | ||
// TODO: Add your own signing config for the release build. | ||
// Signing with the debug keys for now, so `flutter run --release` works. | ||
signingConfig signingConfigs.debug | ||
} | ||
} | ||
} | ||
|
||
flutter { | ||
source '../..' | ||
} | ||
|
||
dependencies {} |
7 changes: 7 additions & 0 deletions
7
pkgs/flutter_http_example/android/app/src/debug/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<!-- The INTERNET permission is required for development. Specifically, | ||
the Flutter tool needs it to communicate with the running application | ||
to allow setting breakpoints, to provide hot reload, etc. | ||
--> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
</manifest> |
Oops, something went wrong.