Flutter - Unable to send message using NearByService - flutter

I am experiencing an issue to send messages from the advertising device to the browser device(Reader) and getting an error like this-
Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: com/event. Response ID: 0
The steps followed are -
Advertiser advertises using a key.
Browser establishes a connection.
Advertiser sends a message using the following code of NearByservice package -
/// Sends a message encapsulated in a Data instance to nearby peers.
FutureOr sendMessage(String deviceID, String message) async {
await _channel.invokeMethod(_sendMessage, <String, dynamic>{
'deviceId': deviceID,
'message': message,
});
And getting the above error mentioned in the title. Assumed some environmental issues and tried to clean up project, rebuilt and faced the same issue.
JFYI -
After executing "flutter doctor -v", the following logs were received -
[✓] Flutter (Channel master, 3.1.0-0.0.pre.1487, on macOS 12.4 21F79 darwin-x64, locale en-BD)
• Flutter version 3.1.0-0.0.pre.1487 on channel master at /Users/imac/Flutter_Projects/Flutter_SDK/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 20217092c1 (4 days ago), 2022-07-02 23:49:08 -0400
• Engine revision 51dc113c3f
• Dart version 2.18.0 (build 2.18.0-249.0.dev)
• DevTools version 2.15.0
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/imac/Library/Android/sdk
• Platform android-33, build-tools 33.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 13F17a
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
[✓] Connected device (4 available)
• SM G960F (mobile) • 2295dc5c4a0d7ece • android-arm64 • Android 10 (API 29)
• SM N950F (mobile) • ce061716a909a80e0d7e • android-arm64 • Android 9 (API 28)
• macOS (desktop) • macos • darwin-x64 • macOS 12.4 21F79 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 103.0.5060.114
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Can anyone support this to accomplish please?

Related

FormatException: SyntaxError: JSON.parse: expected property name or '}' at line 1 column 2 of the JSON data on Safari and Firefox

On debug mode everything works fine but when I create a build for the web with flutter build web and deploy I get the JSON.parse: expected property name or '}' error on just Safari and Firefox but on Google Chrome everything works fine.
flutter doctor -v
[✓] Flutter (Channel stable, 3.7.3, on macOS 13.1 22C65 darwin-arm64, locale en-NG)
• Flutter version 3.7.3 on channel stable at /Users/binemmanuel/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 9944297138 (8 days ago), 2023-02-08 15:46:04 -0800
• Engine revision 248290d6d5
• Dart version 2.19.2
• DevTools version 2.20.1
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/binemmanuel/Library/Android/sdk
• Platform android-33, build-tools 33.0.0
• ANDROID_SDK_ROOT = /Users/binemmanuel/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14A400
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
[✓] VS Code (version 1.75.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.58.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.1 22C65 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 102.0.5005.61
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!

Flutter assign null as value to Map<String, dynamic> throws "Error: Expected a value of type 'Object', but got one of type 'Null'"

I'm trying to assign null to a specific key in Map<String, dynamic> in order to nullify the value in my SQL DB.
But I keep getting an error Error: Expected a value of type 'Object', but got one of type 'Null', in dartpad it works fine without any errors.
Here is the error I'm getting:
Error: Expected a value of type 'Object', but got one of type 'Null'
Here is my code:
Map<String, dynamic> map = {};
map["key2"] = null;
Flutter doctor:
[✓] Flutter (Channel master, 3.1.0-0.0.pre.1014, on macOS 12.5.1 21G83 darwin-x64, locale en-IL)
• Flutter version 3.1.0-0.0.pre.1014 at /Users/daniel/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 08e61c3be2 (6 months ago), 2022-05-31 00:18:09 -0400
• Engine revision 693f95391e
• Dart version 2.18.0 (build 2.18.0-152.0.dev)
• DevTools version 2.13.1
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
• Android SDK at /Users/daniel/Library/Android/sdk
• Platform android-32, build-tools 32.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
[✓] VS Code (version 1.73.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.52.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-x64 • macOS 12.5.1 21G83 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 107.0.5304.110
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!

Flutter Web - space bar key doesn't work in TextFields

whenever I try to press space bar inside a TextField of a Flutter Web Release it doesn't do anything. This occurs on ANY browser except for chrome.
I already tried this "fix":
return MaterialApp(
shortcuts: {
LogicalKeySet(LogicalKeyboardKey.space): ActivateIntent(),
},
And also I upgraded to flutter 2.10, which was a fix to some people. Sadly not for me, so I'm really happy about help.
The issues sometimes goes away if the Site is reloaded several times.
[✓] Flutter (Channel stable, 2.10.2, on macOS 11.1 20C69 darwin-arm, locale
en-DE)
• Flutter version 2.10.2
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 097d3313d8 (5 days ago), 2022-02-18 19:33:08 -0600
• Engine revision a83ed0e5e3
• Dart version 2.16.1
• DevTools version 2.9.2
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /Applications/Android
Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• All Android licenses accepted.
[!] Xcode - develop for iOS and macOS (Xcode 12.5.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
! Flutter recommends a minimum Xcode version of 13.
Download the latest version or update via the Mac App Store.
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
[✓] Connected device (1 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.102
[✓] HTTP Host Availability
• All required HTTP hosts are available

flutter failed to connect android device and off application on iPhone simulator

when I call debug mode on an android device
Error connecting to the service protocol: failed to connect to http://127.0.0.1:60027/bncnE_T-mWw=/
and also asks for permission to wifi, but through a notification, if I give permission, it shows a white screen and the same error
but everything starts quietly if you build the apk and install through it
with an iPhone simulator, the application starts and immediately closes, and in the android studio it is written that the connection is taking too long, it may have crashed
flutter doctor:
[✓] Flutter (Channel stable, 2.5.0, on Mac OS X 10.15.7 19H114 darwin-x64, locale ru-RU)
• Flutter version 2.5.0 at /Users/daniil/Documents/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 4cc385b4b8 (6 days ago), 2021-09-07 23:01:49 -0700
• Engine revision f0826da7ef
• Dart version 2.14.0
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/daniil/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.4, Build version 12D4e
• CocoaPods version 1.10.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
[✓] VS Code (version 1.58.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.24.0
[✓] Connected device (3 available)
• Redmi Note 8T (mobile) • 19645373 • android-arm64 • Android 10 (API 29)
• iPhone 8 Plus (mobile) • 06EE905E-8A76-45D5-A844-8DCDF2EEA3CA • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 93.0.4577.63
• No issues found!
Android the problem was solved by delete update "security" on firmware MIUI

Flutter path_provider getApplicationSupportDirectory() throws _CastError Null check operator on a null value

I am having issues running my flutter application. I am using objectbox-dart for storing data in my app. So far so good, but when I create a store using path_provider, the getApplicationSupportDirectory() throws _CastError: Null check operator on a null value. Below is the output of flutter doctor -v
[✓] Flutter (Channel stable, 2.2.1, on Mac OS X 10.15.7 19H2 darwin-x64, locale en-PK)
• Flutter version 2.2.1 at /Users/muhammadumar/sdks/flutter
• Framework revision 02c026b03c (11 days ago), 2021-05-27 12:24:44 -0700
• Engine revision 0fdb562ac8
• Dart version 2.13.1
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/muhammadumar/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.4, Build version 12D4e
• CocoaPods version 1.10.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
[✓] VS Code (version 1.56.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.23.0
[✓] Connected device (2 available)
• MI 8 Lite (mobile) • bb4e8ab • android-arm64 • Android 10 (API 29)
• Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.77
• No issues found!
Below is the exact line of code of path_provider file where exception is being caught
Future<Directory> getApplicationSupportDirectory() async {
final String? path = await _platform.getApplicationSupportPath();
if (path == null) {
throw MissingPlatformDirectoryException(
'Unable to get application support directory');
}
return Directory(path);
}
I am unable to run my app. Any help would be appreciated.
Thanks