Audio file does not play in the IOS Simulator - flutter

Hi I am developing a flutter application. In this application some sounds are downloaded from my website and saved to the local file storage. It plays when some pictures are showed.
This works in Android phone properly. But I cannot do it in IOS Simulator. I have controlled whether the files are downloaded properly. I have looked simulator files and saw sound files, so they are properly downloaded. My playing sound code is like that.
Future play(File soundFile) async {
debugPrint("sound: play enter");
try {
await advancedPlayer.stop();
advancedPlayer.setReleaseMode(ReleaseMode.RELEASE);
if (soundFile != null) {
print(soundFile.uri);
advancedPlayer.play(soundFile.uri.toString(), isLocal: true);
await advancedPlayer.onPlayerCompletion.first;
debugPrint("sound: played");
// advancedPlayer.stop();
}
} catch (e) {
debugPrint("sound: error");
}
debugPrint("sound: play leave");
}
In this code the program waits in this line and not doesn't go to the next lines.
await advancedPlayer.onPlayerCompletion.first;
I don't see any errors.
I have printed sound file path and controlled it, it is in the file storage. Format of audio file is mp3.
In my pubspec.yaml file I have tried 0.17.4 and 0.16.2 versions. I cannot use 0.18.x versions(because other packages dont let me)
audioplayers: ^0.17.4
Thank you so much
[✓] Flutter (Channel stable, 2.0.4, on Mac OS X 10.15.6 19G2021 darwin-x64, locale en-TR)
• Flutter version 2.0.4 at /Users/varyok/flutter
• Framework revision b1395592de (2 weeks ago), 2021-04-01 14:25:01 -0700
• Engine revision 2dce47073a
• Dart version 2.12.2
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /Users/varyok/Library/Android/sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.
[!] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.0, Build version 12A7209
! Xcode 12.0.0 out of date (12.0.1 is recommended).
Download the latest version or update via the Mac App Store.
• CocoaPods version 1.10.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 49.0.2
• Dart plugin version 193.7547
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] VS Code (version 1.55.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.21.0
[✓] Connected device (2 available)
• iPhone 11 (mobile) • EC15BA0B-9EA7-4FCB-9DD0-E7A6F8B30B95 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-14-0 (simulator)
• Chrome (web) • chrome • web-javascript • Google
Chrome 89.0.4389.128

Related

Flutter writeAsBytes from dart:io library returns PathNotFoundException

I am trying to use the following function in flutter:
Future<File> getFile(String fileName) async {
final appDir = await getTemporaryDirectory();
final appPath = appDir.path;
final fileOnDevice = File('$appPath/$fileName');
final rawAssetFile = await rootBundle.load(fileName);
final rawBytes = rawAssetFile.buffer.asUint8List();
await fileOnDevice.writeAsBytes(rawBytes, flush: true);
return fileOnDevice;
}
But somehow i keep getting this error, failed PathNotFoundException: Cannot open file, path = '/var/mobile/Containers/Data/Application/352527E9-XXXX-XXXX-XXXX-DCFXXXXXXXXX/Library/Caches/assets/
The function is called by final dataFile = await getFile('assets/sample.txt');
Does anyone know how to solve this? Any help is appreciated!
This is my flutter doctor -v
[✓] Flutter (Channel stable, 3.7.0, on macOS 13.1 22C65 darwin-arm64, locale en-SG)
• Flutter version 3.7.0 on channel stable at /Users/xaviertoh/Documents/Flutter/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision b06b8b2710 (3 weeks ago), 2023-01-23 16:55:55 -0800
• Engine revision b24591ed32
• Dart version 2.19.0
• DevTools version 2.20.1
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
• Android SDK at /Users/xaviertoh/Library/Android/sdk
• Platform android-33, build-tools 33.0.1
• 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.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14C18
• 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.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.58.0
[✓] Connected device (3 available)
• iPhone (mobile) • 00008020-000D05313C02002E • ios • iOS 13.5 17F75
• macOS (desktop) • macos • darwin-arm64 • macOS 13.1 22C65
darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 110.0.5481.77
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Thank you for reading!
Things i have tried:
I have confirmed that my file name is correct in the assets folder and i also tried running this code in various locations in the code such as in a widget and also in main() just to test it out.
I also tried running flutter in xcode and visual studio code.
Also tried to run the code in android emulator and also on iPhone physical device.
The /var/mobile/Containers/Data/Application/.../Library/Caches/assets/ directory must already exist. File.writeAsBytes won't automatically create parent directories for you.
You can do that step by first doing:
await fileOnDevice.parent.create(recursive: true);

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

VSCode cannot run flutter app after upgrading Flutter to release 1.20.0 and VSCode Flutter plugin to 1.13.1

Using MacOS and VSCode. Just upgraded Flutter to release 1.20.0 and now I cannot start my project in debug mode (F5) from within VSCode on my iPhone simulator.
If I execute on the terminal
flutter run
everything is working as expected.
Output of flutter doctor -v:
[✓] Flutter (Channel stable, 1.20.0, on Mac OS X 10.15.6 19G73, locale es-ES)
• Flutter version 1.20.0 at /Applications/flutter
• Framework revision 840c9205b3 (12 hours ago), 2020-08-04 20:55:12 -0700
• Engine revision c8e3b94853
• Dart version 2.9.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/abibiano/Library/Android/sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.6, Build version 11E708
• CocoaPods version 1.8.4
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 43.0.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] VS Code (version 1.47.3)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.13.1
[✓] Connected device (1 available)
• iPhone SE (2nd generation) (mobile) • C2027E6D-0C59-4B06-94BC-12382916EE09 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-13-6 (simulator)
• No issues found!
It's fixed.
Please update the vscode plugin for dart.
https://github.com/Dart-Code/Dart-Code/issues/2702

In flutter firebase cloud messaging is not working in oneplus 6/6t in production

In debug mode firebase cloud messaging is working fine in all phones but in production its not working in oneplus phones but its working fine in samsung phones. Battery optimization is not the issue,
I have seen solutions like setting channel id etc... if it is the solution can u please guide me with the solution in dart.
I am new to flutter ,and now stuck with this bug
[✓] Flutter (Channel stable, v1.17.5, on Mac OS X 10.15.5 19F101, locale en-IN) • Flutter version 1.17.5 at /users/rohitmadhu/Documents/flutter • Framework revision 8af6b2f038 (2 weeks ago), 2020-06-30 12:53:55 -0700 • Engine revision ee76268252 • Dart version 2.8.4
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at /Users/rohitmadhu/Library/Android/sdk • Platform android-29, build-tools 29.0.2 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405) • All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.5) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 11.5, Build version 11E608c • CocoaPods version 1.9.3
[✓] Android Studio (version 3.5) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 44.0.1 • Dart plugin version 191.8593 • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] VS Code (version 1.47.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.12.2
[✓] Connected device (1 available) • Rohit • 2d314272e0c5e22659a0de1a57d7ccc8915fc944 • ios • iOS 13.5.1
I am not sure about this solution is correct or not but it worked for me
Once you update SHA-1 in firebase in some devices we need uninstall the app and need to reinstall, just updating new version from play store was causing this issue.
thank you for all who spend time for this question.

Concatenation not working in flutter, instead, variable breaks into two lines?

So, this is a very small problem, but totally annoying!
This is my code:
print('COORDINATES -> ${lat}:${lng}');
As you can see, it should print out, example: '74.23132:47.13123' right?
But instead it goes like this..
flutter: COORDINATES -> 74.23132:
47.13123
Is it really suppose to work like that in flutter?
Best regards!
flutter doctor -v
[✓] Flutter (Channel stable, v1.7.8+hotfix.3, on Mac OS X 10.14.5 18F203, locale en-GB)
• Flutter version 1.7.8+hotfix.3 at /Users/usr/Developer/flutter
• Framework revision b712a172f9 (9 days ago), 2019-07-09 13:14:38 -0700
• Engine revision 54ad777fd2
• Dart version 2.4.0
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/usr/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: /Applications/Android Studio 3.5 Preview.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.2.1, Build version 10E1001
• CocoaPods version 1.7.0
[✓] iOS tools - develop for iOS devices
• ios-deploy 1.9.4
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio 3.5 Preview.app/Contents
• Flutter plugin version 37.1.3
• Dart plugin version 191.7830
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] Connected device (2 available)
• Mattias’s iPhone • aaf4a41bc5a93fcf273e2070e19ec2a6a3f37921 • ios • iOS 12.3.1
• iPhone Xʀ • 93F3E348-5835-492B-B756-CCD1BAD6C8E8 • ios • com.apple.CoreSimulator.SimRuntime.iOS-12-2 (simulator)
• No issues found!
SOLUTION
After trying every logic step to accomplish this, it turns out that the flutter-team hasn't supported this yet! So don't even get into this ever, until flutter support two variables in concatenating. Very very sad to let you know!