lanarsinc / top-snackbar-flutter Goto Github PK
View Code? Open in Web Editor NEWModern UI snackbar widget
License: Other
Modern UI snackbar widget
License: Other
import 'package:flutter/material.dart';
import 'package:top_snackbar_flutter/top_snack_bar.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Builder(builder: (context) {
return Scaffold(
body: Center(
child: TextButton(
onPressed: () => showTopSnackBar(
context,
Container(
width: double.infinity,
margin: const EdgeInsets.only(top: 47),
height: 41,
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: const Color(0xffFF277F),
borderRadius: BorderRadius.circular(8),
),
child: const Text(
'Testing testing testing',
// minFontSize: 10,
maxLines: 1,
style: TextStyle(
color: Colors.white,
fontSize: 14,
height: 17 / 14,
fontWeight: FontWeight.w500,
),
),
),
displayDuration: const Duration(seconds: 10000),
),
child: const Text('click'),
),
),
);
}),
);
}
}
There are underlines on text. And, font family works wrong too, even if I've set default font family on MaterialApp.
So, I need to override every text style to show properly.
flutter doctor -v
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.1 21C52 darwin-arm, locale
en-KR)
• Flutter version 2.8.1 at /Users/suhwancha/development/GitHub/flutter
• Upstream repository [email protected]:SuhwanCha/flutter.git
• Framework revision 77d935af4d (2 weeks ago), 2021-12-16 08:37:33 -0800
• Engine revision 890a5fca2e
• Dart version 2.15.1
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
• Android SDK at /Users/suhwancha/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-7249189)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.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-7249189)
[✓] VS Code (version 1.63.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.29.0
[✓] Connected device (2 available)
• sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 12
(API 31) (emulator)
• Chrome (web) • chrome • web-javascript • Google
Chrome 96.0.4664.110
Got this build error message in one of my apps: "since your app depends on both one_context ^0.5.0 and shared_preferences ^2.0.3, version solving failed". Using older versions of shared_preferences will also result in a "version solving problem" with the other packages.
I encountered a bug while using the feature: if I force too many notifications to appear on the screen, the shadows leave a blurry smear on the top screen, which doesn't disappear. I thought about decreasing the display time of this notification, but the property not found in the plugin.
I really liked the package (compared with showing Android styled snack bar)
I have a use case to show persisting messages until removed manually, something like "No internet connection" I want to keep the snack bar showing until the network state change.
What I tried:-
displayDuration
to const Duration(days: 365)
which seems fine till nowonTap
it is still dismissible with user clicks)Based on the use case above, I believe these features will most likely resolve it:-
bool isInfiniteDuration
which default to false; However, when set to true it disables the dismiss completely.bool isDismissible
which default to true; However, when set to true the user clicks won't dismiss the snack barTopSnackBar
widget with the showTopSnackBar
and expose a public method to dismiss the widgetIs there any way of call top-snackbar-flutter
using a GlobalKey
for scaffoldMessengerKey
?
We have a specific use case in which we don't have access to context, but we do have a instance of scaffoldMessengerKey
, I have tried this without success:
showTopSnackBar(
scaffoldMessageKey.currentContext!,
ToastBody(
...
),
padding: EdgeInsets.zero,
);
Is there any way of using top-snack-bar
without BuildContext
directly?
Very useful package!
Please add a feature to gradient background (like in Container widget)
Tnx!
I understand that version 3 has a breaking change, "Remove BuildContext in favor of OverlayState", but how to migrate from existing code? showTopSnackBar()
now throws type 'StatelessObserverElement' is not a subtype of type 'OverlayState'
in the console.
hey please can you add a feature to allow adjustment of the snack bar. height and width
Currently pub.dev shows "Unverified publisher" for this package:
If we use this package, it makes code reviews harder in our company. Can you please verify your publishing account to show your domain name like this?
Here is how to do this: https://dart.dev/tools/pub/verified-publishers
The snackbar appears at the top. Is it possible to center the snackbar or show it at the bottom?
This package is super-nice. Thank you!
I've noticed that when using showTopSnackBar
that it always fills the width of app window when it's displayed. This is fine on a phone, but it's pretty wide on tablets and desktop.
I am passing my own custom widget into the snackbar, but I can't find a way to set a maximum width. I've tried hard-coding the width
on the container and also setting a maxWidth
using BoxContraints
without any luck.
Is it possible to set a max width on this somehow?
how to hide non persistent snack bar programmatically.
for eg:
onTap(){
ScaffoldMessenger.of(context).hideCurrentSnackBar();
}
The first example is:
showTopSnackBar(
context,
CustomSnackBar.success(
message:
"Good job, your release is successful. Have a nice day",
),
);
This does not build because the first argument requires OverlayState
instead of BuildContext
.
Other examples should be updated too.
Regular SnackBar has this method to hide current SnackBar - ScaffoldMessenger.of(context).hideCurrentSnackBar();
Is there any function which closes previous one before showing topSnackBar?
I want to let the user to select to tap on the snackBar to go to the main screen, or just dismiss it by swipe, but it doesn't work, the onTap function is working only if i'm not using DismissType.onSwipe
showTopSnackBar(
Overlay.of(context),
Container(child: Text('Text')),
curve: Curves.fastLinearToSlowEaseIn,
dismissDirection: [DismissDirection.up, DismissDirection.horizontal],
dismissType: DismissType.onSwipe, <----------------- when comment it, the goToMainScreen() is working
onTap: () => goToMainScreen(context),
);
Hi! Is there an easy way to disable bounce? I would prefer to have a smooth entry and exit of the notification instead of a bounce.
Is there any way of dismissing the top snackbar when it is tapped?
new Timer.periodic(Duration(milliseconds: 10000), (timer) {
showTopSnackBar(
context,
CustomSnackBar.info(
message:
"There is some information. You need to do something with that",
),
);
});
Dear,
Currently the height of showTopSnackBar is fixed by 80, in my case the content is overflow that height.
Could you change the height of showTopSnackBar, I think the minimum height of showTopSnackBar is 80, maximum is unlimit.
Thank you so much
Is there any way to limit the amount of entries in the overlaystate?
Best regards.
All icons are rotated by 32 degrees, even ones passed as parameters, here.
I think a better feature would be either rotating only default icons, or being able to specify the rotation degree.
There's a way to resize (heigh) of this top snack bar?, i think it's to large. I may be a bit shorter should be more pretty.
There's not contributing guideline file?
I want the snackbar to be placed on top center of my application and not to expand through screen width. I tried wrapping my custom snackbar with a Row
widget but it throws bunch of following exceptions:
Assertion failed:
!_debugDuringDeviceUpdate
is not true
snackbars get overwritten by newer ones
Thanks
Доброго ранку
I set the text style in the parameters, but it ignores, in particular, I can’t change the color of the text
Overlay.of(context),
CustomSnackBar.info(
borderRadius: CustomRadius.radius(20),
message: text.isEmpty
? L10n.of(context).error
: '${L10n.of(context).error} $text',
textStyle: TextStyle(
fontFamily: 'Inter',
fontSize: 16,
fontWeight: FontWeight.w400,
color: ColorName.white,
height: 16,
),
icon: SizedBox(),
Thanks in advance, Перемога за Украиной
Hi, first of all thanks for the package!
Can multiple snackbars be set to queue up and showing with set display duration one by one?
I have a message for the user: "You can't select more. Edit your current selections OR tap on the 'Next' button." When I click on the next button, I would like to "force remove"/"force start the reverse animation" of the active message because it is not actual anymore.
Is there any way to do this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.