Skip to content

Instantly share code, notes, and snippets.

@RipplesCode
Created January 5, 2021 11:09
Show Gist options
  • Save RipplesCode/3ed06154de85762c8708e64f3f8b54fc to your computer and use it in GitHub Desktop.
Save RipplesCode/3ed06154de85762c8708e64f3f8b54fc to your computer and use it in GitHub Desktop.
GetX Snackbar
import 'package:flutter/material.dart';
import 'package:get/get.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: implement build
return GetMaterialApp(
title: "Snackbar",
home: Scaffold(
appBar: AppBar(title: Text("Snackbar")),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
RaisedButton(
child: Text("Show Snackbar"),
onPressed: () {
Get.snackbar(
"Snackbar Title", "This will be Snackbar Message",
titleText: Text("Another Title"),
messageText: Text(
"Another Message",
style: TextStyle(color: Colors.white),
),
snackPosition: SnackPosition.BOTTOM,
colorText: Colors.white,
backgroundColor: Colors.black,
borderRadius: 30,
margin: EdgeInsets.all(10),
//maxWidth: 100,
animationDuration: Duration(milliseconds: 3000),
backgroundGradient: LinearGradient(
colors: [Colors.red, Colors.green],
),
// While using borderColor ensure you are using borderWidth otherwise error will be generated
borderColor: Colors.purple,
borderWidth: 4,
boxShadows: [
BoxShadow(
color: Colors.yellow,
offset: Offset(30, 50),
spreadRadius: 20,
blurRadius: 8)
],
dismissDirection: SnackDismissDirection.HORIZONTAL,
forwardAnimationCurve: Curves.bounceInOut,
duration: Duration(milliseconds: 8000),
icon: Icon(
Icons.send,
color: Colors.white,
),
shouldIconPulse: false,
isDismissible: true,
leftBarIndicatorColor: Colors.red,
mainButton: FlatButton(
child: Text("Retry"),
color: Colors.green,
textColor: Colors.white,
onPressed: () {},
),
onTap: (val) {
print("Retry clicked");
},
//overlayBlur: 5,
// overlayColor: Colors.grey,
padding: EdgeInsets.all(50),
showProgressIndicator: true,
progressIndicatorBackgroundColor: Colors.deepOrange,
progressIndicatorValueColor:
AlwaysStoppedAnimation<Color>(Colors.white),
reverseAnimationCurve: Curves.bounceInOut,
snackbarStatus: (val) {
print(val);
},
snackStyle: SnackStyle.FLOATING,
userInputForm: Form(
child: Row(
children: [
Expanded(
child:TextField()
)
],
),
)
);
},
),
],
)),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment