getx icon indicating copy to clipboard operation
getx copied to clipboard

Snackbar above bottomNavBar

Open paulsam1016 opened this issue 1 year ago • 4 comments

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

paulsam1016 avatar Mar 26 '23 12:03 paulsam1016

@paulsam1016

I am also facing the same issue.

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

Thanks

deepss1 avatar Aug 18 '23 05:08 deepss1

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

Thanks in advance :-)

sbarth avatar Sep 18 '23 12:09 sbarth

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.

jonataslaw avatar Sep 18 '23 15:09 jonataslaw

is there any update on this issue?

AdamHavlicek avatar Jan 19 '24 11:01 AdamHavlicek