dwyl / flutter-wysiwyg-editor-tutorial

📱📝 How to do WYSIWYG editing in Flutter in 5 easy steps. 🚀
GNU General Public License v2.0
6 stars 0 forks source link

chore: Using `CustomButton` in place of `ImageButton` #12

Closed LuchoTurtle closed 1 year ago

LuchoTurtle commented 1 year ago

For additional context, please see https://github.com/dwyl/app/pull/341#issuecomment-1747752793.

The ImageButton from flutter_quill has different behaviour when the app is accessed from a mobile app or a web browser. It uses kIsWeb to check if the platform is web-based or not - see https://github.com/singerdmx/flutter-quill/blob/8cb14b8155219a94c612467df79206ff09b9b386/flutter_quill_extensions/lib/embeds/toolbar/media_button.dart#L120.

Unfortunately, this makes it impossible to widget/integration/unit test web embeds and reduces the code coverage because there's no apparent way of overriding this variable during tests.

However, I believe we can work around this problem by having a CustomButton that does the exact same thing an ImageButton does.