Flutter - GIFs play slower than they should - android

I'm working on a Flutter app that can display images from the network. Everything is working fine, however, GIFs seem to play slightly slower than they should.
I have created a new Flutter project in VSCode (View > Command Pallete > Flutter: New Project) and managed to recreate it, so it's not an issue with the project.
'Clean projects' main.dart file:
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'GIFTEST',
home: Page(),
);
}
}
class Page extends StatefulWidget {
const Page({Key? key}) : super(key: key);
#override
State<Page> createState() => _PageState();
}
class _PageState extends State<Page> {
#override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Image.network("https://media1.giphy.com/media/b08ArVM6rvmpy/giphy.gif?
cid=ecf05e47agbfbjzjfkw2q34ta1hw9f2tdgm9qv57hm2cqi7l&rid=giphy.gif&ct=g"),
)
);
}
}
Link to the gif vs. How it actually plays (Device: Xiaomi Redmi 6A running MIUI Global 11.0.8 Stable; Ran in Profile mode)
Second link to the gif if the first one doesn't work
Output of flutter doctor -v:
[√] Flutter (Channel stable, 2.10.4, on Microsoft Windows [Version 10.0.19043.1586], locale sk-SK)
• Flutter version 2.10.4 at C:\SDKs\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision c860cba910 (3 weeks ago), 2022-03-25 00:23:12 -0500
• Engine revision 57d3bac3dd
• Dart version 2.16.2
• DevTools version 2.9.2
[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
• Android SDK at C:\Users\<User>\AppData\Local\Android\sdk
• Platform android-32, build-tools 32.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.2.0 Preview 1.0)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Preview
• Visual Studio Community 2022 version 17.2.32210.308
• The current Visual Studio installation is a pre-release version. It may not be supported by Flutter yet.
• Windows 10 SDK version 10.0.20348.0
[√] Android Studio (version 2020.3)
• Android Studio at C:\Program Files\Android\Android Studio
• 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-7249189)
[√] VS Code (version 1.66.2)
• VS Code at C:\Users\<User>\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.38.1
[√] Connected device (4 available)
• Redmi 6A (mobile) • 4b971dcd7d2c • android-arm • Android 9 (API 28)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19043.1586]
• Chrome (web) • chrome • web-javascript • Google Chrome 100.0.4896.88
• Edge (web) • edge • web-javascript • Microsoft Edge 100.0.1185.39
[√] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Is there any way to fix this issue ?
P.S: Can provide any additional information that is needed or that can help with solving the problem.

Related

CERTIFICATE_VERIFY_FAILED handshake error in vscode but works fine in Android Studio

I'm new to flutter and had my flutter environment set up. I was using VS Code as my editor.
When i tried to request apis it threw me
HandshakeException: Handshake error in client
So eventually i searched it on web and found a solution
void main() {
HttpOverrides.global = MyHttpOverrides();
runApp(const MyApp());
}
class MyHttpOverrides extends HttpOverrides {
#override
HttpClient createHttpClient(SecurityContext? context) {
return super.createHttpClient(context)
..badCertificateCallback =
(X509Certificate cert, String host, int port) => true;
}
}
It did the job but it was mentioned there that this was not ideal. (esp. for prod.)
After few days i tried to use Android Studio for a new project and found i had no issues requesting APIs on Android Studio. I thought the error was fixed but when i ran the exact same code on VS Code i got Handshake error again.
I really want to use VSCode because its really light to use.
So can anyone help me with this what is causing this issue on VS Code and why the hell exact same code works on Android Studio?
Here is the output for flutter doctor -v
[✓] Flutter (Channel stable, 3.3.10, on macOS 13.1 22C65 darwin-arm, locale
en-IN)
• Flutter version 3.3.10 on channel stable at
/Users/dev.meena/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 135454af32 (8 weeks ago), 2022-12-15 07:36:55 -0800
• Engine revision 3316dd8728
• Dart version 2.18.6
• DevTools version 2.15.0
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
• Android SDK at /Users/dev.meena/Library/Android/sdk
• Platform android-33, build-tools 33.0.1
• Java binary at: /Users/dev.meena/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9123335/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 /Users/dev.meena/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9123335/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)
[!] Android Studio (version 2022.1)
• Android Studio at /Users/dev.meena/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9477386/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
✗ Unable to find bundled Java version.
• Try updating or re-installing Android Studio.
[✓] IntelliJ IDEA Community Edition (version 2022.3.1)
• IntelliJ at /Users/dev.meena/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/223.8214.52/IntelliJ IDEA CE.app
• 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
[✓] VS Code (version 1.74.2)
• VS Code at /Users/dev.meena/Downloads/Visual Studio Code.app/Contents
• Flutter extension version 3.58.0
[✓] Connected device (3 available)
• iPhone 14 Pro Max (mobile) • B401E3BC-F514-4C34-B73F-B9B31B70C5E8 • ios • com.apple.CoreSimulator.SimRuntime.iOS-16-2 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.1 22C65 darwin-arm
• Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.119
[✓] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 1 category.
I expect both environments to work similarly.
I recommend that you first run the api with posman or insomnia, in case you have a certificate error, contact with backend person because it is a bad server configuration

Flutter app crashes on startup. How can I fix it?

I'm currently building an app, but it crashes on startup. I've decided tot replace the main.dart code with the most basic default Flutter code, so I can paste codes from the original main.dart file in order to find out what causes the app to crash on startup.
main.dart:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Flutter Demo'),
),
body: Center(
child: Text('Hello World'),
),
),
);
}
}
But when running I get the following error message:
√ Built build\app\outputs\flutter-apk\app-debug.apk.
D/FlutterLocationService(10600): Creating service.
D/FlutterLocationService(10600): Binding to location service.
Lost connection to device.
As you can see, I have not even mentioned geolocator or location plugin in the main.dart but it still crashes with D/FlutterLocationService. How does that even work? It has the same error message as the orginal main.dart. How can I solve this whole predicament?
flutter doctor -v:
[!] Flutter (Channel unknown, 3.3.8, on Microsoft Windows [Version 10.0.22000.1335], locale en-US)
! Flutter version 3.3.8 on channel unknown at C:\Users\DELL\Downloads\flutter_windows_2.10.2-stable\flutter
! Upstream repository unknown
• Framework revision 52b3dc25f6 (8 weeks ago), 2022-11-09 12:09:26 +0800
• Engine revision 857bd6b74c
• Dart version 2.18.4
• DevTools version 2.15.0
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at C:\Users\DELL\AppData\Local\Android\sdk
• Platform android-33, build-tools 33.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.2.1)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.2.32516.85
• Windows 10 SDK version 10.0.19041.0
[√] Android Studio (version 2021.2)
• Android Studio at C:\Program Files\Android\Android Studio
• 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+7-b1504.28-7817840)
[√] VS Code (version 1.74.2)
• VS Code at C:\Users\DELL\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.56.0
[√] Connected device (4 available)
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 12 (API 32) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22000.1335]
• Chrome (web) • chrome • web-javascript • Google Chrome 108.0.5359.125
• Edge (web) • edge • web-javascript • Microsoft Edge 108.0.1462.54
[√] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 1 category.
I'm also running this on Android emulator Pixel 4 API 32.

[FLUTTER][firebase_messaging] Error receiving background notifications for "Android 12" just when permissions are checked

I am a bit desperate with an error when receiving push notifications in the background, and it is failing due to the error that I indicate below,
I was looking for possible solutions but I haven't found anything that worked, can you help me, maybe it's a bug in the firebase_messaging library? Has anyone experienced something similar?
Devices & versions:
[FAIL] Physical Devide with Android 12: Fail
[✓] Physical Devide with Android 13: run perfect
[✓] Physical Devide with IOs 16.2: run perfect
NOTE: I'm not sure if other versions prior to 12 get this error
Flutter code where the error occurs:
I have tried both possibilities with the same result:
NotificationSettings settings = await FirebaseMessaging.instance.requestPermission();
OR
NotificationSettings settings = await FirebaseMessaging.instance.getNotificationSettings();
Flutter Error:
I/flutter (11341): FlutterFire Messaging: An error occurred in your background messaging handler:
I/flutter (11341): [firebase_messaging/unknown] Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
Flutter environment:
plugins related and installed:
firebase_core: ^2.4.1
firebase_messaging: ^14.2.1
flutter_local_notifications: ^13.0.0
permission_handler: ^10.2.0
fllutter doctor -v
[✓] Flutter (Channel stable, 3.7.0, on macOS 13.1 22C65 darwin-arm64, locale es-ES)
• Flutter version 3.7.0 on channel stable at /Users/josevv/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision b06b8b2710 (hace 9 días), 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.0)
• Android SDK at /Users/josevv/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.15+0-b2043.56-8887301)
• 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 2022.1)
• 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.15+0-b2043.56-8887301)
[✓] VS Code (version 1.74.3)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.58.0
[✓] Connected device (3 available)
• NE2213 (mobile) • eea79ab4 • android-arm64 • Android 12 (API 31)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.1 22C65 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.119
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Expected behavior: Receive background push notifications
current behavior: on android 12 (haven't been able to check on versions prior to 12), no background push notifications due to mentioned bug
Finally, I have solved it changing for Android (NotificationSettings settings = await FirebaseMessaging.instance.getNotificationSettings(); ) whit this simply piece of code, like this:
if (Platform.isAndroid) {
flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()!
.requestPermission();
} else if (Platform.isIOS) {
NotificationSettings settings = await FirebaseMessaging.instance.requestPermission(
alert: true,
announcement: false,
badge: true,
carPlay: false,
criticalAlert: false,
provisional: false,
sound: true,
);
if (settings.authorizationStatus == AuthorizationStatus.authorized) {.....}
}

The service is currently unavailable | Firebase cloud_firestore issue

When I try Firebase Firestore on my Android device, the error below is occurred.
[cloud_firestore/unavailable] The service is currently unavailable.
This is a most likely a transient condition and may be corrected by
retrying with a backoff.
This doesn't happen when I try with emulator even same code.
What I doing
Updated version of firebase packages.
firebase_core: ^1.10.0
firebase_auth: ^3.1.4
cloud_firestore: ^3.1.0
Using FutureBuilder to get fields.
In my StatefulWidget;
#override
Widget build(BuildContext context) {
myInterstitial.load();
return FutureBuilder(
future: FirebaseFirestore.instance
.collection("users")
.doc(FirebaseAuth.instance.currentUser!.uid)
.get(),
builder:
(BuildContext context, AsyncSnapshot<DocumentSnapshot> snapshot) {
if (snapshot.hasError) {
return Text(snapshot.error.toString());
}
if (snapshot.hasData && !snapshot.data!.exists) {
FirebaseAuth.instance.signOut();
return const Text("Document does not exist ");
}
if (snapshot.connectionState == ConnectionState.done) {
.............
I don't know why but snapshot.hasError is alaways true, and snapshot.error.toString() returns error above.
I didn't change any code but it works on emulator. However the build (build with $ flutter build appbundle --no-sound-null-safety, $ flutter build apk --no-sound-null-safety and '$ flutter run --no-sound-null-safety') doesn't work better.
The biggest mystery is that everything works correctly in the emulator.
How can I solve this?
flutter doctor -v
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 400608f101 (8 weeks ago), 2021-09-15 15:50:26 -0700
• Engine revision 1d521d89d8
• Dart version 2.15.0 (build 2.15.0-82.2.beta)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at D:\Android
• Platform android-31, build-tools 29.0.3
• Java binary at: D:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 4.2)
• Android Studio at D:\Program Files\Android\Android Studio
• 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.6842174)
[√] VS Code (version 1.62.2)
• VS Code at C:\Users\yukik\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.28.0
[√] Connected device (4 available)
• Pixel 5a (mobile) • 16121JECB02429 • android-arm64 • Android 12 (API 31)
• Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 95.0.4638.69
• Edge (web) • edge • web-javascript • Microsoft Edge 95.0.1020.44
• No issues found!
I've been through this recently in a React Native project with Android emulator.
The only thing that solved was to delete the emulator device and creating another.
I was experience a similar issue ,
firebase/firestore (while performing get , set and other operations) on emulator , everything was working fine on an actual android device but not on android emulator,
what I did to fix was , changed my android studio to 2021 patch version It fixed the error and everything started working .
Hope it helps someone :)

The code doesn't work: void main() => runApp(MaterialApp(home: Center(child: Text('Hello World'))));

(Sorry for my poor English)
The first picture is from a video, the second one is mine.
In the first picture you can see that the result of the her coding is "hello world"
But nothing happened to mine.
What's wrong with my coding?
Picture one
Picture two
Flutter doctor:
C:\src\flutter\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel stable, v1.17.2, on Microsoft Windows [Version 10.0.18362.900], locale zh-TW)
• Flutter version 1.17.2 at C:\src\flutter\flutter
• Framework revision 5f21edf8b6 (4 weeks ago), 2020-05-28 12:44:12 -0700
• Engine revision b851c71829
• Dart version 2.8.3
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at C:\Users\MSINB\AppData\Local\Android\sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 46.0.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] Connected device (1 available)
• Android SDK built for x86 64 • emulator-5554 • android-x64 • Android 9 (API 28) (emulator)
! Doctor found issues in 1 category.
Process finished with exit code 0
There may be problem with gradle, installisation. You could find answer here.
Just add a Scaffold as home: Scaffold and the Center as body: Center.
import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(
home: Scaffold(
body: Center(
child: Text('Hello World'),
),
),
),
);

Categories

Resources