bot_toast icon indicating copy to clipboard operation
bot_toast copied to clipboard

Margin of The showNotification is Blocking Clickable Widget Under It

Open sed1ka opened this issue 1 year ago • 3 comments

Describe the bug The Clickable Widget can't be clicked because of the margin of the Notification/Snackbar. This issue similar like in this flutter snackbar issue

Reproduction code

import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Scaffold demo',
      home: MyHomePage(),
      debugShowCheckedModeBanner: false,
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Test'),
        centerTitle: true,
        backgroundColor: Colors.lightBlueAccent,
        actions: [
          IconButton(
            icon: const Icon(Icons.info),
            tooltip: 'Show Snackbar',
            onPressed: () {
              BotToast.showNotification(
                onlyOne: true,
                crossPage: true,
                enableKeyboardSafeArea: true,
                dismissDirections: [
                  DismissDirection.up,
                  DismissDirection.horizontal,
                ],
                duration: Duration(seconds: 6),
                backgroundColor: Colors.tealAccent,
                borderRadius: 8.0,
                margin: EdgeInsets.fromLTRB(
                  50,
                  MediaQuery.of(context).size.height * 0.75,
                  50,
                  MediaQuery.of(context).size.height * 0.15,
                ),
                title: (_) => Text('Try to tap button behind me'),
                subtitle: (_) => const Text("The clickable widget behind the margin cant be tapped"),
              );
            },
          ),
        ],
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          IconButton(
            icon: const Icon(Icons.notifications),
            tooltip: 'Press me when notif appear',
            onPressed: () {
              print('this clickable?');
            },
          ),
          ElevatedButton(
            child: Text('Open Snackbar'),
            onPressed: () {
              BotToast.showNotification(
                onlyOne: true,
                crossPage: true,
                enableKeyboardSafeArea: true,
                dismissDirections: [
                  DismissDirection.up,
                  DismissDirection.horizontal,
                ],
                duration: Duration(seconds: 6),
                backgroundColor: Colors.tealAccent,
                borderRadius: 8.0,
                margin: EdgeInsets.fromLTRB(
                    50,
                    MediaQuery.of(context).size.height * 0.75,
                    50,
                    MediaQuery.of(context).size.height * 0.15,
                ),
                title: (_) => Text('Try to tap button behind me'),
                subtitle: (_) => const Text(
                    "The clickable widget behind the margin cant be tapped"),
              );
            },
          ),
        ],
      ),
    );
  }
}

To Reproduce Steps to reproduce the behavior:

  1. Click the button Open Snackbar
  2. When notification / snackbar appear, try to click button "Open Snackbar" again or any clickable widget behind the margin area. The clickable widget can't be pressed.

Expected behavior The margin of notification / snackbar should not blocking the clickable widget

Screenshots You can check similiar screenshot/screen record in snackbar flutter issue

Flutter Version: 3.16.8

BotToast Version: 4.1.3

sed1ka avatar Jan 25 '24 07:01 sed1ka

You can temporarily use the showCustomNotification method instead of the showNotification method, and avoid using the ListTile widget, as currently using ListTile will lead to this issue.

MMMzq avatar Jan 30 '24 08:01 MMMzq

Using showCustomNotification will give the same behavior, adding a margin or padding will still block the Clickable widget under it. But I didn't try with ListTile since I have a custom widget already.

sed1ka avatar Feb 01 '24 06:02 sed1ka

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 01 '24 16:04 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 02 '24 12:06 stale[bot]