OpenContainer Flutter : How to set size of open container, default it is opening in full screen

Viewed 4096

In the recent flutter release, there was new feature Open Container, here is the snippet, how to set size of the openContainer, closedbuilder is accepting and rending within its bounds, but the open builder is taking full screen size.

OpenContainer(
            openElevation: 0,
            closedElevation: 0,
            closedColor: Colors.transparent,
            transitionType: ContainerTransitionType.fadeThrough,
            openBuilder: (BuildContext context, VoidCallback _) {
              return SizedBox( height:240, 
                        width:MediaQuery.of(context).size.width
                               child:SearchWidget());
            },
            closedBuilder:
                (BuildContext context, VoidCallback openContainer) {
              return Container(
                 height: 50
                 width: 50
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    const Icon(Icons.search),
                    const Text('Search', style: TextStyle(fontSize: 12))
                  ],
                ),
1 Answers

OpenContainer – A container that grows to fill the screen to reveal new content when tapped. Similar to a Hero widget.

you cant size the openBuilder method in OpenContainer Widget.

because it transforms your little container to a full view page if you want a smaller size widget after clicking on the search button you should use animatedBuilder and make your own animation

Related