![swift share button swift share button](https://www.etonline.com/sites/default/files/styles/max_1280x720/public/images/2016-12/1280_et_taylorswift_122116.png)
On onPressed callback, we toggle the open and closed state by changing the value of isOpen to true or false inside setStateĪnimatedOpacity automatically transitions the child’s opacity over a given duration whenever the given opacity changes. Since we need to toggle the open and closed state on click, we have used IconButton widget.
![swift share button swift share button](https://i.stack.imgur.com/02bCC.jpg)
close), onPressed: () => _toggleShare(), ), crossFadeState: !isOpen ? CrossFadeState.showFirst : CrossFadeState.showSecond, ), IconButton share), onPressed: () => _toggleShare(), ), secondChild: IconButton( icon: Icon(Icons.
![swift share button swift share button](https://images.tmz.com/2019/06/24/0624-taylor-swift-cats-insta-2.jpg)
AnimatedCrossFade( duration: const Duration(milliseconds: 450), firstChild: IconButton( icon: Icon(Icons. To achieve the toggle transition, we have used AnimatedCrossFade widget. AnimatedCrossFadeĪ widget that cross-fades between two given children and animates itself between their sizes.įor open and close state of our social share widget, we need to show either a share icon or across icon button. white, shape: BoxShape.circle, ), child: AnimatedCrossFade(. Container( width: 40, margin: const EdgeInsets.only(left: 4), decoration: BoxDecoration( color: Colors. We use Container widget to add a white circular shaped container, which wraps AnimatedCrossFade widget that we’ll be discussing next. A convenience widget that combines common painting, positioning, and sizing widgets.