Somebody please suggest me the best package or any way to provide a screenshot taken effect in flutter. Please don't downvote.If I did anything wrong
One way to achieve the effect you are looking for is having your page in a Stack. One entry of the Stack will be your Scaffold page, and the other one will be a white Container that fills the screen space. Something like this in your page's build method:
#override
Widget build(BuildContext context) => Stack(
children: [
Container(color: Colors.white),
Scaffold(
// The rest of your page
),
],
);
Then, you can wrap your white Container in an AnimatedOpacity widget (check out this Flutter.dev article on how to animate fading widgets), and define an animation such that the white Container fades in and then fades out very quickly, achieving a flash-like effect. In the article I mentioned they also explain how to trigger such an animation programatically.
Related
In Flutter, how do you make a widget scaleable and dragable at the same time?
A GestureDetector, for some reason, behaves a little strange. For example:
return GestureDetector(
onHorizontalDragUpdate: onHorizontalScroll,
onScaleUpdate: onScale,
behavior: HitTestBehavior.opaque,
child: CustomPaint(
painter: SomeCustomPainter( /* some parameters */ ),
),
);
The above GestureDetector is placed somewhere deep down inside a SingleChildScrollView.
Problem is that onHorizontalScroll triggers most of the time when onScale is supposed to trigger.
In which case (about 9 out of 10 times) the widget doesn't scale.
The only way to reliably make the widget scalable is by removing onHorizontalDargUpate, but then it can't be dragged any more...
So the question now is, how do you make a widget dragable and scalable at the same time? Any advise is very much appreciated. Thank you.
I suggest using the Draggable widget and DragTaregt to drop it in. it is useful and better than creating draggable from scratch. check this link
Is there a way in Flutter to show a scroll indicator only on a specific widget?
For instance, I have the following widget tree
CustomScrollView(
slivers: [
sliverAppBar(),
sliverToBoxAdapter(), // horizontal list view
SliverList(delegate: SliverChildBuilderDelegate()) // show scrollbar only for this widget
],
),
Here is a demonstration of the iOS app Telegram, I have something similar in my app, notice when the header collapses a gray scroll indicator shows up.
Any idea on how to implement this behavior will be highly appreciated
You can use Scrollable List which provide you the nice way to fulfill your requirements
I am trying to create a screen like below which will allow user to show few buttons on top of another screen . So basically it will be on top of another screen which can be seen from the half transparent screen of the top level screen. Not sure how to create it and which widget to use. Can someone please guide here. I am trying to do this using flutter to create android as well as ios app.
You are looking for the stack widget here, develop your first screen and another one which you want to put on top. Put both in stack widget so one can come on top of another one.
On the screen which should be on top, make the first half of it transparent (which can be attained in different ways, one of it would be to use a Card with elevation of 0).
The most accurate answer would be do use an an showModalBottomSheet which we expand from the button into the screen and will also color the screen darker. Example code could be following:
await showModalBottomSheet<void>(
isScrollControlled: true,
context: context,
backgroundColor: Colors.white,
builder: (BuildContext context) {
return Container(width: MediaQuery.of(context).size.width, height: 200);
},
)
With the current answer you would have to write the entire funtionality for it by yourself, which could be quite unnecessary when there is already a widget out there for exactly this case
I am use Flutter for web for make website. I need make foreground scroll, but background not scroll like normal website. For example: codemagic.io .
I cannot use Scaffold background because I want use use CustomPainter for custom background.
I am try use Stack, but issue is I need Center Widgets in ScrollView, and if I do this then the CustomPainter is not start from top of page:
Stack(
children: <Widget>[
Center(
child: SingleChildScrollView(
child:
Stack(children: <Widget>[
CustomPaintWidget(),
Widgets(),
],),
Anyone know solution?
Thanks!
You have two stacks here and one is only holding one widget (basically pointless for what you want to do). Put a widget on the bottom index of that stack (0) and make it the size of its container. You could use LayoutBuilder to get the size of its parent widget. Then place the singlechildscrollview on top of that.
Let's say I have a container on one side of the screen which I want to be present at all times even during navigation through different screens.
Is there any way by which I can achieve this? If yes, how?
This is an interesting question. I can give you a solution but don't know if its the correct way to do that.
In the MaterialApp widget there is a builder parameter which gives whole screen view as a parameter and can be wrapped up by another Widget. Here is an example.
MaterialApp(
....
builder: (context, widget) {
return Stack(
children: [
_myPersistantWidget(), // you can add your widget. May be inside Positioned widget?
widget //this is the whole screen that we are wrapping in the stack
],
);
},
....
);