Showing
42 changed files
with
162 additions
and
819 deletions
example/android/.gitignore
deleted
100644 → 0
example/android/app/build.gradle
deleted
100644 → 0
| 1 | -def localProperties = new Properties() | ||
| 2 | -def localPropertiesFile = rootProject.file('local.properties') | ||
| 3 | -if (localPropertiesFile.exists()) { | ||
| 4 | - localPropertiesFile.withReader('UTF-8') { reader -> | ||
| 5 | - localProperties.load(reader) | ||
| 6 | - } | ||
| 7 | -} | ||
| 8 | - | ||
| 9 | -def flutterRoot = localProperties.getProperty('flutter.sdk') | ||
| 10 | -if (flutterRoot == null) { | ||
| 11 | - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") | ||
| 12 | -} | ||
| 13 | - | ||
| 14 | -def flutterVersionCode = localProperties.getProperty('flutter.versionCode') | ||
| 15 | -if (flutterVersionCode == null) { | ||
| 16 | - flutterVersionCode = '1' | ||
| 17 | -} | ||
| 18 | - | ||
| 19 | -def flutterVersionName = localProperties.getProperty('flutter.versionName') | ||
| 20 | -if (flutterVersionName == null) { | ||
| 21 | - flutterVersionName = '1.0' | ||
| 22 | -} | ||
| 23 | - | ||
| 24 | -apply plugin: 'com.android.application' | ||
| 25 | -apply plugin: 'kotlin-android' | ||
| 26 | -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" | ||
| 27 | - | ||
| 28 | -android { | ||
| 29 | - compileSdkVersion 29 | ||
| 30 | - | ||
| 31 | - sourceSets { | ||
| 32 | - main.java.srcDirs += 'src/main/kotlin' | ||
| 33 | - } | ||
| 34 | - | ||
| 35 | - lintOptions { | ||
| 36 | - disable 'InvalidPackage' | ||
| 37 | - } | ||
| 38 | - | ||
| 39 | - defaultConfig { | ||
| 40 | - // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). | ||
| 41 | - applicationId "com.example.example" | ||
| 42 | - minSdkVersion 16 | ||
| 43 | - targetSdkVersion 29 | ||
| 44 | - versionCode flutterVersionCode.toInteger() | ||
| 45 | - versionName flutterVersionName | ||
| 46 | - } | ||
| 47 | - | ||
| 48 | - buildTypes { | ||
| 49 | - release { | ||
| 50 | - // TODO: Add your own signing config for the release build. | ||
| 51 | - // Signing with the debug keys for now, so `flutter run --release` works. | ||
| 52 | - signingConfig signingConfigs.debug | ||
| 53 | - } | ||
| 54 | - } | ||
| 55 | -} | ||
| 56 | - | ||
| 57 | -flutter { | ||
| 58 | - source '../..' | ||
| 59 | -} | ||
| 60 | - | ||
| 61 | -dependencies { | ||
| 62 | - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
| 63 | -} | 
| 1 | -<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 2 | - package="com.example.example"> | ||
| 3 | - <!-- Flutter needs it to communicate with the running application | ||
| 4 | - to allow setting breakpoints, to provide hot reload, etc. | ||
| 5 | - --> | ||
| 6 | - <uses-permission android:name="android.permission.INTERNET"/> | ||
| 7 | -</manifest> | 
| 1 | -<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 2 | - package="com.example.example"> | ||
| 3 | - <application | ||
| 4 | - android:label="example" | ||
| 5 | - android:icon="@mipmap/ic_launcher"> | ||
| 6 | - <activity | ||
| 7 | - android:name=".MainActivity" | ||
| 8 | - android:launchMode="singleTop" | ||
| 9 | - android:theme="@style/LaunchTheme" | ||
| 10 | - android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" | ||
| 11 | - android:hardwareAccelerated="true" | ||
| 12 | - android:windowSoftInputMode="adjustResize"> | ||
| 13 | - <!-- Specifies an Android theme to apply to this Activity as soon as | ||
| 14 | - the Android process has started. This theme is visible to the user | ||
| 15 | - while the Flutter UI initializes. After that, this theme continues | ||
| 16 | - to determine the Window background behind the Flutter UI. --> | ||
| 17 | - <meta-data | ||
| 18 | - android:name="io.flutter.embedding.android.NormalTheme" | ||
| 19 | - android:resource="@style/NormalTheme" | ||
| 20 | - /> | ||
| 21 | - <!-- Displays an Android View that continues showing the launch screen | ||
| 22 | - Drawable until Flutter paints its first frame, then this splash | ||
| 23 | - screen fades out. A splash screen is useful to avoid any visual | ||
| 24 | - gap between the end of Android's launch screen and the painting of | ||
| 25 | - Flutter's first frame. --> | ||
| 26 | - <meta-data | ||
| 27 | - android:name="io.flutter.embedding.android.SplashScreenDrawable" | ||
| 28 | - android:resource="@drawable/launch_background" | ||
| 29 | - /> | ||
| 30 | - <intent-filter> | ||
| 31 | - <action android:name="android.intent.action.MAIN"/> | ||
| 32 | - <category android:name="android.intent.category.LAUNCHER"/> | ||
| 33 | - </intent-filter> | ||
| 34 | - </activity> | ||
| 35 | - <!-- Don't delete the meta-data below. | ||
| 36 | - This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --> | ||
| 37 | - <meta-data | ||
| 38 | - android:name="flutterEmbedding" | ||
| 39 | - android:value="2" /> | ||
| 40 | - </application> | ||
| 41 | -</manifest> | 
| 1 | -<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | -<!-- Modify this file to customize your launch splash screen --> | ||
| 3 | -<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 4 | - <item android:drawable="?android:colorBackground" /> | ||
| 5 | - | ||
| 6 | - <!-- You can insert your own image assets here --> | ||
| 7 | - <!-- <item> | ||
| 8 | - <bitmap | ||
| 9 | - android:gravity="center" | ||
| 10 | - android:src="@mipmap/launch_image" /> | ||
| 11 | - </item> --> | ||
| 12 | -</layer-list> | 
| 1 | -<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | -<!-- Modify this file to customize your launch splash screen --> | ||
| 3 | -<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 4 | - <item android:drawable="@android:color/white" /> | ||
| 5 | - | ||
| 6 | - <!-- You can insert your own image assets here --> | ||
| 7 | - <!-- <item> | ||
| 8 | - <bitmap | ||
| 9 | - android:gravity="center" | ||
| 10 | - android:src="@mipmap/launch_image" /> | ||
| 11 | - </item> --> | ||
| 12 | -</layer-list> | 
 
544 Bytes
 
442 Bytes
 
721 Bytes
 
1.01 KB
 
1.41 KB
| 1 | -<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | -<resources> | ||
| 3 | - <!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on --> | ||
| 4 | - <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar"> | ||
| 5 | - <!-- Show a splash screen on the activity. Automatically removed when | ||
| 6 | - Flutter draws its first frame --> | ||
| 7 | - <item name="android:windowBackground">@drawable/launch_background</item> | ||
| 8 | - </style> | ||
| 9 | - <!-- Theme applied to the Android Window as soon as the process has started. | ||
| 10 | - This theme determines the color of the Android Window while your | ||
| 11 | - Flutter UI initializes, as well as behind your Flutter UI while its | ||
| 12 | - running. | ||
| 13 | - | ||
| 14 | - This Theme is only used starting with V2 of Flutter's Android embedding. --> | ||
| 15 | - <style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar"> | ||
| 16 | - <item name="android:windowBackground">?android:colorBackground</item> | ||
| 17 | - </style> | ||
| 18 | -</resources> | 
| 1 | -<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | -<resources> | ||
| 3 | - <!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off --> | ||
| 4 | - <style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar"> | ||
| 5 | - <!-- Show a splash screen on the activity. Automatically removed when | ||
| 6 | - Flutter draws its first frame --> | ||
| 7 | - <item name="android:windowBackground">@drawable/launch_background</item> | ||
| 8 | - </style> | ||
| 9 | - <!-- Theme applied to the Android Window as soon as the process has started. | ||
| 10 | - This theme determines the color of the Android Window while your | ||
| 11 | - Flutter UI initializes, as well as behind your Flutter UI while its | ||
| 12 | - running. | ||
| 13 | - | ||
| 14 | - This Theme is only used starting with V2 of Flutter's Android embedding. --> | ||
| 15 | - <style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar"> | ||
| 16 | - <item name="android:windowBackground">?android:colorBackground</item> | ||
| 17 | - </style> | ||
| 18 | -</resources> | 
| 1 | -<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 2 | - package="com.example.example"> | ||
| 3 | - <!-- Flutter needs it to communicate with the running application | ||
| 4 | - to allow setting breakpoints, to provide hot reload, etc. | ||
| 5 | - --> | ||
| 6 | - <uses-permission android:name="android.permission.INTERNET"/> | ||
| 7 | -</manifest> | 
example/android/build.gradle
deleted
100644 → 0
| 1 | -buildscript { | ||
| 2 | - ext.kotlin_version = '1.3.50' | ||
| 3 | - repositories { | ||
| 4 | - google() | ||
| 5 | - jcenter() | ||
| 6 | - } | ||
| 7 | - | ||
| 8 | - dependencies { | ||
| 9 | - classpath 'com.android.tools.build:gradle:3.5.0' | ||
| 10 | - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||
| 11 | - } | ||
| 12 | -} | ||
| 13 | - | ||
| 14 | -allprojects { | ||
| 15 | - repositories { | ||
| 16 | - google() | ||
| 17 | - jcenter() | ||
| 18 | - } | ||
| 19 | -} | ||
| 20 | - | ||
| 21 | -rootProject.buildDir = '../build' | ||
| 22 | -subprojects { | ||
| 23 | - project.buildDir = "${rootProject.buildDir}/${project.name}" | ||
| 24 | -} | ||
| 25 | -subprojects { | ||
| 26 | - project.evaluationDependsOn(':app') | ||
| 27 | -} | ||
| 28 | - | ||
| 29 | -task clean(type: Delete) { | ||
| 30 | - delete rootProject.buildDir | ||
| 31 | -} | 
example/android/gradle.properties
deleted
100644 → 0
example/android/settings.gradle
deleted
100644 → 0
| 1 | -include ':app' | ||
| 2 | - | ||
| 3 | -def localPropertiesFile = new File(rootProject.projectDir, "local.properties") | ||
| 4 | -def properties = new Properties() | ||
| 5 | - | ||
| 6 | -assert localPropertiesFile.exists() | ||
| 7 | -localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } | ||
| 8 | - | ||
| 9 | -def flutterSdkPath = properties.getProperty("flutter.sdk") | ||
| 10 | -assert flutterSdkPath != null, "flutter.sdk not set in local.properties" | ||
| 11 | -apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" | 
example/linux/.gitignore
deleted
100644 → 0
| 1 | -flutter/ephemeral | 
example/linux/CMakeLists.txt
deleted
100644 → 0
| 1 | -cmake_minimum_required(VERSION 3.10) | ||
| 2 | -project(runner LANGUAGES CXX) | ||
| 3 | - | ||
| 4 | -set(BINARY_NAME "example") | ||
| 5 | -set(APPLICATION_ID "com.example.example") | ||
| 6 | - | ||
| 7 | -cmake_policy(SET CMP0063 NEW) | ||
| 8 | - | ||
| 9 | -set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") | ||
| 10 | - | ||
| 11 | -# Configure build options. | ||
| 12 | -if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) | ||
| 13 | - set(CMAKE_BUILD_TYPE "Debug" CACHE | ||
| 14 | - STRING "Flutter build mode" FORCE) | ||
| 15 | - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS | ||
| 16 | - "Debug" "Profile" "Release") | ||
| 17 | -endif() | ||
| 18 | - | ||
| 19 | -# Compilation settings that should be applied to most targets. | ||
| 20 | -function(APPLY_STANDARD_SETTINGS TARGET) | ||
| 21 | - target_compile_features(${TARGET} PUBLIC cxx_std_14) | ||
| 22 | - target_compile_options(${TARGET} PRIVATE -Wall -Werror) | ||
| 23 | - target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>") | ||
| 24 | - target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>") | ||
| 25 | -endfunction() | ||
| 26 | - | ||
| 27 | -set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") | ||
| 28 | - | ||
| 29 | -# Flutter library and tool build rules. | ||
| 30 | -add_subdirectory(${FLUTTER_MANAGED_DIR}) | ||
| 31 | - | ||
| 32 | -# System-level dependencies. | ||
| 33 | -find_package(PkgConfig REQUIRED) | ||
| 34 | -pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) | ||
| 35 | - | ||
| 36 | -add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") | ||
| 37 | - | ||
| 38 | -# Application build | ||
| 39 | -add_executable(${BINARY_NAME} | ||
| 40 | - "main.cc" | ||
| 41 | - "my_application.cc" | ||
| 42 | - "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" | ||
| 43 | -) | ||
| 44 | -apply_standard_settings(${BINARY_NAME}) | ||
| 45 | -target_link_libraries(${BINARY_NAME} PRIVATE flutter) | ||
| 46 | -target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) | ||
| 47 | -add_dependencies(${BINARY_NAME} flutter_assemble) | ||
| 48 | -# Only the install-generated bundle's copy of the executable will launch | ||
| 49 | -# correctly, since the resources must in the right relative locations. To avoid | ||
| 50 | -# people trying to run the unbundled copy, put it in a subdirectory instead of | ||
| 51 | -# the default top-level location. | ||
| 52 | -set_target_properties(${BINARY_NAME} | ||
| 53 | - PROPERTIES | ||
| 54 | - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" | ||
| 55 | -) | ||
| 56 | - | ||
| 57 | -# Generated plugin build rules, which manage building the plugins and adding | ||
| 58 | -# them to the application. | ||
| 59 | -include(flutter/generated_plugins.cmake) | ||
| 60 | - | ||
| 61 | - | ||
| 62 | -# === Installation === | ||
| 63 | -# By default, "installing" just makes a relocatable bundle in the build | ||
| 64 | -# directory. | ||
| 65 | -set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") | ||
| 66 | -if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) | ||
| 67 | - set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) | ||
| 68 | -endif() | ||
| 69 | - | ||
| 70 | -# Start with a clean build bundle directory every time. | ||
| 71 | -install(CODE " | ||
| 72 | - file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") | ||
| 73 | - " COMPONENT Runtime) | ||
| 74 | - | ||
| 75 | -set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") | ||
| 76 | -set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") | ||
| 77 | - | ||
| 78 | -install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" | ||
| 79 | - COMPONENT Runtime) | ||
| 80 | - | ||
| 81 | -install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" | ||
| 82 | - COMPONENT Runtime) | ||
| 83 | - | ||
| 84 | -install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" | ||
| 85 | - COMPONENT Runtime) | ||
| 86 | - | ||
| 87 | -if(PLUGIN_BUNDLED_LIBRARIES) | ||
| 88 | - install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" | ||
| 89 | - DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" | ||
| 90 | - COMPONENT Runtime) | ||
| 91 | -endif() | ||
| 92 | - | ||
| 93 | -# Fully re-copy the assets directory on each build to avoid having stale files | ||
| 94 | -# from a previous install. | ||
| 95 | -set(FLUTTER_ASSET_DIR_NAME "flutter_assets") | ||
| 96 | -install(CODE " | ||
| 97 | - file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") | ||
| 98 | - " COMPONENT Runtime) | ||
| 99 | -install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" | ||
| 100 | - DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) | ||
| 101 | - | ||
| 102 | -# Install the AOT library on non-Debug builds only. | ||
| 103 | -if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") | ||
| 104 | - install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" | ||
| 105 | - COMPONENT Runtime) | ||
| 106 | -endif() | 
example/linux/flutter/CMakeLists.txt
deleted
100644 → 0
| 1 | -cmake_minimum_required(VERSION 3.10) | ||
| 2 | - | ||
| 3 | -set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") | ||
| 4 | - | ||
| 5 | -# Configuration provided via flutter tool. | ||
| 6 | -include(${EPHEMERAL_DIR}/generated_config.cmake) | ||
| 7 | - | ||
| 8 | -# TODO: Move the rest of this into files in ephemeral. See | ||
| 9 | -# https://github.com/flutter/flutter/issues/57146. | ||
| 10 | - | ||
| 11 | -# Serves the same purpose as list(TRANSFORM ... PREPEND ...), | ||
| 12 | -# which isn't available in 3.10. | ||
| 13 | -function(list_prepend LIST_NAME PREFIX) | ||
| 14 | - set(NEW_LIST "") | ||
| 15 | - foreach(element ${${LIST_NAME}}) | ||
| 16 | - list(APPEND NEW_LIST "${PREFIX}${element}") | ||
| 17 | - endforeach(element) | ||
| 18 | - set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) | ||
| 19 | -endfunction() | ||
| 20 | - | ||
| 21 | -# === Flutter Library === | ||
| 22 | -# System-level dependencies. | ||
| 23 | -find_package(PkgConfig REQUIRED) | ||
| 24 | -pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) | ||
| 25 | -pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) | ||
| 26 | -pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) | ||
| 27 | -pkg_check_modules(BLKID REQUIRED IMPORTED_TARGET blkid) | ||
| 28 | - | ||
| 29 | -set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") | ||
| 30 | - | ||
| 31 | -# Published to parent scope for install step. | ||
| 32 | -set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) | ||
| 33 | -set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) | ||
| 34 | -set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) | ||
| 35 | -set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) | ||
| 36 | - | ||
| 37 | -list(APPEND FLUTTER_LIBRARY_HEADERS | ||
| 38 | - "fl_basic_message_channel.h" | ||
| 39 | - "fl_binary_codec.h" | ||
| 40 | - "fl_binary_messenger.h" | ||
| 41 | - "fl_dart_project.h" | ||
| 42 | - "fl_engine.h" | ||
| 43 | - "fl_json_message_codec.h" | ||
| 44 | - "fl_json_method_codec.h" | ||
| 45 | - "fl_message_codec.h" | ||
| 46 | - "fl_method_call.h" | ||
| 47 | - "fl_method_channel.h" | ||
| 48 | - "fl_method_codec.h" | ||
| 49 | - "fl_method_response.h" | ||
| 50 | - "fl_plugin_registrar.h" | ||
| 51 | - "fl_plugin_registry.h" | ||
| 52 | - "fl_standard_message_codec.h" | ||
| 53 | - "fl_standard_method_codec.h" | ||
| 54 | - "fl_string_codec.h" | ||
| 55 | - "fl_value.h" | ||
| 56 | - "fl_view.h" | ||
| 57 | - "flutter_linux.h" | ||
| 58 | -) | ||
| 59 | -list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") | ||
| 60 | -add_library(flutter INTERFACE) | ||
| 61 | -target_include_directories(flutter INTERFACE | ||
| 62 | - "${EPHEMERAL_DIR}" | ||
| 63 | -) | ||
| 64 | -target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") | ||
| 65 | -target_link_libraries(flutter INTERFACE | ||
| 66 | - PkgConfig::GTK | ||
| 67 | - PkgConfig::GLIB | ||
| 68 | - PkgConfig::GIO | ||
| 69 | - PkgConfig::BLKID | ||
| 70 | -) | ||
| 71 | -add_dependencies(flutter flutter_assemble) | ||
| 72 | - | ||
| 73 | -# === Flutter tool backend === | ||
| 74 | -# _phony_ is a non-existent file to force this command to run every time, | ||
| 75 | -# since currently there's no way to get a full input/output list from the | ||
| 76 | -# flutter tool. | ||
| 77 | -add_custom_command( | ||
| 78 | - OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} | ||
| 79 | - ${CMAKE_CURRENT_BINARY_DIR}/_phony_ | ||
| 80 | - COMMAND ${CMAKE_COMMAND} -E env | ||
| 81 | - ${FLUTTER_TOOL_ENVIRONMENT} | ||
| 82 | - "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" | ||
| 83 | - linux-x64 ${CMAKE_BUILD_TYPE} | ||
| 84 | -) | ||
| 85 | -add_custom_target(flutter_assemble DEPENDS | ||
| 86 | - "${FLUTTER_LIBRARY}" | ||
| 87 | - ${FLUTTER_LIBRARY_HEADERS} | ||
| 88 | -) | 
| 1 | -// | ||
| 2 | -// Generated file. Do not edit. | ||
| 3 | -// | ||
| 4 | - | ||
| 5 | -#ifndef GENERATED_PLUGIN_REGISTRANT_ | ||
| 6 | -#define GENERATED_PLUGIN_REGISTRANT_ | ||
| 7 | - | ||
| 8 | -#include <flutter_linux/flutter_linux.h> | ||
| 9 | - | ||
| 10 | -// Registers Flutter plugins. | ||
| 11 | -void fl_register_plugins(FlPluginRegistry* registry); | ||
| 12 | - | ||
| 13 | -#endif // GENERATED_PLUGIN_REGISTRANT_ | 
| 1 | -# | ||
| 2 | -# Generated file, do not edit. | ||
| 3 | -# | ||
| 4 | - | ||
| 5 | -list(APPEND FLUTTER_PLUGIN_LIST | ||
| 6 | -) | ||
| 7 | - | ||
| 8 | -set(PLUGIN_BUNDLED_LIBRARIES) | ||
| 9 | - | ||
| 10 | -foreach(plugin ${FLUTTER_PLUGIN_LIST}) | ||
| 11 | - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) | ||
| 12 | - target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) | ||
| 13 | - list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>) | ||
| 14 | - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) | ||
| 15 | -endforeach(plugin) | 
example/linux/main.cc
deleted
100644 → 0
example/linux/my_application.cc
deleted
100644 → 0
| 1 | -#include "my_application.h" | ||
| 2 | - | ||
| 3 | -#include <flutter_linux/flutter_linux.h> | ||
| 4 | -#ifdef GDK_WINDOWING_X11 | ||
| 5 | -#include <gdk/gdkx.h> | ||
| 6 | -#endif | ||
| 7 | - | ||
| 8 | -#include "flutter/generated_plugin_registrant.h" | ||
| 9 | - | ||
| 10 | -struct _MyApplication { | ||
| 11 | - GtkApplication parent_instance; | ||
| 12 | - char** dart_entrypoint_arguments; | ||
| 13 | -}; | ||
| 14 | - | ||
| 15 | -G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) | ||
| 16 | - | ||
| 17 | -// Implements GApplication::activate. | ||
| 18 | -static void my_application_activate(GApplication* application) { | ||
| 19 | - MyApplication* self = MY_APPLICATION(application); | ||
| 20 | - GtkWindow* window = | ||
| 21 | - GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); | ||
| 22 | - | ||
| 23 | - // Use a header bar when running in GNOME as this is the common style used | ||
| 24 | - // by applications and is the setup most users will be using (e.g. Ubuntu | ||
| 25 | - // desktop). | ||
| 26 | - // If running on X and not using GNOME then just use a traditional title bar | ||
| 27 | - // in case the window manager does more exotic layout, e.g. tiling. | ||
| 28 | - // If running on Wayland assume the header bar will work (may need changing | ||
| 29 | - // if future cases occur). | ||
| 30 | - gboolean use_header_bar = TRUE; | ||
| 31 | -#ifdef GDK_WINDOWING_X11 | ||
| 32 | - GdkScreen *screen = gtk_window_get_screen(window); | ||
| 33 | - if (GDK_IS_X11_SCREEN(screen)) { | ||
| 34 | - const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); | ||
| 35 | - if (g_strcmp0(wm_name, "GNOME Shell") != 0) { | ||
| 36 | - use_header_bar = FALSE; | ||
| 37 | - } | ||
| 38 | - } | ||
| 39 | -#endif | ||
| 40 | - if (use_header_bar) { | ||
| 41 | - GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); | ||
| 42 | - gtk_widget_show(GTK_WIDGET(header_bar)); | ||
| 43 | - gtk_header_bar_set_title(header_bar, "example"); | ||
| 44 | - gtk_header_bar_set_show_close_button(header_bar, TRUE); | ||
| 45 | - gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); | ||
| 46 | - } | ||
| 47 | - else { | ||
| 48 | - gtk_window_set_title(window, "example"); | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | - gtk_window_set_default_size(window, 1280, 720); | ||
| 52 | - gtk_widget_show(GTK_WIDGET(window)); | ||
| 53 | - | ||
| 54 | - g_autoptr(FlDartProject) project = fl_dart_project_new(); | ||
| 55 | - fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); | ||
| 56 | - | ||
| 57 | - FlView* view = fl_view_new(project); | ||
| 58 | - gtk_widget_show(GTK_WIDGET(view)); | ||
| 59 | - gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); | ||
| 60 | - | ||
| 61 | - fl_register_plugins(FL_PLUGIN_REGISTRY(view)); | ||
| 62 | - | ||
| 63 | - gtk_widget_grab_focus(GTK_WIDGET(view)); | ||
| 64 | -} | ||
| 65 | - | ||
| 66 | -// Implements GApplication::local_command_line. | ||
| 67 | -static gboolean my_application_local_command_line(GApplication* application, gchar ***arguments, int *exit_status) { | ||
| 68 | - MyApplication* self = MY_APPLICATION(application); | ||
| 69 | - // Strip out the first argument as it is the binary name. | ||
| 70 | - self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); | ||
| 71 | - | ||
| 72 | - g_autoptr(GError) error = nullptr; | ||
| 73 | - if (!g_application_register(application, nullptr, &error)) { | ||
| 74 | - g_warning("Failed to register: %s", error->message); | ||
| 75 | - *exit_status = 1; | ||
| 76 | - return TRUE; | ||
| 77 | - } | ||
| 78 | - | ||
| 79 | - g_application_activate(application); | ||
| 80 | - *exit_status = 0; | ||
| 81 | - | ||
| 82 | - return TRUE; | ||
| 83 | -} | ||
| 84 | - | ||
| 85 | -// Implements GObject::dispose. | ||
| 86 | -static void my_application_dispose(GObject *object) { | ||
| 87 | - MyApplication* self = MY_APPLICATION(object); | ||
| 88 | - g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); | ||
| 89 | - G_OBJECT_CLASS(my_application_parent_class)->dispose(object); | ||
| 90 | -} | ||
| 91 | - | ||
| 92 | -static void my_application_class_init(MyApplicationClass* klass) { | ||
| 93 | - G_APPLICATION_CLASS(klass)->activate = my_application_activate; | ||
| 94 | - G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; | ||
| 95 | - G_OBJECT_CLASS(klass)->dispose = my_application_dispose; | ||
| 96 | -} | ||
| 97 | - | ||
| 98 | -static void my_application_init(MyApplication* self) {} | ||
| 99 | - | ||
| 100 | -MyApplication* my_application_new() { | ||
| 101 | - return MY_APPLICATION(g_object_new(my_application_get_type(), | ||
| 102 | - "application-id", APPLICATION_ID, | ||
| 103 | - nullptr)); | ||
| 104 | -} | 
example/linux/my_application.h
deleted
100644 → 0
| 1 | -#ifndef FLUTTER_MY_APPLICATION_H_ | ||
| 2 | -#define FLUTTER_MY_APPLICATION_H_ | ||
| 3 | - | ||
| 4 | -#include <gtk/gtk.h> | ||
| 5 | - | ||
| 6 | -G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, | ||
| 7 | - GtkApplication) | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * my_application_new: | ||
| 11 | - * | ||
| 12 | - * Creates a new Flutter-based application. | ||
| 13 | - * | ||
| 14 | - * Returns: a new #MyApplication. | ||
| 15 | - */ | ||
| 16 | -MyApplication* my_application_new(); | ||
| 17 | - | ||
| 18 | -#endif // FLUTTER_MY_APPLICATION_H_ | 
example/web/favicon.png
deleted
100644 → 0
 
917 Bytes
example/web/icons/Icon-192.png
deleted
100644 → 0
 
5.17 KB
example/web/icons/Icon-512.png
deleted
100644 → 0
 
8.06 KB
example/web/index.html
deleted
100644 → 0
| 1 | -<!DOCTYPE html> | ||
| 2 | -<html> | ||
| 3 | -<head> | ||
| 4 | - <!-- | ||
| 5 | - If you are serving your web app in a path other than the root, change the | ||
| 6 | - href value below to reflect the base path you are serving from. | ||
| 7 | - | ||
| 8 | - The path provided below has to start and end with a slash "/" in order for | ||
| 9 | - it to work correctly. | ||
| 10 | - | ||
| 11 | - Fore more details: | ||
| 12 | - * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base | ||
| 13 | - --> | ||
| 14 | - <base href="/"> | ||
| 15 | - | ||
| 16 | - <meta charset="UTF-8"> | ||
| 17 | - <meta content="IE=Edge" http-equiv="X-UA-Compatible"> | ||
| 18 | - <meta name="description" content="A new Flutter project."> | ||
| 19 | - | ||
| 20 | - <!-- iOS meta tags & icons --> | ||
| 21 | - <meta name="apple-mobile-web-app-capable" content="yes"> | ||
| 22 | - <meta name="apple-mobile-web-app-status-bar-style" content="black"> | ||
| 23 | - <meta name="apple-mobile-web-app-title" content="example"> | ||
| 24 | - <link rel="apple-touch-icon" href="icons/Icon-192.png"> | ||
| 25 | - | ||
| 26 | - <!-- Favicon --> | ||
| 27 | - <link rel="icon" type="image/png" href="favicon.png"/> | ||
| 28 | - | ||
| 29 | - <title>example</title> | ||
| 30 | - <link rel="manifest" href="manifest.json"> | ||
| 31 | -</head> | ||
| 32 | -<body> | ||
| 33 | - <!-- This script installs service_worker.js to provide PWA functionality to | ||
| 34 | - application. For more information, see: | ||
| 35 | - https://developers.google.com/web/fundamentals/primers/service-workers --> | ||
| 36 | - <script> | ||
| 37 | - if ('serviceWorker' in navigator) { | ||
| 38 | - window.addEventListener('flutter-first-frame', function () { | ||
| 39 | - navigator.serviceWorker.register('flutter_service_worker.js'); | ||
| 40 | - }); | ||
| 41 | - } | ||
| 42 | - </script> | ||
| 43 | - <script src="main.dart.js" type="application/javascript"></script> | ||
| 44 | -</body> | ||
| 45 | -</html> | 
example/web/manifest.json
deleted
100644 → 0
| 1 | -{ | ||
| 2 | - "name": "example", | ||
| 3 | - "short_name": "example", | ||
| 4 | - "start_url": ".", | ||
| 5 | - "display": "standalone", | ||
| 6 | - "background_color": "#0175C2", | ||
| 7 | - "theme_color": "#0175C2", | ||
| 8 | - "description": "A new Flutter project.", | ||
| 9 | - "orientation": "portrait-primary", | ||
| 10 | - "prefer_related_applications": false, | ||
| 11 | - "icons": [ | ||
| 12 | - { | ||
| 13 | - "src": "icons/Icon-192.png", | ||
| 14 | - "sizes": "192x192", | ||
| 15 | - "type": "image/png" | ||
| 16 | - }, | ||
| 17 | - { | ||
| 18 | - "src": "icons/Icon-512.png", | ||
| 19 | - "sizes": "512x512", | ||
| 20 | - "type": "image/png" | ||
| 21 | - } | ||
| 22 | - ] | ||
| 23 | -} | 
| 1 | import 'dart:async'; | 1 | import 'dart:async'; | 
| 2 | import 'dart:convert'; | 2 | import 'dart:convert'; | 
| 3 | + | ||
| 3 | import 'package:meta/meta.dart'; | 4 | import 'package:meta/meta.dart'; | 
| 4 | 5 | ||
| 5 | import '../src/certificates/certificates.dart'; | 6 | import '../src/certificates/certificates.dart'; | 
| @@ -8,11 +9,11 @@ import '../src/http_impl/http_request_stub.dart' | @@ -8,11 +9,11 @@ import '../src/http_impl/http_request_stub.dart' | ||
| 8 | if (dart.library.html) 'http_impl/http_request_html.dart' | 9 | if (dart.library.html) 'http_impl/http_request_html.dart' | 
| 9 | if (dart.library.io) 'http_impl/http_request_io.dart'; | 10 | if (dart.library.io) 'http_impl/http_request_io.dart'; | 
| 10 | import '../src/http_impl/request_base.dart'; | 11 | import '../src/http_impl/request_base.dart'; | 
| 11 | -import '../src/interceptors/get_interceptors.dart'; | ||
| 12 | import '../src/multipart/form_data.dart'; | 12 | import '../src/multipart/form_data.dart'; | 
| 13 | import '../src/request/request.dart'; | 13 | import '../src/request/request.dart'; | 
| 14 | import '../src/response/response.dart'; | 14 | import '../src/response/response.dart'; | 
| 15 | import '../src/status/http_status.dart'; | 15 | import '../src/status/http_status.dart'; | 
| 16 | +import 'interceptors/get_modifiers.dart'; | ||
| 16 | 17 | ||
| 17 | typedef Decoder<T> = T Function(dynamic data); | 18 | typedef Decoder<T> = T Function(dynamic data); | 
| 18 | 19 | ||
| @@ -74,7 +75,7 @@ class GetHttpClient { | @@ -74,7 +75,7 @@ class GetHttpClient { | ||
| 74 | List<int> bodyBytes; | 75 | List<int> bodyBytes; | 
| 75 | 76 | ||
| 76 | if (body is FormData) { | 77 | if (body is FormData) { | 
| 77 | - bodyBytes = await body.readAsBytes(); | 78 | + bodyBytes = await body.toBytes(); | 
| 78 | } else { | 79 | } else { | 
| 79 | try { | 80 | try { | 
| 80 | var jsonString = json.encode(body); | 81 | var jsonString = json.encode(body); | 
| @@ -2,55 +2,44 @@ import 'dart:async'; | @@ -2,55 +2,44 @@ import 'dart:async'; | ||
| 2 | import 'dart:convert'; | 2 | import 'dart:convert'; | 
| 3 | import 'dart:math'; | 3 | import 'dart:math'; | 
| 4 | import '../../../../get_rx/src/rx_stream/rx_stream.dart'; | 4 | import '../../../../get_rx/src/rx_stream/rx_stream.dart'; | 
| 5 | - | 5 | +import '../request/request.dart'; | 
| 6 | import '../utils/utils.dart'; | 6 | import '../utils/utils.dart'; | 
| 7 | - | ||
| 8 | import 'multipart_file.dart'; | 7 | import 'multipart_file.dart'; | 
| 9 | 8 | ||
| 10 | class FormData { | 9 | class FormData { | 
| 11 | - static const _BOUNDARY_LENGTH = GET_BOUNDARY.length + 10; | 10 | + FormData(Map<String, dynamic> map) : boundary = _getBoundary() { | 
| 11 | + urlEncode(map, '', false, (key, value) { | ||
| 12 | + if (value == null) return; | ||
| 13 | + (value is MultipartFile) | ||
| 14 | + ? files.add(MapEntry(key, value)) | ||
| 15 | + : fields.add(MapEntry(key, value.toString())); | ||
| 16 | + return; | ||
| 17 | + }); | ||
| 18 | + } | ||
| 12 | 19 | ||
| 13 | - final String boundary; | 20 | + static const int _maxBoundaryLength = 70; | 
| 14 | 21 | ||
| 15 | - /// The boundary of FormData, it consists of a constant prefix and a random | ||
| 16 | - /// postfix to assure the the boundary unpredictable and unique, each FormData | ||
| 17 | - /// instance will be different. | 22 | + static String _getBoundary() { | 
| 23 | + final _random = Random(); | ||
| 24 | + var list = List<int>.generate(_maxBoundaryLength - GET_BOUNDARY.length, | ||
| 25 | + (_) => boundaryCharacters[_random.nextInt(boundaryCharacters.length)], | ||
| 26 | + growable: false); | ||
| 27 | + return '$GET_BOUNDARY${String.fromCharCodes(list)}'; | ||
| 28 | + } | ||
| 18 | 29 | ||
| 19 | - final _newlineRegExp = RegExp(r'\r\n|\r|\n'); | 30 | + final String boundary; | 
| 20 | 31 | ||
| 21 | /// The form fields to send for this request. | 32 | /// The form fields to send for this request. | 
| 22 | final fields = <MapEntry<String, String>>[]; | 33 | final fields = <MapEntry<String, String>>[]; | 
| 23 | 34 | ||
| 24 | - /// The [files]. | 35 | + /// The [files] to send for this request | 
| 25 | final files = <MapEntry<String, MultipartFile>>[]; | 36 | final files = <MapEntry<String, MultipartFile>>[]; | 
| 26 | 37 | ||
| 27 | - /// Whether [finalize] has been called. | ||
| 28 | - bool get isFinalized => _isFinalized; | ||
| 29 | - bool _isFinalized = false; | ||
| 30 | - | ||
| 31 | - FormData(Map<String, dynamic> map) | ||
| 32 | - : boundary = GET_BOUNDARY + | ||
| 33 | - Random().nextInt(4294967296).toString().padLeft(10, '0') { | ||
| 34 | - encodeMap( | ||
| 35 | - map, | ||
| 36 | - (key, value) { | ||
| 37 | - if (value == null) return null; | ||
| 38 | - if (value is MultipartFile) { | ||
| 39 | - files.add(MapEntry(key, value)); | ||
| 40 | - } else { | ||
| 41 | - fields.add(MapEntry(key, value.toString())); | ||
| 42 | - } | ||
| 43 | - return null; | ||
| 44 | - }, | ||
| 45 | - encode: false, | ||
| 46 | - ); | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | /// Returns the header string for a field. The return value is guaranteed to | 38 | /// Returns the header string for a field. The return value is guaranteed to | 
| 50 | /// contain only ASCII characters. | 39 | /// contain only ASCII characters. | 
| 51 | - String _headerForField(String name, String value) { | 40 | + String _fieldHeader(String name, String value) { | 
| 52 | var header = | 41 | var header = | 
| 53 | - 'content-disposition: form-data; name="${_browserEncode(name)}"'; | 42 | + 'content-disposition: form-data; name="${browserEncode(name)}"'; | 
| 54 | if (!isPlainAscii(value)) { | 43 | if (!isPlainAscii(value)) { | 
| 55 | header = '$header\r\n' | 44 | header = '$header\r\n' | 
| 56 | 'content-type: text/plain; charset=utf-8\r\n' | 45 | 'content-type: text/plain; charset=utf-8\r\n' | 
| @@ -61,71 +50,55 @@ class FormData { | @@ -61,71 +50,55 @@ class FormData { | ||
| 61 | 50 | ||
| 62 | /// Returns the header string for a file. The return value is guaranteed to | 51 | /// Returns the header string for a file. The return value is guaranteed to | 
| 63 | /// contain only ASCII characters. | 52 | /// contain only ASCII characters. | 
| 64 | - String _headerForFile(MapEntry<String, MultipartFile> entry) { | ||
| 65 | - var file = entry.value; | 53 | + String _fileHeader(MapEntry<String, MultipartFile> file) { | 
| 66 | var header = | 54 | var header = | 
| 67 | - 'content-disposition: form-data; name="${_browserEncode(entry.key)}"'; | ||
| 68 | - if (file.filename != null) { | ||
| 69 | - header = '$header; filename="${_browserEncode(file.filename)}"'; | 55 | + 'content-disposition: form-data; name="${browserEncode(file.key)}"'; | 
| 56 | + if (file.value.filename != null) { | ||
| 57 | + header = '$header; filename="${browserEncode(file.value.filename)}"'; | ||
| 70 | } | 58 | } | 
| 71 | header = '$header\r\n' | 59 | header = '$header\r\n' | 
| 72 | - 'content-type: ${file.contentType}'; | 60 | + 'content-type: ${file.value.contentType}'; | 
| 73 | return '$header\r\n\r\n'; | 61 | return '$header\r\n\r\n'; | 
| 74 | } | 62 | } | 
| 75 | 63 | ||
| 76 | - /// Encode [value] in the same way browsers do. | ||
| 77 | - String _browserEncode(String value) { | ||
| 78 | - // http://tools.ietf.org/html/rfc2388 mandates some complex encodings for | ||
| 79 | - // field names and file names, but in practice user agents seem not to | ||
| 80 | - // follow this at all. Instead, they URL-encode `\r`, `\n`, and `\r\n` as | ||
| 81 | - // `\r\n`; URL-encode `"`; and do nothing else (even for `%` or non-ASCII | ||
| 82 | - // characters). We follow their behavior. | ||
| 83 | - return value.replaceAll(_newlineRegExp, '%0D%0A').replaceAll('"', '%22'); | ||
| 84 | - } | ||
| 85 | - | ||
| 86 | - /// The total length of the request body, in bytes. This is calculated from | ||
| 87 | - /// [fields] and [files] and cannot be set manually. | 64 | + /// The length of the request body from this [FormData] | 
| 88 | int get length { | 65 | int get length { | 
| 89 | var length = 0; | 66 | var length = 0; | 
| 90 | 67 | ||
| 91 | for (final item in fields) { | 68 | for (final item in fields) { | 
| 92 | length += '--'.length + | 69 | length += '--'.length + | 
| 93 | - _BOUNDARY_LENGTH + | 70 | + _maxBoundaryLength + | 
| 94 | '\r\n'.length + | 71 | '\r\n'.length + | 
| 95 | - utf8.encode(_headerForField(item.key, item.value)).length + | 72 | + utf8.encode(_fieldHeader(item.key, item.value)).length + | 
| 96 | utf8.encode(item.value).length + | 73 | utf8.encode(item.value).length + | 
| 97 | '\r\n'.length; | 74 | '\r\n'.length; | 
| 98 | } | 75 | } | 
| 99 | 76 | ||
| 100 | for (var file in files) { | 77 | for (var file in files) { | 
| 101 | length += '--'.length + | 78 | length += '--'.length + | 
| 102 | - _BOUNDARY_LENGTH + | 79 | + _maxBoundaryLength + | 
| 103 | '\r\n'.length + | 80 | '\r\n'.length + | 
| 104 | - utf8.encode(_headerForFile(file)).length + | 81 | + utf8.encode(_fileHeader(file)).length + | 
| 105 | file.value.length + | 82 | file.value.length + | 
| 106 | '\r\n'.length; | 83 | '\r\n'.length; | 
| 107 | } | 84 | } | 
| 108 | 85 | ||
| 109 | - return length + '--'.length + _BOUNDARY_LENGTH + '--\r\n'.length; | 86 | + return length + '--'.length + _maxBoundaryLength + '--\r\n'.length; | 
| 110 | } | 87 | } | 
| 111 | 88 | ||
| 112 | - Stream<List<int>> finalize() { | ||
| 113 | - if (isFinalized) { | ||
| 114 | - throw StateError("Can't finalize a finalized MultipartFile."); | ||
| 115 | - } | ||
| 116 | - _isFinalized = true; | 89 | + Future<List<int>> toBytes() { | 
| 117 | final getStream = GetStream<List<int>>(); | 90 | final getStream = GetStream<List<int>>(); | 
| 118 | 91 | ||
| 119 | for (final item in fields) { | 92 | for (final item in fields) { | 
| 120 | stringToBytes('--$boundary\r\n', getStream); | 93 | stringToBytes('--$boundary\r\n', getStream); | 
| 121 | - stringToBytes(_headerForField(item.key, item.value), getStream); | 94 | + stringToBytes(_fieldHeader(item.key, item.value), getStream); | 
| 122 | stringToBytes(item.value, getStream); | 95 | stringToBytes(item.value, getStream); | 
| 123 | writeLine(getStream); | 96 | writeLine(getStream); | 
| 124 | } | 97 | } | 
| 125 | 98 | ||
| 126 | Future.forEach<MapEntry<String, MultipartFile>>(files, (file) { | 99 | Future.forEach<MapEntry<String, MultipartFile>>(files, (file) { | 
| 127 | stringToBytes('--$boundary\r\n', getStream); | 100 | stringToBytes('--$boundary\r\n', getStream); | 
| 128 | - stringToBytes(_headerForFile(file), getStream); | 101 | + stringToBytes(_fileHeader(file), getStream); | 
| 129 | 102 | ||
| 130 | return streamToFuture(file.value.stream, getStream) | 103 | return streamToFuture(file.value.stream, getStream) | 
| 131 | .then((_) => writeLine(getStream)); | 104 | .then((_) => writeLine(getStream)); | 
| @@ -133,11 +106,6 @@ class FormData { | @@ -133,11 +106,6 @@ class FormData { | ||
| 133 | stringToBytes('--$boundary--\r\n', getStream); | 106 | stringToBytes('--$boundary--\r\n', getStream); | 
| 134 | getStream.close(); | 107 | getStream.close(); | 
| 135 | }); | 108 | }); | 
| 136 | - return getStream.stream; | ||
| 137 | - } | ||
| 138 | - | ||
| 139 | - ///Transform the entire FormData contents as a list of bytes asynchronously. | ||
| 140 | - Future<List<int>> readAsBytes() { | ||
| 141 | - return Future(() => finalize().reduce((a, b) => [...a, ...b])); | 109 | + return BodyBytes(getStream.stream).toBytes(); | 
| 142 | } | 110 | } | 
| 143 | } | 111 | } | 
| 1 | -class MultipartFile { | ||
| 2 | - final String contentType; | ||
| 3 | - | ||
| 4 | - final Stream<List<int>> _stream; | ||
| 5 | - | ||
| 6 | - final int length; | ||
| 7 | - | ||
| 8 | - final String filename; | 1 | +import '../request/request.dart'; | 
| 9 | 2 | ||
| 3 | +class MultipartFile { | ||
| 10 | MultipartFile( | 4 | MultipartFile( | 
| 11 | List<int> bytes, { | 5 | List<int> bytes, { | 
| 12 | this.filename, | 6 | this.filename, | 
| 13 | this.contentType = 'application/octet-stream', | 7 | this.contentType = 'application/octet-stream', | 
| 14 | }) : length = bytes.length, | 8 | }) : length = bytes.length, | 
| 15 | - _stream = Stream.fromIterable([bytes]); | 9 | + stream = BodyBytes.fromBytes(bytes); | 
| 10 | + | ||
| 11 | + final String contentType; | ||
| 12 | + | ||
| 13 | + /// This stream will emit the file content of File. | ||
| 14 | + final BodyBytes stream; | ||
| 16 | 15 | ||
| 17 | - Stream<List<int>> get stream => _stream; | 16 | + final int length; | 
| 17 | + | ||
| 18 | + final String filename; | ||
| 18 | } | 19 | } | 
| @@ -75,18 +75,6 @@ class Request<T> { | @@ -75,18 +75,6 @@ class Request<T> { | ||
| 75 | decoder: decoder, | 75 | decoder: decoder, | 
| 76 | ); | 76 | ); | 
| 77 | } | 77 | } | 
| 78 | - | ||
| 79 | - /// Constructs a [Request] containing the same properties as [request]. | ||
| 80 | - factory Request.copyWith(Request request) => Request( | ||
| 81 | - method: request.method, | ||
| 82 | - url: request.url, | ||
| 83 | - headers: request.headers, | ||
| 84 | - bodyBytes: request.bodyBytes, | ||
| 85 | - followRedirects: request.followRedirects, | ||
| 86 | - maxRedirects: request.maxRedirects, | ||
| 87 | - files: request.files, | ||
| 88 | - persistentConnection: request.persistentConnection, | ||
| 89 | - ); | ||
| 90 | } | 78 | } | 
| 91 | 79 | ||
| 92 | class BodyBytes extends StreamView<List<int>> { | 80 | class BodyBytes extends StreamView<List<int>> { | 
| @@ -111,7 +99,4 @@ class BodyBytes extends StreamView<List<int>> { | @@ -111,7 +99,4 @@ class BodyBytes extends StreamView<List<int>> { | ||
| 111 | 99 | ||
| 112 | Future<String> bytesToString([Encoding encoding = utf8]) => | 100 | Future<String> bytesToString([Encoding encoding = utf8]) => | 
| 113 | encoding.decodeStream(this); | 101 | encoding.decodeStream(this); | 
| 114 | - | ||
| 115 | - Stream<String> toStringStream([Encoding encoding = utf8]) => | ||
| 116 | - encoding.decoder.bind(this); | ||
| 117 | } | 102 | } | 
| @@ -119,14 +119,14 @@ class HeaderValue { | @@ -119,14 +119,14 @@ class HeaderValue { | ||
| 119 | 119 | ||
| 120 | @override | 120 | @override | 
| 121 | String toString() { | 121 | String toString() { | 
| 122 | - var sb = StringBuffer(); | ||
| 123 | - sb.write(_value); | 122 | + var stringBuffer = StringBuffer(); | 
| 123 | + stringBuffer.write(_value); | ||
| 124 | if (parameters != null && parameters.isNotEmpty) { | 124 | if (parameters != null && parameters.isNotEmpty) { | 
| 125 | _parameters.forEach((name, value) { | 125 | _parameters.forEach((name, value) { | 
| 126 | - sb..write('; ')..write(name)..write('=')..write(value); | 126 | + stringBuffer..write('; ')..write(name)..write('=')..write(value); | 
| 127 | }); | 127 | }); | 
| 128 | } | 128 | } | 
| 129 | - return sb.toString(); | 129 | + return stringBuffer.toString(); | 
| 130 | } | 130 | } | 
| 131 | 131 | ||
| 132 | void _parse(String value, String parameterSeparator, String valueSeparator, | 132 | void _parse(String value, String parameterSeparator, String valueSeparator, | 
| @@ -135,7 +135,7 @@ class HeaderValue { | @@ -135,7 +135,7 @@ class HeaderValue { | ||
| 135 | 135 | ||
| 136 | bool done() => index == value.length; | 136 | bool done() => index == value.length; | 
| 137 | 137 | ||
| 138 | - void skipWS() { | 138 | + void bump() { | 
| 139 | while (!done()) { | 139 | while (!done()) { | 
| 140 | if (value[index] != ' ' && value[index] != '\t') return; | 140 | if (value[index] != ' ' && value[index] != '\t') return; | 
| 141 | index++; | 141 | index++; | 
| @@ -188,7 +188,7 @@ class HeaderValue { | @@ -188,7 +188,7 @@ class HeaderValue { | ||
| 188 | 188 | ||
| 189 | String parseParameterValue() { | 189 | String parseParameterValue() { | 
| 190 | if (!done() && value[index] == '\"') { | 190 | if (!done() && value[index] == '\"') { | 
| 191 | - var sb = StringBuffer(); | 191 | + var stringBuffer = StringBuffer(); | 
| 192 | index++; | 192 | index++; | 
| 193 | while (!done()) { | 193 | while (!done()) { | 
| 194 | if (value[index] == '\\') { | 194 | if (value[index] == '\\') { | 
| @@ -196,17 +196,17 @@ class HeaderValue { | @@ -196,17 +196,17 @@ class HeaderValue { | ||
| 196 | throw StateError('Failed to parse header value'); | 196 | throw StateError('Failed to parse header value'); | 
| 197 | } | 197 | } | 
| 198 | if (preserveBackslash && value[index + 1] != '\"') { | 198 | if (preserveBackslash && value[index + 1] != '\"') { | 
| 199 | - sb.write(value[index]); | 199 | + stringBuffer.write(value[index]); | 
| 200 | } | 200 | } | 
| 201 | index++; | 201 | index++; | 
| 202 | } else if (value[index] == '\"') { | 202 | } else if (value[index] == '\"') { | 
| 203 | index++; | 203 | index++; | 
| 204 | break; | 204 | break; | 
| 205 | } | 205 | } | 
| 206 | - sb.write(value[index]); | 206 | + stringBuffer.write(value[index]); | 
| 207 | index++; | 207 | index++; | 
| 208 | } | 208 | } | 
| 209 | - return sb.toString(); | 209 | + return stringBuffer.toString(); | 
| 210 | } else { | 210 | } else { | 
| 211 | var val = parseValue(); | 211 | var val = parseValue(); | 
| 212 | return val == '' ? null : val; | 212 | return val == '' ? null : val; | 
| @@ -214,16 +214,16 @@ class HeaderValue { | @@ -214,16 +214,16 @@ class HeaderValue { | ||
| 214 | } | 214 | } | 
| 215 | 215 | ||
| 216 | while (!done()) { | 216 | while (!done()) { | 
| 217 | - skipWS(); | 217 | + bump(); | 
| 218 | if (done()) return; | 218 | if (done()) return; | 
| 219 | var name = parseParameterName(); | 219 | var name = parseParameterName(); | 
| 220 | - skipWS(); | 220 | + bump(); | 
| 221 | if (done()) { | 221 | if (done()) { | 
| 222 | parameters[name] = null; | 222 | parameters[name] = null; | 
| 223 | return; | 223 | return; | 
| 224 | } | 224 | } | 
| 225 | maybeExpect('='); | 225 | maybeExpect('='); | 
| 226 | - skipWS(); | 226 | + bump(); | 
| 227 | if (done()) { | 227 | if (done()) { | 
| 228 | parameters[name] = null; | 228 | parameters[name] = null; | 
| 229 | return; | 229 | return; | 
| @@ -233,16 +233,16 @@ class HeaderValue { | @@ -233,16 +233,16 @@ class HeaderValue { | ||
| 233 | value = value.toLowerCase(); | 233 | value = value.toLowerCase(); | 
| 234 | } | 234 | } | 
| 235 | parameters[name] = value; | 235 | parameters[name] = value; | 
| 236 | - skipWS(); | 236 | + bump(); | 
| 237 | if (done()) return; | 237 | if (done()) return; | 
| 238 | if (value[index] == valueSeparator) return; | 238 | if (value[index] == valueSeparator) return; | 
| 239 | expect(parameterSeparator); | 239 | expect(parameterSeparator); | 
| 240 | } | 240 | } | 
| 241 | } | 241 | } | 
| 242 | 242 | ||
| 243 | - skipWS(); | 243 | + bump(); | 
| 244 | _value = parseValue(); | 244 | _value = parseValue(); | 
| 245 | - skipWS(); | 245 | + bump(); | 
| 246 | if (done()) return; | 246 | if (done()) return; | 
| 247 | maybeExpect(parameterSeparator); | 247 | maybeExpect(parameterSeparator); | 
| 248 | parseParameters(); | 248 | parseParameters(); | 
| 1 | import 'dart:async'; | 1 | import 'dart:async'; | 
| 2 | import 'dart:convert'; | 2 | import 'dart:convert'; | 
| 3 | - | ||
| 4 | import '../../../../get_rx/src/rx_stream/rx_stream.dart'; | 3 | import '../../../../get_rx/src/rx_stream/rx_stream.dart'; | 
| 5 | - | ||
| 6 | import '../request/request.dart'; | 4 | import '../request/request.dart'; | 
| 7 | 5 | ||
| 8 | bool isTokenChar(int byte) { | 6 | bool isTokenChar(int byte) { | 
| @@ -30,8 +28,6 @@ class CharCode { | @@ -30,8 +28,6 @@ class CharCode { | ||
| 30 | 28 | ||
| 31 | const bool F = false; | 29 | const bool F = false; | 
| 32 | 30 | ||
| 33 | -const String GET_BOUNDARY = '--get-boundary-'; | ||
| 34 | - | ||
| 35 | const bool T = true; | 31 | const bool T = true; | 
| 36 | const SEPARATOR_MAP = [ | 32 | const SEPARATOR_MAP = [ | 
| 37 | F, F, F, F, F, F, F, F, F, T, F, F, F, F, F, F, F, F, F, F, F, F, F, F, // | 33 | F, F, F, F, F, F, F, F, F, T, F, F, F, F, F, F, F, F, F, F, F, F, F, F, // | 
| @@ -64,22 +60,19 @@ BodyBytes toBodyBytes(Stream<List<int>> stream) { | @@ -64,22 +60,19 @@ BodyBytes toBodyBytes(Stream<List<int>> stream) { | ||
| 64 | 60 | ||
| 65 | final _asciiOnly = RegExp(r'^[\x00-\x7F]+$'); | 61 | final _asciiOnly = RegExp(r'^[\x00-\x7F]+$'); | 
| 66 | 62 | ||
| 63 | +final newlineRegExp = RegExp(r'\r\n|\r|\n'); | ||
| 64 | + | ||
| 67 | /// Returns whether [string] is composed entirely of ASCII-compatible | 65 | /// Returns whether [string] is composed entirely of ASCII-compatible | 
| 68 | /// characters. | 66 | /// characters. | 
| 69 | bool isPlainAscii(String string) => _asciiOnly.hasMatch(string); | 67 | bool isPlainAscii(String string) => _asciiOnly.hasMatch(string); | 
| 70 | 68 | ||
| 71 | -String encodeMap(dynamic data, _Handler handler, {bool encode = true}) { | ||
| 72 | - return urlEncode(data, '', encode, handler).toString(); | ||
| 73 | -} | ||
| 74 | - | ||
| 75 | StringBuffer urlEncode( | 69 | StringBuffer urlEncode( | 
| 76 | dynamic sub, | 70 | dynamic sub, | 
| 77 | String path, | 71 | String path, | 
| 78 | bool encode, | 72 | bool encode, | 
| 79 | - _Handler handler, | 73 | + String Function(String key, Object value) handler, | 
| 80 | ) { | 74 | ) { | 
| 81 | var urlData = StringBuffer(''); | 75 | var urlData = StringBuffer(''); | 
| 82 | - var first = true; | ||
| 83 | var leftBracket = '['; | 76 | var leftBracket = '['; | 
| 84 | var rightBracket = ']'; | 77 | var rightBracket = ']'; | 
| 85 | 78 | ||
| @@ -89,16 +82,7 @@ StringBuffer urlEncode( | @@ -89,16 +82,7 @@ StringBuffer urlEncode( | ||
| 89 | } | 82 | } | 
| 90 | 83 | ||
| 91 | var encodeComponent = encode ? Uri.encodeQueryComponent : (e) => e; | 84 | var encodeComponent = encode ? Uri.encodeQueryComponent : (e) => e; | 
| 92 | - if (sub is List) { | ||
| 93 | - for (var i = 0; i < sub.length; i++) { | ||
| 94 | - urlEncode( | ||
| 95 | - sub[i], | ||
| 96 | - // ignore: lines_longer_than_80_chars | ||
| 97 | - '$path$leftBracket${(sub[i] is Map || sub[i] is List) ? i : ''}$rightBracket', | ||
| 98 | - encode, | ||
| 99 | - handler); | ||
| 100 | - } | ||
| 101 | - } else if (sub is Map) { | 85 | + if (sub is Map) { | 
| 102 | sub.forEach((key, value) { | 86 | sub.forEach((key, value) { | 
| 103 | if (path == '') { | 87 | if (path == '') { | 
| 104 | urlEncode( | 88 | urlEncode( | 
| @@ -117,20 +101,14 @@ StringBuffer urlEncode( | @@ -117,20 +101,14 @@ StringBuffer urlEncode( | ||
| 117 | } | 101 | } | 
| 118 | }); | 102 | }); | 
| 119 | } else { | 103 | } else { | 
| 120 | - var str = handler(path, sub); | ||
| 121 | - var isNotEmpty = str != null && (str as String).trim().isNotEmpty; | ||
| 122 | - if (!first && isNotEmpty) { | ||
| 123 | - urlData.write('&'); | ||
| 124 | - } | ||
| 125 | - first = false; | ||
| 126 | - if (isNotEmpty) { | ||
| 127 | - urlData.write(str); | ||
| 128 | - } | 104 | + throw 'FormData need be a Map'; | 
| 129 | } | 105 | } | 
| 130 | 106 | ||
| 131 | return urlData; | 107 | return urlData; | 
| 132 | } | 108 | } | 
| 133 | 109 | ||
| 110 | +const String GET_BOUNDARY = 'getx-http-boundary-'; | ||
| 111 | + | ||
| 134 | Future streamToFuture(Stream stream, GetStream sink) { | 112 | Future streamToFuture(Stream stream, GetStream sink) { | 
| 135 | var completer = Completer(); | 113 | var completer = Completer(); | 
| 136 | stream.listen(sink.add, | 114 | stream.listen(sink.add, | 
| @@ -142,6 +120,78 @@ void stringToBytes(String string, GetStream stream) { | @@ -142,6 +120,78 @@ void stringToBytes(String string, GetStream stream) { | ||
| 142 | stream.add(utf8.encode(string)); | 120 | stream.add(utf8.encode(string)); | 
| 143 | } | 121 | } | 
| 144 | 122 | ||
| 123 | +/// Encode [value] like browsers | ||
| 124 | +String browserEncode(String value) { | ||
| 125 | + return value.replaceAll(newlineRegExp, '%0D%0A').replaceAll('"', '%22'); | ||
| 126 | +} | ||
| 127 | + | ||
| 145 | void writeLine(GetStream stream) => stream.add([13, 10]); | 128 | void writeLine(GetStream stream) => stream.add([13, 10]); | 
| 146 | 129 | ||
| 147 | -typedef _Handler = Function(String key, Object value); | 130 | +const List<int> boundaryCharacters = <int>[ | 
| 131 | + 43, | ||
| 132 | + 95, | ||
| 133 | + 45, | ||
| 134 | + 46, | ||
| 135 | + 48, | ||
| 136 | + 49, | ||
| 137 | + 50, | ||
| 138 | + 51, | ||
| 139 | + 52, | ||
| 140 | + 53, | ||
| 141 | + 54, | ||
| 142 | + 55, | ||
| 143 | + 56, | ||
| 144 | + 57, | ||
| 145 | + 65, | ||
| 146 | + 66, | ||
| 147 | + 67, | ||
| 148 | + 68, | ||
| 149 | + 69, | ||
| 150 | + 70, | ||
| 151 | + 71, | ||
| 152 | + 72, | ||
| 153 | + 73, | ||
| 154 | + 74, | ||
| 155 | + 75, | ||
| 156 | + 76, | ||
| 157 | + 77, | ||
| 158 | + 78, | ||
| 159 | + 79, | ||
| 160 | + 80, | ||
| 161 | + 81, | ||
| 162 | + 82, | ||
| 163 | + 83, | ||
| 164 | + 84, | ||
| 165 | + 85, | ||
| 166 | + 86, | ||
| 167 | + 87, | ||
| 168 | + 88, | ||
| 169 | + 89, | ||
| 170 | + 90, | ||
| 171 | + 97, | ||
| 172 | + 98, | ||
| 173 | + 99, | ||
| 174 | + 100, | ||
| 175 | + 101, | ||
| 176 | + 102, | ||
| 177 | + 103, | ||
| 178 | + 104, | ||
| 179 | + 105, | ||
| 180 | + 106, | ||
| 181 | + 107, | ||
| 182 | + 108, | ||
| 183 | + 109, | ||
| 184 | + 110, | ||
| 185 | + 111, | ||
| 186 | + 112, | ||
| 187 | + 113, | ||
| 188 | + 114, | ||
| 189 | + 115, | ||
| 190 | + 116, | ||
| 191 | + 117, | ||
| 192 | + 118, | ||
| 193 | + 119, | ||
| 194 | + 120, | ||
| 195 | + 121, | ||
| 196 | + 122 | ||
| 197 | +]; | 
| @@ -34,6 +34,7 @@ class GetPageRoute<T> extends PageRoute<T> { | @@ -34,6 +34,7 @@ class GetPageRoute<T> extends PageRoute<T> { | ||
| 34 | assert(barrierDismissible != null), | 34 | assert(barrierDismissible != null), | 
| 35 | assert(maintainState != null), | 35 | assert(maintainState != null), | 
| 36 | assert(fullscreenDialog != null), | 36 | assert(fullscreenDialog != null), | 
| 37 | + reference = "$routeName: ${page.hashCode}", | ||
| 37 | super(settings: settings, fullscreenDialog: fullscreenDialog); | 38 | super(settings: settings, fullscreenDialog: fullscreenDialog); | 
| 38 | 39 | ||
| 39 | @override | 40 | @override | 
| @@ -43,6 +44,8 @@ class GetPageRoute<T> extends PageRoute<T> { | @@ -43,6 +44,8 @@ class GetPageRoute<T> extends PageRoute<T> { | ||
| 43 | 44 | ||
| 44 | final String routeName; | 45 | final String routeName; | 
| 45 | 46 | ||
| 47 | + final String reference; | ||
| 48 | + | ||
| 46 | final CustomTransition customTransition; | 49 | final CustomTransition customTransition; | 
| 47 | 50 | ||
| 48 | final Bindings binding; | 51 | final Bindings binding; | 
| @@ -110,7 +113,7 @@ class GetPageRoute<T> extends PageRoute<T> { | @@ -110,7 +113,7 @@ class GetPageRoute<T> extends PageRoute<T> { | ||
| 110 | Animation<double> animation, | 113 | Animation<double> animation, | 
| 111 | Animation<double> secondaryAnimation, | 114 | Animation<double> secondaryAnimation, | 
| 112 | ) { | 115 | ) { | 
| 113 | - Get.reference = settings.name ?? routeName; | 116 | + // Get.reference = settings.name ?? routeName; | 
| 114 | binding?.dependencies(); | 117 | binding?.dependencies(); | 
| 115 | if (bindings != null) { | 118 | if (bindings != null) { | 
| 116 | for (final binding in bindings) { | 119 | for (final binding in bindings) { | 
| @@ -372,11 +375,15 @@ class GetPageRoute<T> extends PageRoute<T> { | @@ -372,11 +375,15 @@ class GetPageRoute<T> extends PageRoute<T> { | ||
| 372 | 375 | ||
| 373 | @override | 376 | @override | 
| 374 | void dispose() { | 377 | void dispose() { | 
| 378 | + super.dispose(); | ||
| 379 | + // if (Get.smartManagement != SmartManagement.onlyBuilder) { | ||
| 380 | + // WidgetsBinding.instance.addPostFrameCallback((_) => GetInstance() | ||
| 381 | + // .removeDependencyByRoute("${settings?.name ?? routeName}")); | ||
| 382 | + // } | ||
| 375 | if (Get.smartManagement != SmartManagement.onlyBuilder) { | 383 | if (Get.smartManagement != SmartManagement.onlyBuilder) { | 
| 376 | - WidgetsBinding.instance.addPostFrameCallback((_) => GetInstance() | ||
| 377 | - .removeDependencyByRoute("${settings?.name ?? routeName}")); | 384 | + WidgetsBinding.instance.addPostFrameCallback( | 
| 385 | + (_) => GetInstance().removeDependencyByRoute("$reference")); | ||
| 378 | } | 386 | } | 
| 379 | - super.dispose(); | ||
| 380 | } | 387 | } | 
| 381 | } | 388 | } | 
| 382 | 389 | 
- 
Please register or login to post a comment