mirror of
https://github.com/hackku21/nearby_connections.git
synced 2024-10-27 19:14:01 +00:00
Update example and plugin. (#32)
* Update example to null safety, fix int? -> int for sendFilePayload * Fixed example and plugin errors when running on sound null safety
This commit is contained in:
parent
4c22d91e06
commit
32cace5af7
58
example/.gitignore
vendored
58
example/.gitignore
vendored
@ -15,56 +15,32 @@
|
|||||||
*.iws
|
*.iws
|
||||||
.idea/
|
.idea/
|
||||||
|
|
||||||
# Visual Studio Code related
|
# The .vscode folder contains launch configuration and tasks you configure in
|
||||||
.vscode/
|
# 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
|
# Flutter/Dart/Pub related
|
||||||
**/doc/api/
|
**/doc/api/
|
||||||
|
**/ios/Flutter/.last_build_id
|
||||||
.dart_tool/
|
.dart_tool/
|
||||||
.flutter-plugins
|
.flutter-plugins
|
||||||
|
.flutter-plugins-dependencies
|
||||||
.packages
|
.packages
|
||||||
.pub-cache/
|
.pub-cache/
|
||||||
.pub/
|
.pub/
|
||||||
/build/
|
/build/
|
||||||
|
|
||||||
# Android related
|
# Web related
|
||||||
**/android/**/gradle-wrapper.jar
|
lib/generated_plugin_registrant.dart
|
||||||
**/android/.gradle
|
|
||||||
**/android/captures/
|
|
||||||
**/android/gradlew
|
|
||||||
**/android/gradlew.bat
|
|
||||||
**/android/local.properties
|
|
||||||
**/android/**/GeneratedPluginRegistrant.java
|
|
||||||
|
|
||||||
# iOS/XCode related
|
# Symbolication related
|
||||||
**/ios/**/*.mode1v3
|
app.*.symbols
|
||||||
**/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.
|
# Obfuscation related
|
||||||
!**/ios/**/default.mode1v3
|
app.*.map.json
|
||||||
!**/ios/**/default.mode2v3
|
|
||||||
!**/ios/**/default.pbxuser
|
# Android Studio will place build artifacts here
|
||||||
!**/ios/**/default.perspectivev3
|
/android/app/debug
|
||||||
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
|
/android/app/profile
|
||||||
|
/android/app/release
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
# This file should be version controlled and should not be manually edited.
|
# This file should be version controlled and should not be manually edited.
|
||||||
|
|
||||||
version:
|
version:
|
||||||
revision: 7a4c33425ddd78c54aba07d86f3f9a4a0051769b
|
revision: 60bd88df915880d23877bfc1602e8ddcf4c4dd2a
|
||||||
channel: stable
|
channel: stable
|
||||||
|
|
||||||
project_type: app
|
project_type: app
|
||||||
|
@ -2,8 +2,15 @@
|
|||||||
|
|
||||||
Demonstrates how to use the nearby_connections plugin.
|
Demonstrates how to use the nearby_connections plugin.
|
||||||
|
|
||||||
Checkout the [**Example**](https://github.com/mannprerak2/nearby_connections/tree/master/example) repository for implementation of sending bytes and files.
|
## Getting Started
|
||||||
|
|
||||||
Other examples using this is
|
This project is a starting point for a Flutter application.
|
||||||
- [Monoply Money Handler](https://github.com/mannprerak2/monopoly_money_game)
|
|
||||||
|
|
||||||
|
A few resources to get you started if this is your first Flutter project:
|
||||||
|
|
||||||
|
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
|
||||||
|
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
|
||||||
|
|
||||||
|
For help getting started with Flutter, view our
|
||||||
|
[online documentation](https://flutter.dev/docs), which offers tutorials,
|
||||||
|
samples, guidance on mobile development, and a full API reference.
|
||||||
|
11
example/android/.gitignore
vendored
Normal file
11
example/android/.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
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
|
@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>android</name>
|
|
||||||
<comment>Project android_ created by Buildship.</comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
@ -1,13 +0,0 @@
|
|||||||
arguments=
|
|
||||||
auto.sync=false
|
|
||||||
build.scans.enabled=false
|
|
||||||
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
|
|
||||||
connection.project.dir=
|
|
||||||
eclipse.preferences.version=1
|
|
||||||
gradle.user.home=
|
|
||||||
java.home=/usr/lib/jvm/java-11-openjdk-amd64
|
|
||||||
jvm.arguments=
|
|
||||||
offline.mode=false
|
|
||||||
override.workspace.settings=true
|
|
||||||
show.console.view=true
|
|
||||||
show.executions.view=true
|
|
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<classpath>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
|
||||||
<classpathentry kind="output" path="bin/default"/>
|
|
||||||
</classpath>
|
|
@ -1,23 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>app</name>
|
|
||||||
<comment>Project app created by Buildship.</comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
||||||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
@ -1,2 +0,0 @@
|
|||||||
connection.project.dir=..
|
|
||||||
eclipse.preferences.version=1
|
|
@ -25,23 +25,20 @@ apply plugin: 'com.android.application'
|
|||||||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 30
|
||||||
|
|
||||||
lintOptions {
|
|
||||||
disable 'InvalidPackage'
|
|
||||||
}
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
|
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||||
applicationId "com.pkmnapps.nearby_connections_example"
|
applicationId "com.pkmnapps.nearby_connections_example"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 28
|
targetSdkVersion 30
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
// TODO: Add your own signing config for the release build.
|
||||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||||
signingConfig signingConfigs.debug
|
signingConfig signingConfigs.debug
|
||||||
}
|
}
|
||||||
@ -51,9 +48,3 @@ android {
|
|||||||
flutter {
|
flutter {
|
||||||
source '../..'
|
source '../..'
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
|
||||||
testImplementation 'junit:junit:4.12'
|
|
||||||
androidTestImplementation 'androidx.test:runner:1.1.0'
|
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
|
|
||||||
}
|
|
||||||
|
@ -10,33 +10,42 @@
|
|||||||
|
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
|
<application
|
||||||
calls FlutterMain.startInitialization(this); in its onCreate method.
|
|
||||||
In most cases you can leave this as-is, but you if you want to provide
|
|
||||||
additional functionality it is fine to subclass or reimplement
|
|
||||||
FlutterApplication and put your custom class here. -->
|
|
||||||
<application
|
|
||||||
android:name="io.flutter.app.FlutterApplication"
|
|
||||||
android:label="nearby_connections_example"
|
android:label="nearby_connections_example"
|
||||||
android:icon="@mipmap/ic_launcher">
|
android:icon="@mipmap/ic_launcher">
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:launchMode="singleTop"
|
android:launchMode="singleTop"
|
||||||
android:theme="@style/LaunchTheme"
|
android:theme="@style/LaunchTheme"
|
||||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||||
android:hardwareAccelerated="true"
|
android:hardwareAccelerated="true"
|
||||||
android:windowSoftInputMode="adjustResize">
|
android:windowSoftInputMode="adjustResize">
|
||||||
<!-- This keeps the window background of the activity showing
|
<!-- Specifies an Android theme to apply to this Activity as soon as
|
||||||
until Flutter renders its first frame. It can be removed if
|
the Android process has started. This theme is visible to the user
|
||||||
there is no splash screen (such as the default splash screen
|
while the Flutter UI initializes. After that, this theme continues
|
||||||
defined in @style/LaunchTheme). -->
|
to determine the Window background behind the Flutter UI. -->
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
|
android:name="io.flutter.embedding.android.NormalTheme"
|
||||||
android:value="true" />
|
android:resource="@style/NormalTheme"
|
||||||
|
/>
|
||||||
|
<!-- Displays an Android View that continues showing the launch screen
|
||||||
|
Drawable until Flutter paints its first frame, then this splash
|
||||||
|
screen fades out. A splash screen is useful to avoid any visual
|
||||||
|
gap between the end of Android's launch screen and the painting of
|
||||||
|
Flutter's first frame. -->
|
||||||
|
<meta-data
|
||||||
|
android:name="io.flutter.embedding.android.SplashScreenDrawable"
|
||||||
|
android:resource="@drawable/launch_background"
|
||||||
|
/>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<!-- Don't delete the meta-data below.
|
||||||
|
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||||
|
<meta-data
|
||||||
|
android:name="flutterEmbedding"
|
||||||
|
android:value="2" />
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@ -1,16 +1,6 @@
|
|||||||
package com.pkmnapps.nearby_connections_example;
|
package com.pkmnapps.nearby_connections_example;
|
||||||
|
|
||||||
|
import io.flutter.embedding.android.FlutterActivity;
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
|
|
||||||
import io.flutter.app.FlutterActivity;
|
|
||||||
import io.flutter.plugins.GeneratedPluginRegistrant;
|
|
||||||
|
|
||||||
public class MainActivity extends FlutterActivity {
|
public class MainActivity extends FlutterActivity {
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
GeneratedPluginRegistrant.registerWith(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Modify this file to customize your launch splash screen -->
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="?android:colorBackground" />
|
||||||
|
|
||||||
|
<!-- You can insert your own image assets here -->
|
||||||
|
<!-- <item>
|
||||||
|
<bitmap
|
||||||
|
android:gravity="center"
|
||||||
|
android:src="@mipmap/launch_image" />
|
||||||
|
</item> -->
|
||||||
|
</layer-list>
|
18
example/android/app/src/main/res/values-night/styles.xml
Normal file
18
example/android/app/src/main/res/values-night/styles.xml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
|
||||||
|
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||||
|
<!-- Show a splash screen on the activity. Automatically removed when
|
||||||
|
Flutter draws its first frame -->
|
||||||
|
<item name="android:windowBackground">@drawable/launch_background</item>
|
||||||
|
</style>
|
||||||
|
<!-- Theme applied to the Android Window as soon as the process has started.
|
||||||
|
This theme determines the color of the Android Window while your
|
||||||
|
Flutter UI initializes, as well as behind your Flutter UI while its
|
||||||
|
running.
|
||||||
|
|
||||||
|
This Theme is only used starting with V2 of Flutter's Android embedding. -->
|
||||||
|
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||||
|
<item name="android:windowBackground">?android:colorBackground</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
@ -1,8 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
|
||||||
|
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
||||||
<!-- Show a splash screen on the activity. Automatically removed when
|
<!-- Show a splash screen on the activity. Automatically removed when
|
||||||
Flutter draws its first frame -->
|
Flutter draws its first frame -->
|
||||||
<item name="android:windowBackground">@drawable/launch_background</item>
|
<item name="android:windowBackground">@drawable/launch_background</item>
|
||||||
</style>
|
</style>
|
||||||
|
<!-- Theme applied to the Android Window as soon as the process has started.
|
||||||
|
This theme determines the color of the Android Window while your
|
||||||
|
Flutter UI initializes, as well as behind your Flutter UI while its
|
||||||
|
running.
|
||||||
|
|
||||||
|
This Theme is only used starting with V2 of Flutter's Android embedding. -->
|
||||||
|
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
||||||
|
<item name="android:windowBackground">?android:colorBackground</item>
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -5,17 +5,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||||
}
|
|
||||||
subprojects {
|
|
||||||
project.configurations.all {
|
|
||||||
resolutionStrategy.eachDependency { details ->
|
|
||||||
if (details.requested.group == 'androidx.core'
|
|
||||||
&& !details.requested.name.contains('androidx')) {
|
|
||||||
details.useVersion "1.0.1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
android.enableJetifier=true
|
|
||||||
android.useAndroidX=true
|
|
||||||
org.gradle.jvmargs=-Xmx1536M
|
org.gradle.jvmargs=-Xmx1536M
|
||||||
android.enableR8=true
|
android.useAndroidX=true
|
||||||
|
android.enableJetifier=true
|
||||||
|
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
include ':app'
|
include ':app'
|
||||||
|
|
||||||
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
|
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
|
||||||
|
def properties = new Properties()
|
||||||
|
|
||||||
def plugins = new Properties()
|
assert localPropertiesFile.exists()
|
||||||
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
|
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
|
||||||
if (pluginsFile.exists()) {
|
|
||||||
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins.each { name, path ->
|
def flutterSdkPath = properties.getProperty("flutter.sdk")
|
||||||
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
|
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
|
||||||
include ":$name"
|
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
|
||||||
project(":$name").projectDir = pluginDirectory
|
|
||||||
}
|
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
# Uncomment this line to define a global platform for your project
|
|
||||||
# platform :ios, '9.0'
|
|
||||||
|
|
||||||
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
|
|
||||||
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
|
|
||||||
|
|
||||||
project 'Runner', {
|
|
||||||
'Debug' => :debug,
|
|
||||||
'Profile' => :release,
|
|
||||||
'Release' => :release,
|
|
||||||
}
|
|
||||||
|
|
||||||
def flutter_root
|
|
||||||
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
|
|
||||||
unless File.exist?(generated_xcode_build_settings_path)
|
|
||||||
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
|
|
||||||
end
|
|
||||||
|
|
||||||
File.foreach(generated_xcode_build_settings_path) do |line|
|
|
||||||
matches = line.match(/FLUTTER_ROOT\=(.*)/)
|
|
||||||
return matches[1].strip if matches
|
|
||||||
end
|
|
||||||
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
|
|
||||||
end
|
|
||||||
|
|
||||||
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
|
|
||||||
|
|
||||||
flutter_ios_podfile_setup
|
|
||||||
|
|
||||||
target 'Runner' do
|
|
||||||
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
|
|
||||||
end
|
|
||||||
|
|
||||||
post_install do |installer|
|
|
||||||
installer.pods_project.targets.each do |target|
|
|
||||||
flutter_additional_ios_build_settings(target)
|
|
||||||
end
|
|
||||||
end
|
|
@ -37,7 +37,7 @@ class _MyBodyState extends State<Body> {
|
|||||||
final Strategy strategy = Strategy.P2P_STAR;
|
final Strategy strategy = Strategy.P2P_STAR;
|
||||||
Map<String, ConnectionInfo> endpointMap = Map();
|
Map<String, ConnectionInfo> endpointMap = Map();
|
||||||
|
|
||||||
File tempFile; //reference to the file currently being transferred
|
File? tempFile; //reference to the file currently being transferred
|
||||||
Map<int, String> map =
|
Map<int, String> map =
|
||||||
Map(); //store filename mapped to corresponding payloadId
|
Map(); //store filename mapped to corresponding payloadId
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ class _MyBodyState extends State<Body> {
|
|||||||
},
|
},
|
||||||
onDisconnected: (id) {
|
onDisconnected: (id) {
|
||||||
showSnackbar(
|
showSnackbar(
|
||||||
"Disconnected: ${endpointMap[id].endpointName}, id $id");
|
"Disconnected: ${endpointMap[id]!.endpointName}, id $id");
|
||||||
setState(() {
|
setState(() {
|
||||||
endpointMap.remove(id);
|
endpointMap.remove(id);
|
||||||
});
|
});
|
||||||
@ -207,7 +207,7 @@ class _MyBodyState extends State<Body> {
|
|||||||
endpointMap.remove(id);
|
endpointMap.remove(id);
|
||||||
});
|
});
|
||||||
showSnackbar(
|
showSnackbar(
|
||||||
"Disconnected from: ${endpointMap[id].endpointName}, id $id");
|
"Disconnected from: ${endpointMap[id]!.endpointName}, id $id");
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -220,7 +220,7 @@ class _MyBodyState extends State<Body> {
|
|||||||
},
|
},
|
||||||
onEndpointLost: (id) {
|
onEndpointLost: (id) {
|
||||||
showSnackbar(
|
showSnackbar(
|
||||||
"Lost discovered Endpoint: ${endpointMap[id].endpointName}, id $id");
|
"Lost discovered Endpoint: ${endpointMap[id]!.endpointName}, id $id");
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
showSnackbar("DISCOVERING: " + a.toString());
|
showSnackbar("DISCOVERING: " + a.toString());
|
||||||
@ -266,7 +266,7 @@ class _MyBodyState extends State<Body> {
|
|||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
child: Text("Send File Payload"),
|
child: Text("Send File Payload"),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
PickedFile file =
|
PickedFile? file =
|
||||||
await ImagePicker().getImage(source: ImageSource.gallery);
|
await ImagePicker().getImage(source: ImageSource.gallery);
|
||||||
|
|
||||||
if (file == null) return;
|
if (file == null) return;
|
||||||
@ -319,7 +319,7 @@ class _MyBodyState extends State<Body> {
|
|||||||
id,
|
id,
|
||||||
onPayLoadRecieved: (endid, payload) async {
|
onPayLoadRecieved: (endid, payload) async {
|
||||||
if (payload.type == PayloadType.BYTES) {
|
if (payload.type == PayloadType.BYTES) {
|
||||||
String str = String.fromCharCodes(payload.bytes);
|
String str = String.fromCharCodes(payload.bytes!);
|
||||||
showSnackbar(endid + ": " + str);
|
showSnackbar(endid + ": " + str);
|
||||||
|
|
||||||
if (str.contains(':')) {
|
if (str.contains(':')) {
|
||||||
@ -329,9 +329,9 @@ class _MyBodyState extends State<Body> {
|
|||||||
String fileName = (str.split(':')[1]);
|
String fileName = (str.split(':')[1]);
|
||||||
|
|
||||||
if (map.containsKey(payloadId)) {
|
if (map.containsKey(payloadId)) {
|
||||||
if (await tempFile.exists()) {
|
if (await tempFile!.exists()) {
|
||||||
tempFile.rename(
|
tempFile!.rename(
|
||||||
tempFile.parent.path + "/" + fileName);
|
tempFile!.parent.path + "/" + fileName);
|
||||||
} else {
|
} else {
|
||||||
showSnackbar("File doesn't exist");
|
showSnackbar("File doesn't exist");
|
||||||
}
|
}
|
||||||
@ -342,7 +342,7 @@ class _MyBodyState extends State<Body> {
|
|||||||
}
|
}
|
||||||
} else if (payload.type == PayloadType.FILE) {
|
} else if (payload.type == PayloadType.FILE) {
|
||||||
showSnackbar(endid + ": File transfer started");
|
showSnackbar(endid + ": File transfer started");
|
||||||
tempFile = File(payload.filePath);
|
tempFile = File(payload.filePath!);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onPayloadTransferUpdate: (endid, payloadTransferUpdate) {
|
onPayloadTransferUpdate: (endid, payloadTransferUpdate) {
|
||||||
@ -360,8 +360,8 @@ class _MyBodyState extends State<Body> {
|
|||||||
|
|
||||||
if (map.containsKey(payloadTransferUpdate.id)) {
|
if (map.containsKey(payloadTransferUpdate.id)) {
|
||||||
//rename the file now
|
//rename the file now
|
||||||
String name = map[payloadTransferUpdate.id];
|
String name = map[payloadTransferUpdate.id]!;
|
||||||
tempFile.rename(tempFile.parent.path + "/" + name);
|
tempFile!.rename(tempFile!.parent.path + "/" + name);
|
||||||
} else {
|
} else {
|
||||||
//bytes not received till yet
|
//bytes not received till yet
|
||||||
map[payloadTransferUpdate.id] = "";
|
map[payloadTransferUpdate.id] = "";
|
||||||
|
@ -43,13 +43,6 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.15.0"
|
version: "1.15.0"
|
||||||
cupertino_icons:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: cupertino_icons
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "0.1.3"
|
|
||||||
fake_async:
|
fake_async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -68,40 +61,59 @@ packages:
|
|||||||
name: flutter_plugin_android_lifecycle
|
name: flutter_plugin_android_lifecycle
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.11"
|
version: "2.0.1"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_web_plugins:
|
||||||
|
dependency: transitive
|
||||||
|
description: flutter
|
||||||
|
source: sdk
|
||||||
|
version: "0.0.0"
|
||||||
http:
|
http:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: http
|
name: http
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.2"
|
version: "0.13.1"
|
||||||
http_parser:
|
http_parser:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: http_parser
|
name: http_parser
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.4"
|
version: "4.0.0"
|
||||||
image_picker:
|
image_picker:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: image_picker
|
name: image_picker
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.6.7+21"
|
version: "0.7.4"
|
||||||
|
image_picker_for_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: image_picker_for_web
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.0"
|
||||||
image_picker_platform_interface:
|
image_picker_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: image_picker_platform_interface
|
name: image_picker_platform_interface
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.1"
|
version: "2.0.1"
|
||||||
|
js:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: js
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.6.3"
|
||||||
matcher:
|
matcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -117,7 +129,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.0"
|
version: "1.3.0"
|
||||||
nearby_connections:
|
nearby_connections:
|
||||||
dependency: "direct dev"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: ".."
|
path: ".."
|
||||||
relative: true
|
relative: true
|
||||||
@ -136,14 +148,14 @@ packages:
|
|||||||
name: pedantic
|
name: pedantic
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.2"
|
version: "1.11.0"
|
||||||
plugin_platform_interface:
|
plugin_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: plugin_platform_interface
|
name: plugin_platform_interface
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.3"
|
version: "2.0.0"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -1,27 +1,32 @@
|
|||||||
name: nearby_connections_example
|
name: nearby_connections_example
|
||||||
description: Demonstrates how to use the nearby_connections plugin.
|
description: Demonstrates how to use the nearby_connections plugin.
|
||||||
publish_to: 'none'
|
|
||||||
|
# The following line prevents the package from being accidentally published to
|
||||||
|
# pub.dev using `pub publish`. This is preferred for private packages.
|
||||||
|
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.1.0 <3.0.0"
|
sdk: ">=2.12.0 <3.0.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
# The following adds the Cupertino Icons font to your application.
|
image_picker: ^0.7.4
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
nearby_connections:
|
||||||
cupertino_icons: ^0.1.2
|
# When depending on this package from a real application you should use:
|
||||||
image_picker: ^0.6.1+2
|
# nearby_connections: ^x.y.z
|
||||||
|
# See https://dart.dev/tools/pub/dependencies#version-constraints
|
||||||
|
# The example app is bundled with the plugin so we use a path dependency on
|
||||||
|
# the parent directory to use the current plugin's version.
|
||||||
|
path: ../
|
||||||
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
nearby_connections:
|
|
||||||
path: ../
|
|
||||||
|
|
||||||
# For information on the generic Dart part of this file, see the
|
# For information on the generic Dart part of this file, see the
|
||||||
# following page: https://www.dartlang.org/tools/pub/pubspec
|
# following page: https://dart.dev/tools/pub/pubspec
|
||||||
|
|
||||||
# The following section is specific to Flutter.
|
# The following section is specific to Flutter.
|
||||||
flutter:
|
flutter:
|
||||||
@ -33,8 +38,8 @@ flutter:
|
|||||||
|
|
||||||
# To add assets to your application, add an assets section, like this:
|
# To add assets to your application, add an assets section, like this:
|
||||||
# assets:
|
# assets:
|
||||||
# - images/a_dot_burr.jpeg
|
# - images/a_dot_burr.jpeg
|
||||||
# - images/a_dot_ham.jpeg
|
# - images/a_dot_ham.jpeg
|
||||||
|
|
||||||
# An image asset can refer to one or more resolution-specific "variants", see
|
# An image asset can refer to one or more resolution-specific "variants", see
|
||||||
# https://flutter.dev/assets-and-images/#resolution-aware.
|
# https://flutter.dev/assets-and-images/#resolution-aware.
|
||||||
|
@ -36,8 +36,7 @@ class Nearby {
|
|||||||
endpointId,
|
endpointId,
|
||||||
ConnectionInfo(
|
ConnectionInfo(
|
||||||
endpointName, authenticationToken, isIncomingConnection));
|
endpointName, authenticationToken, isIncomingConnection));
|
||||||
|
break;
|
||||||
return null;
|
|
||||||
case "ad.onConnectionResult":
|
case "ad.onConnectionResult":
|
||||||
String endpointId = args['endpointId'] ?? '-1';
|
String endpointId = args['endpointId'] ?? '-1';
|
||||||
Status statusCode =
|
Status statusCode =
|
||||||
@ -45,13 +44,13 @@ class Nearby {
|
|||||||
|
|
||||||
_advertConnectionResult?.call(endpointId, statusCode);
|
_advertConnectionResult?.call(endpointId, statusCode);
|
||||||
|
|
||||||
return null;
|
break;
|
||||||
case "ad.onDisconnected":
|
case "ad.onDisconnected":
|
||||||
String endpointId = args['endpointId'] ?? '-1';
|
String endpointId = args['endpointId'] ?? '-1';
|
||||||
|
|
||||||
_advertDisconnected?.call(endpointId);
|
_advertDisconnected?.call(endpointId);
|
||||||
|
|
||||||
return null;
|
break;
|
||||||
|
|
||||||
case "dis.onConnectionInitiated":
|
case "dis.onConnectionInitiated":
|
||||||
String endpointId = args['endpointId'] ?? '-1';
|
String endpointId = args['endpointId'] ?? '-1';
|
||||||
@ -64,7 +63,7 @@ class Nearby {
|
|||||||
ConnectionInfo(
|
ConnectionInfo(
|
||||||
endpointName, authenticationToken, isIncomingConnection));
|
endpointName, authenticationToken, isIncomingConnection));
|
||||||
|
|
||||||
return null;
|
break;
|
||||||
case "dis.onConnectionResult":
|
case "dis.onConnectionResult":
|
||||||
String endpointId = args['endpointId'] ?? '-1';
|
String endpointId = args['endpointId'] ?? '-1';
|
||||||
Status statusCode =
|
Status statusCode =
|
||||||
@ -72,13 +71,13 @@ class Nearby {
|
|||||||
|
|
||||||
_discoverConnectionResult?.call(endpointId, statusCode);
|
_discoverConnectionResult?.call(endpointId, statusCode);
|
||||||
|
|
||||||
return null;
|
break;
|
||||||
case "dis.onDisconnected":
|
case "dis.onDisconnected":
|
||||||
String endpointId = args['endpointId'] ?? '-1';
|
String endpointId = args['endpointId'] ?? '-1';
|
||||||
|
|
||||||
_discoverDisconnected?.call(endpointId);
|
_discoverDisconnected?.call(endpointId);
|
||||||
|
|
||||||
return null;
|
break;
|
||||||
|
|
||||||
case "dis.onEndpointFound":
|
case "dis.onEndpointFound":
|
||||||
String endpointId = args['endpointId'] ?? '-1';
|
String endpointId = args['endpointId'] ?? '-1';
|
||||||
@ -86,13 +85,13 @@ class Nearby {
|
|||||||
String serviceId = args['serviceId'] ?? '-1';
|
String serviceId = args['serviceId'] ?? '-1';
|
||||||
_onEndpointFound?.call(endpointId, endpointName, serviceId);
|
_onEndpointFound?.call(endpointId, endpointName, serviceId);
|
||||||
|
|
||||||
return null;
|
break;
|
||||||
case "dis.onEndpointLost":
|
case "dis.onEndpointLost":
|
||||||
String endpointId = args['endpointId'] ?? '-1';
|
String endpointId = args['endpointId'] ?? '-1';
|
||||||
|
|
||||||
_onEndpointLost?.call(endpointId);
|
_onEndpointLost?.call(endpointId);
|
||||||
|
|
||||||
return null;
|
break;
|
||||||
case "onPayloadReceived":
|
case "onPayloadReceived":
|
||||||
String endpointId = args['endpointId'] ?? '-1';
|
String endpointId = args['endpointId'] ?? '-1';
|
||||||
int type = args['type'] ?? PayloadType.NONE;
|
int type = args['type'] ?? PayloadType.NONE;
|
||||||
@ -127,8 +126,8 @@ class Nearby {
|
|||||||
_onPayloadTransferUpdate?.call(endpointId, payloadTransferUpdate);
|
_onPayloadTransferUpdate?.call(endpointId, payloadTransferUpdate);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return null;
|
return Future.value();
|
||||||
} as Future<dynamic> Function(MethodCall)?);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//for advertisers
|
//for advertisers
|
||||||
@ -387,7 +386,7 @@ class Nearby {
|
|||||||
/// You must also send a bytes payload to send the filename and extension
|
/// You must also send a bytes payload to send the filename and extension
|
||||||
/// so that receiver can rename the file accordingly
|
/// so that receiver can rename the file accordingly
|
||||||
/// Send the payloadID and filename to receiver as bytes payload
|
/// Send the payloadID and filename to receiver as bytes payload
|
||||||
Future<int?> sendFilePayload(String endpointId, String filePath) async {
|
Future<int> sendFilePayload(String endpointId, String filePath) async {
|
||||||
return await _channel.invokeMethod(
|
return await _channel.invokeMethod(
|
||||||
'sendFilePayload',
|
'sendFilePayload',
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
|
Loading…
Reference in New Issue
Block a user