From df543d38f28b6fc7d4ebfe8f4abf017b3919b030 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Tue, 9 Nov 2021 15:54:58 +0100 Subject: [PATCH] Workaround IconButton splash animation appearing on the back Workaround for https://github.com/flutter/flutter/issues/30658 Fixes #460 --- lib/editors/bottom_bar.dart | 6 ++++-- lib/editors/markdown_toolbar.dart | 12 ++++++------ lib/forks/icon_button_more_gestures.dart | 6 +++++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/editors/bottom_bar.dart b/lib/editors/bottom_bar.dart index c28f2842..6ed96c98 100644 --- a/lib/editors/bottom_bar.dart +++ b/lib/editors/bottom_bar.dart @@ -96,7 +96,8 @@ class EditorBottomBar extends StatelessWidget { child: Row( children: [ Visibility( - child: addIcon, + // Remove Material when https://github.com/flutter/flutter/issues/30658 is fixed + child: Material(child: addIcon), visible: allowEdits, maintainSize: true, maintainAnimation: true, @@ -126,7 +127,8 @@ class EditorBottomBar extends StatelessWidget { onPressed: redoAllowed ? onRedoSelected : null, ), const Spacer(), - menuIcon, + // Remove Material when https://github.com/flutter/flutter/issues/30658 is fixed + Material(child: menuIcon), ], mainAxisAlignment: MainAxisAlignment.center, ), diff --git a/lib/editors/markdown_toolbar.dart b/lib/editors/markdown_toolbar.dart index d4b9f1e7..38642ab1 100644 --- a/lib/editors/markdown_toolbar.dart +++ b/lib/editors/markdown_toolbar.dart @@ -34,32 +34,32 @@ class MarkdownToolBar extends StatelessWidget { scrollDirection: Axis.horizontal, child: Row( children: [ - IconButton( + fork.IconButton( icon: Text('H1', style: style), padding: const EdgeInsets.all(0.0), onPressed: () => _modifyCurrentLine('# '), ), - IconButton( + fork.IconButton( icon: Text('I', style: style), padding: const EdgeInsets.all(0.0), onPressed: () => _modifyCurrentWord('*'), ), - IconButton( + fork.IconButton( icon: Text('B', style: style), padding: const EdgeInsets.all(0.0), onPressed: () => _modifyCurrentWord('**'), ), - IconButton( + fork.IconButton( icon: const FaIcon(FontAwesomeIcons.listUl), padding: const EdgeInsets.all(0.0), onPressed: () => _modifyCurrentLine('- '), ), - IconButton( + fork.IconButton( icon: const FaIcon(FontAwesomeIcons.listOl), padding: const EdgeInsets.all(0.0), onPressed: () => _modifyCurrentLine('1. '), ), - IconButton( + fork.IconButton( icon: const FaIcon(FontAwesomeIcons.tasks), padding: const EdgeInsets.all(0.0), onPressed: () => _modifyCurrentLine('- [ ] '), diff --git a/lib/forks/icon_button_more_gestures.dart b/lib/forks/icon_button_more_gestures.dart index bb8f03c4..d4c83a95 100644 --- a/lib/forks/icon_button_more_gestures.dart +++ b/lib/forks/icon_button_more_gestures.dart @@ -21,6 +21,9 @@ const double _kMinButtonSize = kMinInteractiveDimension; /// A material design icon button. /// +/// The FORK adds onLongPressed and wraps it in Material because of +/// https://github.com/flutter/flutter/issues/30658 +/// /// An icon button is a picture printed on a [Material] widget that reacts to /// touches by filling with color (ink). /// @@ -374,7 +377,7 @@ class IconButton extends StatelessWidget { ); } - return Semantics( + var sem = Semantics( button: true, enabled: onPressed != null, child: InkResponse( @@ -398,6 +401,7 @@ class IconButton extends StatelessWidget { ), ), ); + return Material(child: sem); } @override