I have a TextButton. I want to add an animation to this TextButton. I want to add presence animation. So instead of suddenly existing without animation, it will slowly exist. How can I do that?
Codes:
TextButton(
child: Text('Example text button'),
onPressed: () {
print('Clicked');
}
)
You can use these package argon_buttons to add animation to a button.
flutter_spinkit
ArgonButton(
height: 50,
width: 350,
borderRadius: 5.0,
color: Color(0xFF7866FE),
child: Text(
"Continue",
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.w700
),
),
loader: Container(
padding: EdgeInsets.all(10),
child: SpinKitRotatingCircle(
color: Colors.white,
// size: loaderWidth ,
),
),
onTap: (startLoading, stopLoading, btnState) {
},
)
Related
I've been updating a Flutter app and replaced a FlatButton with the new TextButton. But now the button doesn't display on the Card. I can click it and it works, and if I long press you can see the button and it's caption.
The card widget code is below.
Card otherSwapCard(
List<FSRows?> data, int index, context, Function circularprogress) {
String? shiftDate = formatJsonDate(data[index]!.shiftDate!, 'dd/MM/yyyy');
//calculate time value string
String shiftTimes =
'${formatJsonTime24To12(data[index]!.startTime!)} - ${formatJsonTime24To12(data[index]!.finishTime!)}';
return Card(
color: Colors.white,
elevation: 3,
margin: EdgeInsets.fromLTRB(16, 4, 16, 12),
child: Container(
decoration: BoxDecoration(
border: Border(
top: BorderSide(
width: 2.0,
color: kMainColor40,
),
),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: <Widget>[
Expanded(
flex: 72,
child: Column(
children: <Widget>[
DataKeyRow(dkLabel: 'Job:', dkValue: data[index]!.jobName!),
SizedBox(height: 2),
DataKeyRow(dkLabel: 'Date:', dkValue: shiftDate!),
SizedBox(height: 2),
DataKeyRow(
dkLabel: 'Time:', dkValue: shiftTimes.toLowerCase()),
],
),
),
Expanded(
flex: 28,
child: Center(
child: TextButton(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all<Color>(Colors.blue),
),
child: Text('Fill', style: TextStyle(color: Colors.white)),
onPressed: () { },
),
),
),
],
),
),
),
);
}
Card, TextButton, and Text three are in white color. So trying changing the color of the Button or Text.
To change the TextButton color
TextButton(
onPressed: () {},
style: TextButton.styleFrom(
primary: Colors.white,
backgroundColor: Colors.black, // Background Color
),
child: const Text(
'Text Button ',
style: TextStyle(fontSize: 24),
),
)
The backgroundColor will change the TextButton background color to black and the primary will change the font color to white, you can customize it accordingly.
Both your Card color and TextButton Text color are White, you just need to change one of them.
I copied your code and change the color and everything went fine.
Card(
color: Colors.white,
TextButton(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all<Color>(Colors.blue),
),
child: Text('Fill', style: TextStyle(color: Colors.**white**)),
onPressed: () { },
),
Card and TextButton both are in white color , so try changing your code.
Change
child: Text('Fill', style: TextStyle(color: Colors.white)),
to
child: Text('Fill', style: TextStyle(color: Colors.black)),
I have an alert popup using rflutter_alert, that contains a text widget (and Ok button). The text is wrapped in a SingleChildScrollView to scroll the text vertically.
This works with no issues when in debug mode - either with the emulator or on my android phone. But the release version after being approved on Google Play, does not work. The text area is one long grey box with no text. Images as follows.
My other rflutter_alerts (without a scrollable view) work fine in release mode.
Is there a user permission required for release for scrolling views? Or some other difference between test and release?
// Alert to display roster message
_onAlertShowRosterNotes(context, String rosterMsg) {
var alertStyle = AlertStyle(
isCloseButton: false,
);
Alert(
context: context,
style: alertStyle,
title: 'Roster Message',
content: Column(
children: <Widget>[
Container(
margin: const EdgeInsets.fromLTRB(0.0, 15.0, 0.0, 0.0),
padding: const EdgeInsets.fromLTRB(6.0, 3.0, 6.0, 3.0),
height: 280.0,
width: 230,
decoration: BoxDecoration(
border: Border.all(
color: kMainColor,
width: 0.5,
),
),
child: Expanded(
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Text(rosterMsg,
style: TextStyle(
color: kBodyText,
fontWeight: FontWeight.normal,
fontSize: 16.0,
),
),
),
),
),
],
),
buttons: [
DialogButton(
child: Text('OK', style: TextStyle(color: Colors.white, fontSize: 20)),
color: kMainColor,
onPressed: () {
Navigator.pop(context, false);
},
),
],
).show();
}
The problem was caused by the Expanded widget. Once I removed this, the problem went away.
I like the typer / typewriter class in animated_text_kit but I want to know whether it is possible for the new characters / letters to come in with a fade effect..
This is what I'm trying to achieve:
https://imgur.com/a/t41tG20
Here is what I've currently done, I can type each text by itself but how can i make it fade evrytime a new letter comes out..
Container(
color: Colors.purple,
width: 250.0,
height: 250,
child: DefaultTextStyle(
style: const TextStyle(
color: Colors.black,
fontSize: 32.0,
fontWeight: FontWeight.bold,
),
child: AnimatedTextKit(
animatedTexts: [
TyperAnimatedText(
'It is not enough to do your best,',
speed: Duration(milliseconds: 200),
),
],
onTap: () {
print("Tap Event");
},
),
),
)
I have an elevated button in Flutter, generally the button works fine.
However, the setting of the primary: Colors.red in this example does not work, the button is transparent for some reason... All the other params of the ElevatedButton.styleFrom() are working as expected.
Any assistance would be appreciated!
Widget _btnGood() {
return SizedBox(
width: MediaQuery.of(context).size.width * 0.8,
child: ElevatedButton(
onPressed: null,
style: ElevatedButton.styleFrom(
primary: Colors.purple,
side: const BorderSide(width: 8.0, color: Colors.white),
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(32)),
padding: const EdgeInsets.all(25),
),
child: const Text(
"Im Feeling Good",
style: TextStyle(
color: Colors.white,
fontSize: 30,
),
),
),
);
}
Example of Button
Simply change on pressed to-
on_pressed: (){} instead of null.
I'm trying to implement a button that calls another page when it is tapped.
I'm wrapping a container with the inkWell widget that has a splash color effect and the onTap (){}.
The button shows the splash color effect with the onTap (){} empty however when I add a Navigator.push.. to call another page, the splash color effect disappears.
Any idea about how to solve this?
This is the code
Padding(
padding: const EdgeInsets.only(top: 11),
child: Material(
color: Colors.white,
child: InkWell(
splashColor: Colors.grey,
onTap: () {
Navigator.push(
context,
PageTransition(
type: PageTransitionType.downToUp,
duration: Duration(milliseconds: 200),
child: ProfileProduct(
imageUrl: widget.reviews.imageUrl,
cost: widget.reviews.cost,
name: widget.reviews.userName,
address: widget.reviews.address,
brand: widget.reviews.brand,
productName: widget.reviews.productName,
userImage: widget.reviews.userImage,
currentUserId: widget.reviews.authorId,
cSrateStars: widget.reviews.cSrateStars,
easyPurchaseRateStars:
widget.reviews.easyPurchaseRateStars,
envioDiasRateStars: widget.reviews.envioDiasRateStars,
totalRate: widget.reviews.totalRate,
recomendation: widget.reviews.recomendation,
businessName: widget.reviews.businessName,
fecha: widget.reviews.timestamp,
videoLink: widget.reviews.videoLink,
),
),
);
},
child: Container(
// margin: EdgeInsets.only(top: 10),
height: 280,
width: 190,
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 10, top: 2),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
CircleAvatar(
radius: 12.0,
backgroundColor: Colors.grey,
backgroundImage: widget
.reviews.userImage.isEmpty
? AssetImage(
'assets/images/user_placeholder.jpg')
: CachedNetworkImageProvider(
widget.reviews.userImage),
),
SizedBox(width: 0.0),
Text(
widget.reviews.userName,
style: TextStyle(
fontSize: 15, fontWeight: FontWeight.w700),
),
IconButton(
// alignment: Alignment.topLeft,
icon: _isLiked
? Icon(
Icons.favorite,
color: Colors.red,
)
: Icon(Icons.favorite_border),
iconSize: 15.0,
onPressed: _likePost,
),
],
),
),
AutoSizeText(
widget.reviews.productName,
maxLines: 4,
style: TextStyle(color: Colors.blue, fontSize: 20),
),
SizedBox(height: 3.0),
RatingStars(widget: widget),
SizedBox(height: 8.0),
AutoSizeText(
'$costos',
maxLines: 4,
style: TextStyle(color: Colors.grey),
),
SizedBox(height: 3.0),
Padding(
padding: const EdgeInsets.only(left: 15, right: 15),
child: AutoSizeText(
widget.reviews.comments,
maxLines: 3,
style: TextStyle(color: Colors.grey),
),
),
// SizedBox(height: 3.0),
AutoSizeText(
'See More...',
maxLines: 4,
style: TextStyle(color: Colors.blue),
),
Text(
'${_likeCount.toString()} likes',
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
),
),
],
),
),
),
),
),
I was in the same problem and realised the "NewPage()" loads before the Inkwell splash is shown. I did a small hack by delaying the Navigator.push by 300 milliseconds. It seems to work.
InkWell(
splashColor: Colors.grey,
onTap: () {
Future.delayed(const Duration(milliseconds: 300), () {
Navigator.push(
context, MaterialPageRoute(builder: (context) => NextPage()));
});
},
child:Somewidget,
)
The InkWell widget must have a Material widget as an ancestor. The Material widget is where the ink reactions are actually painted. This matches the material design premise wherein the Material is what is actually reacting to touches by spreading ink.
The ink splashes aren't visible!
If there is an opaque graphic, e.g. painted using a Container, Image, or DecoratedBox, between the Material widget and the InkWell widget, then the splash won't be visible because it will be under the opaque graphic. This is because ink splashes draw on the underlying Material itself, as if the ink was spreading inside the material.
The Ink widget can be used as a replacement for Image, Container, or DecoratedBox to ensure that the image or decoration also paints in the Material itself, below the ink.
editing you widget as per description above
Material(
child: InkWell(
onTap: () {
print("tapped me");
},
splashColor: Colors.grey,....
You must have an onTap: in the inkwell else the splash will not appear even after wrapping it with material