Running the following code is very slow on iOS device although it is fast on iOS simulator.
The file comes from its album.
How can I speed it up?
Future<List<int>> decoding(File f) async {
return await f.readAsBytes();
}
Related
I'm using Expo's iOS simulator with my React Native app. Before, it would live update / "fast refresh" when code changes were made, but it's no longer doing that. So this is not about using the Expo Go app on my phone, but rather the Simulator on my Macbook.
I've checked the shake (ctrl + cmd + Z) menu, and Fast Refresh is still enabled. Running npx expo run:ios does correctly reflect the latest code, but that takes a while to run.
Any help to debug this?
A few days ago the same thing happened to me and it depended on how I exported the main component to App.tsx.
This one doesn't work properly:
export default () => {
return <View/>
}
This one works:
const App = () => {
return <View/>
}
export default App
Let me know if this helps
I'm using flutter_blue_plus package which is almost same with flutter_blue. When I test with iphone 13 mini connected with mac book xcode, my app scans bluetooth devices well. But when I extract my app to .ipa and install the app using xcode, my iphone 13 mini(which is not connected to mac book) not scan bluetooth devices anymore. Of course I've checked that I give same permission to the iphone both of the test.
Is there any suggestion for test or anyone experienced same situation?
I'm very beginner of flutter and ios development (I just started it from a month ago), so please give me any advice if you have about this bluetooth problem..
My scan function is in the background mode, and I checked the scanned devices using snack bar. But I think it is not the problem, the app works well when I test with xcode and the iphone is connected to mac.
I added a part of my code for your information.
(My function for BLE Scanning)
Future<void> initialScanning() async {
// ios execute this function with .ipa installed but skips scanning.
final FlutterBluePlus flutterBlue = FlutterBluePlus.instance;
// Start scanning
flutterBlue.startScan(timeout: Duration(seconds: _firstScanDuration));
// Listen to scan results
var subscription = flutterBlue.scanResults.listen((results) async {
// Find the device with the name and Register
for (ScanResult r in results) {
print('${r.device.name} rssi: ${r.rssi}');
if (r.device.name == 'raspberrypi') {
if (!devices.contains(r.device)) {
devices.add(r.device);
print('device added!!!!');
}
}
}
for (BluetoothDevice device in devices) {
if (!registeredDevices.contains(device.id.toString())) {
registeredDevices.add(device.id.toString());
await someBleRegister(device);
}
}
});
// Stop scanning
flutterBlue.stopScan();
}
(onEvent function for flutter_foreground_task)
#override
Future<void> onEvent(DateTime timestamp, SendPort? sendPort) async {
if (_eventCount == 0) {
await initialScanning();
} else {
print('number of devices: ${someBles.length}');
for (SomeBle ble in someRegisteredBles) {
await someBleReadAndWrite(ble);
}
}
I my self found out the answer that flutter_blue_plus.startScan (i.e. BLE scan) is not work well with flutter_foreground_task package in ios.
When I use the startScan in onStart( a override method of flutter_foreground_task package), the BLE scanning was work well with normal development setup with xcode.
But the same code was not work when I made .ipa file and installed to iphone.
It never scans anything and skips the scanning.
But when I moved the BLE scanning codes to the foreground, it worked well both xcode connected and .ipa file installed.
I don't know why.. but, anyway, that is true.
(Edit) flutter_reactive_ble not work too in flutter_foreground_task background mode with .ipa file installed.
I am using soundpool to play small mp3 sounds in my app. On android everything works fine. But on ios it just won't work. I don't get any error at all, but it just does not play the sound. Neither in the simulator nor on my real device.
This is my code:
_successSoundId = await rootBundle.load("assets/sounds/success.mp3").then((ByteData soundData) {
return pool.load(soundData);
});
await pool.play(_successSoundId)
pubspec:
dependencies:
soundpool: ^2.3.0
assets:
- assets/sounds/
Do I need some permissions or something? What am I missing here.
We are using firebase_messaging ^9.1.1 in our flutter app. onBackgroundMessage is being called in 'iPhone se' when app is in background or in terminated state. But is in not being called on iPhone 7 or iPhone 8. IOS version is same in all the devices i.e. IOS 14.4.2.
We are calling callkeep: ^0.2.3+1 plugin in onBackgroundMessage. We can't see call UI when app is terminated/in background and receive notification (iPhone 7 or iPhone 8).
This is our code:
void main() async {
FirebaseMessaging.onBackgroundMessage(myBackgroundMessageHandler);
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
if (!UniversalPlatform.isWeb) {
PushNotificationsManager().initCallKit();
}
Future<dynamic> myBackgroundMessageHandler(RemoteMessage message) async {
await Firebase.initializeApp();
//callkeep: ^0.2.3+1 plugin. code here.
}
Have anyone faced this issue? what next we can try to solve this issue?
I need to detect, if an app is running on an iOS or Android emulator to skip an QR code scan method and just return a scanned code.
Q: How do I detect
on which device type - iOS or Android - an app is running and
if an app is running on an emulator?
Just found this plugin, which prints various details:
https://pub.dartlang.org/packages/device_info#-readme-tab-
Output on Android emulator [see last line]:
safe_device: ^1.1.1
import 'package:safe_device/safe_device.dart';
Checks whether device is real or emulator
bool isRealDevice = await SafeDevice.isRealDevice;
(ANDROID ONLY) Check if development Options is enable on device
bool isDevelopmentModeEnable = await SafeDevice.isDevelopmentModeEnable;