Reputation: 181
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))
],
),
Upvotes: 5
Views: 5019
Reputation: 618
You can have specific width or padding in the parent of open container instead
Padding(
padding: EdgeInsets.symmetric(horizontal: 8.w),
child: OpenContainer(...)
)
Upvotes: 0
Reputation: 2355
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
Upvotes: 2