Render a ripple over the whole surface of a Card - dart

Is it possible to have a ripple rendered over the whole surface of a Card?
InkWell with a child Card renders the ripple behind the Card; Card itself doesn't have an onTap handler...
So, how to get that ripple?

Put the InkWell inside the Card.

Put this simple code
Card(
child: InkWell(
onTap: () {},
),

Related

Flutter - How to add two Text Widgets in a Column with the 2nd one overflowing vertically after filling the spaces horizontally?

I made a Chat app, I made two Text widgets inside a Column widget, now I want to make the Chat message (the 2nd text Widget) Text Widget to go Vertically after filling the spaces horizontally, so what can I do, this is the image of the Chat screen
and What happens is this(image), the images are embedded because I'm a new user
The Code of it is this:-
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
/// USER NAME
Text(userName, style: Theme.of(context).textTheme.subtitle),
/// CHAT MESSAGE
Container(
margin: const EdgeInsets.only(top: 5.0),
child: Text(
theText,
maxLines: null,
style: Theme.of(context).textTheme.body2,
),
),
],
),
I expected the Code to work like the traditional Chat app's messages, the First text widget (USERNAME) worked but the 2nd one (the actual CHAT MESSAGE) didn't work as it Overflows by pixels, So how can I fix this and Make it like the traditional Chat Messages??
I resolved the problem! And here it is:
I just wrapped my whole Column widget with a Flexible widget and it resolved my problem and now I can add Multiline Messages!
I'm keeping the post as to any Newbie facing the same problem 'may' find this useful...

How to disable splashColor only for TextField in flutter?

I am trying to disable ripple effect on a TextField.
splashColor: Colors.transparent removes ripple effect on others widgets as well.
I want to remove ripple effect only on TextField.
Try this way, you only need to add Theme to your TextField
Theme(
data: Theme.of(context).copyWith(splashColor: Colors.transparent),
child: TextField(),
),

Status bar color when navigating to new screen

I am using following in my build() method of 1st screen to change status bar color and it works fine.
// 1st screen's build() method
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarColor: Colors.green),
);
However when I navigate to 2nd screen the 1st screen status bar color appears on the 2nd screen too. And in 2nd screen's build() method, I am using the same code with different color
// 2nd screen's build() method
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarColor: Colors.red),
);
I had a similar problem and found the solution. The best way is to use AnnotatedRegion under Scaffold without AppBar (appBar is null) instead of the function SystemChrome.setSystemUIOverlayStyle() to set the system ui color.
Something like:
Scaffold(
body: AnnotatedRegion(
value: SystemUiOverlayStyle(statusBarColor: Colors.red)
child: MyBodyWidget(),
),
);
Btw, the value can be SystemUiOverlayStyle.dark or SystemUiOverlayStyle.light if you only want dark or light overlay instead of a color. Note that statusBarColor only works in Android so far.
Also note that appBar has to be null (absent) for AnnotatedRegion to work. You can write your own MyAppBar widget easily inside MyBodyWidget.
Try setting the 2nd status bar color before doing the Navigator.push to the second screen. Like this
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarColor: Colors.red),
);
await Navigator.of(context).push(MaterialPageRoute(
builder: (context) => SecondScreen();
));
From Flutter Docs
Call this API in code whose lifecycle matches that of the desired system UI styles. For instance, to change the system UI style on a new page, consider calling when pushing/popping a new PageRoute.
It has a simple solution.
It is one way of several method.(AnnotatedRegion)
First, top parent page buildcontext in Saffold
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.transparent, <---- transparent.
and 2nd page of 3rd page ...
if Appbar : Appbar( backgroundcolor: Colors.red <---- want color.
if no Appbar : Scaffold( backgroundcolor: Colors.red <---- want color.
This way, if you do a navigation pop, Page status color return the background color of Appbar or the background color of the scaffold.
It's my shortcut and I hope it helps.

How to transform child widgets in flutter?

I want animate widgets like the below gif
But whats happening is like the below gif
I just added a color to the container to get a sense of the frame of parent container
How can we make the inner widgets to clip when moving out of parent widget?
I am using Transform to animate like projects.
Please let me know if any more info is required.
If you want your red container to clip overflow, you have to wrap it into a ClipRect.
new ClipRect(
child: new Container(color: Colors.red, child: myAnimationThing),
),

Flutter floating action button in a CustomScrollView

Is there any way to include a Floating Action Button in a screen consisting of a CustomScrollView with a SliverAppBar and a SliverList?
I want to be able to have the default behaviour of a sliver list with a FAB fixed on the screen.
Is it possible?
You can still use the Scaffold when you're using the SliverAppBar such as:
new Scaffold(
body: new CustomScrollView(
slivers: <Widget>[
new SliverAppBar(...),
...
],
),
floatingActionButton: new FloatingActionButton(...),
);
Otherwise, you can generally use a Stack above the CustomScrollView and the FloatingActionButton (in a Positioned) as well.

Resources