jonataslaw / getx

Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get.
MIT License
10.1k stars 1.58k forks source link

Snackbar above bottomNavBar #2753

Open paulsam1016 opened 1 year ago

paulsam1016 commented 1 year ago

When adding a snackbar when a present bottomNavBar, causes the snackbar to show on top of the bottomNavBar.

Get.rawSnackbar(
  messageText: Text('Text'),
);

I added a margin so that the snackbar pops up above the bottomNavBar. But then the bottomNavBar is not clickable!

Get.rawSnackbar(
  messageText: Text('Text'),
  margin: const EdgeInsets.only(left: 8.0, right: 8.0, bottom: 74.0),
);

example:

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

void main() => runApp(const GetMaterialApp(home: MyApp()));

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  int _selectedIndex = 0;
  static const TextStyle optionStyle = TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
  static const List<Widget> _widgetOptions = <Widget>[
    Text(
      'Index 0: Home',
      style: optionStyle,
    ),
    Text(
      'Index 1: Business',
      style: optionStyle,
    ),
    Text(
      'Index 2: School',
      style: optionStyle,
    ),
  ];

  void _onItemTapped(int index) {
    setState(() {
      _selectedIndex = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Flutter Code Sample'),
      ),
      body: Center(
        child: _widgetOptions.elementAt(_selectedIndex),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          Get.rawSnackbar(
            messageText: const Text(
              'Text',
              style: TextStyle(color: Colors.white),
            ),
            // Uncomment for showing bottomNavigationBar
            // But bottomNavigationBar is not clickable
            // margin: const EdgeInsets.only(left: 8.0, right: 8.0, bottom: 74.0),
          );
        },
        child: const Icon(Icons.navigation),
      ),
      bottomNavigationBar: BottomNavigationBar(
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            icon: Icon(Icons.home),
            label: 'Home',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.business),
            label: 'Business',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.school),
            label: 'School',
          ),
        ],
        currentIndex: _selectedIndex,
        onTap: _onItemTapped,
      ),
    );
  }
}

To Reproduce Steps to reproduce the behaviour:

  1. Click on floatingActionButton to show snackbar
  2. snackbar is shown on bottomNavigationBar
  3. Uncomment margin (line 55 on code)
  4. Click on floatingActionButton to show snackbar
  5. Snackbar pops up above the bottomNavBar. But then the bottomNavBar is not clickable!

Expected behaviour When using the default snackbar(not getx) alongside bottomNavBar, the snackbar always pops up above the bottomNavBar.

Flutter Version: 3.7.5

Getx Version: 4.6.5

Describe on which device you found the bug: Any

deepss1 commented 11 months ago

@paulsam1016

I am also facing the same issue.

Were you able to find any workaround or a solution to this ?

Thanks

sbarth commented 10 months ago

I am having the same issue, did you find a soultion to fix this behavior?

Thanks in advance :-)

jonataslaw commented 10 months ago

I think we can add a new snackbar that mimics Flutter's default behavior (respect scaffold items). This is a good issue. I'll work on it.

AdamHavlicek commented 6 months ago

is there any update on this issue?