Comments (10)
@jonataslaw Removing
showDialog(context: context, builder: () => );
doesn't solve the problem.
Can you create a test example? I just can't reproduce this problem, and I am convinced that it has nothing to do with the library (touch or scroll events have nothing to do with this lib, and it is imperative, as soon as the code is called, it will be executed) .
The only thing that can be is the SchedulerBinding.instance blocking the appearance of the Snackbar.
Please change Get.snackbar for this, and tell me if the behavior has stopped. If not, I will need an example in the repository to try to help you, and I will reopen the issue.
static _showSnackbar({@required Map<String, dynamic> data}) {
GetBar(
title: "New Notif",
message: data['data']['notification_title'],
icon: ImageIcon(
AssetImage(Assets.defaultNotificationImage),
),
shouldIconPulse: true,
barBlur: 20,
isDismissible: true,
duration: Duration(seconds: 3),
backgroundColor: ColorPalette.primary,
snackPosition: SnackPosition.BOTTOM,
margin: EdgeInsets.only(bottom: 10.0, left: 15.0, right: 15.0),
colorText: Colors.white,
).show(); // important
}
GetBar doesn't use SchedulerBinding, so if that doesn't work for you, it's because Get isn't being called, but I will still help you solve the problem, even if it's not related to lib.
If it works, something is blocking the SchedulerBinding.
from getx.
Sorry, but I don't understand what you mean.
Is the snackbar being displayed only if the user touches or scrolls the screen?
What version of Flutter and Get are you using?
Please insert a reproduction case or sample code to reproduce the problem.
from getx.
Without more details about this error, it will not be possible to proceed with this issue.
In addition, the code above was tested on receiving messages in firebase and worked properly, so the problem must be in the code block where you call Get.snackbar.
Without a minimum reproduction, it is impossible to continue this issue, so it will be closed.
If the problem persists, reopen the problem with the form duly completed, with a code snippet where the error occurred, Flutter version, Get version, and describe the behavior in detail.
Closing it.
from getx.
Sorry for my late.
Snackbar show up when user touch screen, e.g. app is opened and notification arrived and but snackbar not show up until user touches screen.
class NotificationManger {
static navigateToReminders() {
Get.toNamed(Routes.reminders);
}
static onMessage(Map<String, dynamic> message) {
print(message);
_showSnackbar(data: message);
}
static onLaunch(Map<String, dynamic> message) {
navigateToReminders();
print(message);
}
static onResume(Map<String, dynamic> message) {
navigateToReminders();
print(message);
}
static _showSnackbar({@required Map<String, dynamic> data}) {
showDialog(context: _context, builder: (_) => );
Get.snackbar(
"New Notif",
data['data']['notification_title'],
icon: ImageIcon(
AssetImage(Assets.defaultNotificationImage),
),
shouldIconPulse: true,
barBlur: 20,
isDismissible: true,
duration: Duration(seconds: 3),
backgroundColor: ColorPalette.primary,
snackPosition: SnackPosition.BOTTOM,
margin: EdgeInsets.only(bottom: 10.0, left: 15.0, right: 15.0),
colorText: Colors.white,
);
}
}
This is where I using it.
Get package version: get: ^1.17.2
and `flutter doctor -v output:
[✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Linux, locale en_US.UTF-8)
• Flutter version 1.12.13+hotfix.9 at /home/hamidreza/flutter
• Framework revision f139b11009 (3 weeks ago), 2020-03-30 13:57:30 -0700
• Engine revision af51afceb8
• Dart version 2.7.2
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /home/hamidreza/Android/Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.3
• ANDROID_HOME = /home/hamidreza/Android/Sdk
• Java binary at: /snap/android-studio/88/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.
[!] Android Studio (version 3.6)
• Android Studio at /snap/android-studio/88/android-studio
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
[✓] Connected device (1 available)
• C6603 • CB5A1VRUQV • android-arm • Android 5.1.1 (API 22)
! Doctor found issues in 1 category.
from getx.
showDialog(context: context, builder: () => );
This overlap that is causing this:
showDialog(context: context, builder: () => );
I think you would need to use Get.dialog instead of this code with context, and you should also see the logic of your code to be displayed or a dialog or a snackbar, or one after the other.
from getx.
@jonataslaw Removing showDialog(context: context, builder: () => );
doesn't solve the problem.
from getx.
@jonataslaw Your code works.
I don't know how to reproduce this.
I have just Fcm class and NotificationManger class.
Fcm
Future<dynamic> myBackgroundMessageHandler(Map<String, dynamic> message) {
print('background: $message');
if (message.containsKey('data')) {
final dynamic data = message['data'];
}
if (message.containsKey('notification')) {
final dynamic notification = message['notification'];
}
// Or do other work.
}
class Fcm {
static final FirebaseRepository repository = FirebaseRepository();
static final FirebaseMessaging _fcm = FirebaseMessaging();
static initConfigure() {
if (Platform.isIOS) _iosPermission();
_fcm.requestNotificationPermissions();
_fcm.autoInitEnabled();
_fcm.configure(
onMessage: (Map<String, dynamic> message) async => NotificationManger.onMessage(message),
onLaunch: (Map<String, dynamic> message) async => NotificationManger.onLaunch(message),
onResume: (Map<String, dynamic> message) async => NotificationManger.onResume(message),
onBackgroundMessage: myBackgroundMessageHandler,
);
_fcm.getToken().then((String token) {
print('token: $token');
repository.setUserNotifToken(token);
});
}
static _iosPermission() {
_fcm.requestNotificationPermissions(IosNotificationSettings(sound: true, badge: true, alert: true));
_fcm.onIosSettingsRegistered.listen((IosNotificationSettings settings) {
print("Settings registered: $settings");
});
}
}
and in my home screen I configure Fcm:
@override
void initState() {
super.initState();
Fcm.initConfigure();
}
from getx.
@jonataslaw Your code works.
I don't know how to reproduce this.
I have just Fcm class and NotificationManger class.Fcm
Future<dynamic> myBackgroundMessageHandler(Map<String, dynamic> message) { print('background: $message'); if (message.containsKey('data')) { final dynamic data = message['data']; } if (message.containsKey('notification')) { final dynamic notification = message['notification']; } // Or do other work. } class Fcm { static final FirebaseRepository repository = FirebaseRepository(); static final FirebaseMessaging _fcm = FirebaseMessaging(); static initConfigure() { if (Platform.isIOS) _iosPermission(); _fcm.requestNotificationPermissions(); _fcm.autoInitEnabled(); _fcm.configure( onMessage: (Map<String, dynamic> message) async => NotificationManger.onMessage(message), onLaunch: (Map<String, dynamic> message) async => NotificationManger.onLaunch(message), onResume: (Map<String, dynamic> message) async => NotificationManger.onResume(message), onBackgroundMessage: myBackgroundMessageHandler, ); _fcm.getToken().then((String token) { print('token: $token'); repository.setUserNotifToken(token); }); } static _iosPermission() { _fcm.requestNotificationPermissions(IosNotificationSettings(sound: true, badge: true, alert: true)); _fcm.onIosSettingsRegistered.listen((IosNotificationSettings settings) { print("Settings registered: $settings"); }); } }
and in my home screen I configure Fcm:
@override void initState() { super.initState(); Fcm.initConfigure(); }
Did using GetBar work for you?
If so, the problem is in the Flutter's SchedulerBinding in its version.
You can continue using GetBar, it is the same as Get.snackbar. And I will investigate why the SchedulerBinding is blocked in your class to open an issue in Flutter.
from getx.
@jonataslaw Yes it works.
tnx.
from getx.
Here's an example video, the snackbar will not show unless I touch the screen
video_2023-01-19_09-46-53.mp4
from getx.
Related Issues (20)
- Need change dark mode theme HOT 6
- getx is dead? HOT 1
- Navigation Transition HOT 1
- Can't load Kernel binary: Invalid kernel binary format version HOT 1
- Please add new transition type: Transition.predictiveBack HOT 1
- Get 5.0.0 Nested Navigation duplicate routes HOT 5
- You need to call "Get.put(xx)" or "Get.lazyPut(()=>xx()) HOT 9
- Nested Navigation State Not Retained on Back to "Navigation" Tab HOT 3
- Unable to ecustomize `rootDelegate.pickPagesForRootNavigator` HOT 1
- Keyboard not appearing after swipe-back gesture when returning to a screen with TextField using GetX HOT 3
- A Controller's task continues to execute even after being deleted. HOT 1
- getx tree routing problem HOT 1
- An improper use of GetX has been detected when building PopupMenuButton in Obx
- [5.0.0-release-candidate-6] - PopScope not working in Flutter WEB HOT 1
- [5.0.0-release-candidate-6] - Get.back(result: true) or Get.close(result: true) does not return HOT 1
- GetResponsiveView not return the correct width when mobile orientation changes
- use GetX with routefly
- Flutter - get package: The getter 'backgroundColor' isn't defined for the class 'ThemeData' HOT 5
- get.dialog() animation HOT 1
- Prevent rebuild entire SliverGrid on LOAD more data
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from getx.