Ad

Flutter Bottom Container Swipe Up

- 1 answer

I'm making an app which shows place detail when clicking a place on Google Maps. I can open a container at bottom of the page but I want to do that when the user swipe this container to up with animation, the container will cover the whole page and I will get extra information about that place and show the user. How can I do that with Flutter?

Bottom Container

Ad

Answer

You can try to use the package here:

https://pub.dev/packages/sliding_up_panel

However, if this does not fullfill you wish, try this instead: Wrap you Widget with a GestureDetector and an AnimatedController:

double containerHeight = 0;
GestureDetector(
  onVerticalDragEnd: (dragUpdateDetails) {
    setState(){
       containerHeight = //device height or use MediaQuery.of(context).size.height//
    }
  },
  child: AnimatedContainer(
         duration: Duration(milliseconds: //how long should it take//), 
         height: containerHeight,
         child: //whatever you want//
   )
),

AnimatedController automatically animates between changes of properties. However, you might want to try changing onVertivalDragEnd to something else like onVerticalDragUpdate to fullfill your wish completely. If you want to have that behaviour for the full screen, wrap your first return Widget with the GestureDetector.

Ad
source: stackoverflow.com
Ad