Use Flutter Swiper to fade-out text in different area - flutter

How can I combine a swiper action with a fade-in/fade-out action in another area of the screen?
My screen is divided into two halves: The Top is a text widget and the bottom is a swiper widget with two pages. My goal is to fade-out the text in the top half when I swipe to the second page in the bottom half.
I'm using this dependency for the swiper widget in the bottom half: https://pub.dev/packages/flutter_swiper

I solved it by using GestureDetector widget and updated the opacity via the state.
The GestureDetector needed two functions: onDragUpdate and onDragEnd. Both changed the state of the progress which is also used to update the opacity in the other half.
Quite some work for such a small interaction, however, it works.

Related

How to scale down a widget to display an overview in a grid view?

In my Flutter app, the user can create and edit multiple pages that are displayed in a PageView. The user can see one page at a time. Now I want to show an overview of all pages by shrinking the widgets and showing them in a Wrap layout widget.
I've tried this with the Transform.scale widget, but this keeps the original size of the page and just displays the child widget at a lower scale.Therefore this does not bring the desired effect in a wrap layout.

Disable PageView scrolling in Card widget

Imagine, that you have two pages - pages A and B.
Of course, you can switch between pages by clicking on the tab bar or swipe (left to right or right to left).
On page A, there are multiple Card widgets, one of them contains charts.TimeSeriesChart.
Chart contains behaviour: charts.SlidingViewport(), charts.PanAndZoomBehavior(), nevertheless it doesn't work.
When I put physics:NeverScrollableScrollPhysics(), into PageView, charts getting scrollable feature.
Question:
I would like to allow swipe between tabs, but how to disable swipe between tabs only in this Card widget (with chart), and make sliding working in Chart?
I'm using this package: https://pub.dev/packages/charts_flutter

Flutter Sticky widget that belongs to ListView

I want to have a sticky widget similar to the floating widgets in scaffolds, difference is that this widget would belong to a ListView, when it isn't on screen it would behave as a floating widget, when user scrolls so its position be visible it would start animating to stay on its position on the ListView.
Here is a visual example of what I am trying to achieve
https://miro.medium.com/max/1200/1*GsH-kEVNtoDZaM0ZjNYRpQ.gif (the 'MY STICKY BUTTON' widget)
is this even possible in flutter ? and if so how ?
Thanks in advance!

How to disable animation at the edges of PageView?

I want users to scroll between pages in PageView, but I don't want to show them an animation when they try to scroll before first and after last page. I can switch between colorful animation, black animation and no scrolling, but I could not find any possibility to disable the animation at all.
If there is no such possibility, how can I change the color of that animation or make it transparent at least?
Based on your screenshot, I can say that you are using BouncingScrollPhysics for your PageView. This behavior is commonly used by iOS devices. Nonetheless, I have also reviewed the entire source code you have provided here.
What went wrong
You have added PageView without accompanying it with a Scaffold or Material widget at the top level that's why the background behind the children of the PageView is color black.
https://dartpad.dev/c709e410d0a68248ac5b387b3bc6af93
From the documentation:
Scaffold implements the basic material design visual layout structure.
Without this widget, you'll notice that your app may occupy the entire screen of your device, including the notification bar, because it (PageView) does not know where is the status bar is located in the screen.
What you can do
I noticed that all of the children added inside the PageView has individual Scaffold and AppBar, it's not really necessary to nest scaffolds and you may want to use TabBarView instead of PageView, and let the parent widget handle the AppBar changes via TabController.
But if you think it'll cost you too much effort to refactor, feel free to review the following options that require minimal changes which will suit your needs:
Option 1. You can wrap your widget inside a Scaffold widget.
https://dartpad.dev/4620ff91444353f5e000d2063594bd96
Option 2. Given that nesting Scaffold widgets is not a good practice, you can just use the plain Material widget to wrap your PageView with children wrapped with Scaffold widget.
https://dartpad.dev/43f8730e5592ce1f96193fc01f08a29c
These solutions will change the background color of the PageView from black to white.
Option 3. If you really want to get rid of the animation, the easiest way to hack it is changing your scroll physics:
physics: ClampingScrollPhysics(),
However, this still has a glowing or ripple effect when you try to swipe at the end of the screen.
To further get rid of this effect, I'll share with you these SO answers:
How to remove scroll glow? (works for Android)
How to remove overscroll on ios? (works for iOS)
Further reading
https://api.flutter.dev/flutter/widgets/ScrollPhysics-class.html
https://medium.com/flutter-community/custom-scroll-physics-in-flutter-3224dd9e9b41

Scrollable bottom sheet in Flutter

Can a bottomsheet be made scrollable? For example it opens initially upto a particular height and scrolls up as the content is scrolled. If yes, please help!
The DraggableScrollableSheet is here for that purpose.
This widget can be dragged along the vertical axis between its minChildSize, which defaults to 0.25 and maxChildSize, which defaults to 1.0.
You can use any Scrollable widget as child of DraggableScrollableSheet.
See the official video from Flutter team.