Resize Icon every second using GestureDetector's onLongPressStart - flutter

This problem is pretty much very similar to messenger's icons. As long as you press that icon, the larger it gets.
This would be fun for others to use soon!
I'm new to flutter but if someone has an idea on how to implement this, I'm very much willing to help.

You can use a ScaleTransition widget that accept animation value
_controller = AnimationController(duration: const Duration(milliseconds: 2000), vsync: this, value: 0.1);
_animation = CurvedAnimation(parent: _controller, curve: Curves.bounceInOut);
ScaleTransition(
scale: _animation,
alignment: Alignment.center,
child: child
)
and in your longPress just call
_controller.forward();

Related

Callback for when an AnimatedFoo widget has finished animating

I was wondering if there is a way to know once an AnimatedFoo widget has completed the animation? I'm currently using AnimatedSize and am trying to find a way to call a function once it has completed. I initially also created an AnimatedController but it doesn't look like it's accepting any controllers.
AnimatedSize(
duration: const Duration(milliseconds: 500),
curve: Curves.bounceOut,
child: Container(...),
),

How I can change curve animation for snackbar in flutter?

Help me!
I need to change the default snackbar animation in flutter. And I need to change the curve animation when the snackbar appears.
I want to change the standard animation to Curves.easeOutBack.
I tried to use animation property of Snackbar but nothing happened. And
I tried to use Snackbar().withAnimation(_curve) but also nothing happened.
Use the package called another_flushbar
Flushbar(
animationDuration: const Duration(seconds: 2),
forwardAnimationCurve: Curves.easeIn, // 👈 Here you change the curve animation
reverseAnimationCurve: Curves.easeOut,// 👈 Here you change the curve animation
duration: const Duration(milliseconds: 3000),
flushbarPosition: FlushbarPosition.BOTTOM,
flushbarStyle: FlushbarStyle.FLOATING,
message: "I am Bottom Snackbar",
margin: const EdgeInsets.symmetric(vertical: 20),
).show(context);

Flutter web - scroll down but horizontal

the effect I want to achieve is that the user scrolls sideways when the user uses the gesture to scroll down. Something like on this page.
ListView does not work with gestures - but it does work with a mouse, but that doesn't solve the problem when the user is using gestures, e.g. on a laptop.
Does anyone have an idea how to handle it?
I did not find any dedicated functionality in some widget, but here is my workaround:
final scrollController = ScrollController();
Listener(
onPointerSignal: (pointerSignal) {
if (pointerSignal is PointerScrollEvent) {
scrollController.animateTo(
scrollController.offset + pointerSignal.scrollDelta.dy,
curve: Curves.decelerate,
duration: const Duration(milliseconds: 200),
);
}
},
child: SingleChildScrollView( // or any other
controller: scrollController,
child: ...,
),
)

Animate in and out a widget when some data changes in flutter

I have a widget that is displaying data, which changes over time, i'd like for that old data to fade out, then fade in new data when its available (passed in by the parent).
How can i achieve this?
I think this might help u:
AnimatedOpacity(
opacity: _visible ? 1.0 : 0.0,
duration: Duration(milliseconds: 500),
child: Text('Hello World!),
);

ScrollController not scrolling to bottom of content

Using a ScrollController and TextFormField FocusNode to scrollController.animateTo scrollController.position.maxSCrollExtent I cannot achieve displaying my "submit" button at the bottom of the view when the keyboard displays to for entry into the TextFormField above my "submit" button.
Note I have tried with resizeToAvoidBottomInset set to true and false.
My SingleChildScrollView code snippet
ScrollConfiguration(
behavior: ScrollBehaviorHideSplash(),
child: SingleChildScrollView(
controller: _scrollController,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[...widgets
My my FocusNode on focus function:
void _scrollToBottom() {
print('scrollToBottom');
_scrollController.animateTo(
_scrollController.position.maxScrollExtent,
curve: Curves.easeOut,
duration: const Duration(milliseconds: 750),
);
}
I have also tried _scrollController.position.maxScrollExtent + 400.0 just in case.
Content display with having resizeToAvoidBottomInset: true:
Where I would like the ScrollController to scroll to but have to currently manually scroll to see the button:
Try this:
Timer(Duration(milliseconds: 100), () {
_scrollController.animateTo(
_scrollController.position.maxScrollExtent,
curve: Curves.easeOut,
duration: const Duration(milliseconds: 750),
);
});
A little bit hacky but adding Timer before scroll animation solved my problem, i guess listview needs some time to add new item.
In my case I had a SingleChildScrollView and a ListView.separated inside of it, I passed the scroll controller to the inner listview instead of the parent scroll view (the max scroll ), the height of the view was changing based on the appearance of the keyboard so waiting time was required.
Future.delayed(
Duration(milliseconds: 200),
() {
scrollController.animateTo(
scrollController.position.maxScrollExtent,
duration: Duration(milliseconds: 400),
curve: Curves.ease,
);
},
);