BilalShahid13 / PersistentBottomNavBar

A highly customizable persistent bottom navigation bar for Flutter
BSD 3-Clause "New" or "Revised" License
507 stars 368 forks source link

How could i show a global SnakBar? #318

Open AndryCU opened 1 year ago

AndryCU commented 1 year ago

I am using persistent_bottom_nav_bar: ^5.0.2, and until now keep the botton navigation bar for all the screen, but, How can i show a global snakbar? I want to generate a snakcbar in creen A, and when i swich to creen B (using botton navigation) keep it visible. Actually when i swich the snakbar dont show in the other one

  const MainUI({super.key});

  @override
  State<MainUI> createState() => _MainUIState();
}

class _MainUIState extends State<MainUI> {
  late PersistentTabController _controller;
  final screens = [
    SalesPage(), //<- I want that when i change to this one keep wathing it
    ConfigurationPage(), //<- I had inside this screen other screen and in this one is where i show my SnakcBar
  ];

  final _navBarsItems = [
    PersistentBottomNavBarItem(
      icon: const Icon(Icons.food_bank),
      title: ("Sales"),
      activeColorPrimary: CupertinoColors.white,
      inactiveColorPrimary: CupertinoColors.systemGrey,
    ),
    PersistentBottomNavBarItem(
      icon: Icon(CupertinoIcons.settings),
      title: ("Configuration"),
      activeColorPrimary: CupertinoColors.white,
      inactiveColorPrimary: CupertinoColors.systemGrey,
    ),
  ];

  @override
  void initState() {
    super.initState();
    _controller = PersistentTabController(initialIndex: 0);
  }

  @override
  Widget build(BuildContext context) {
    return PersistentTabView(
      key: scaffoldKey,
      backgroundColor: Colors.blue.shade400,
      context,
      screens: screens,
      items: _navBarsItems,
    );
  }
}
sed1ka commented 1 year ago

The behaviour also occurs on me when using another bottomNavigationBar Maybe the problem is not from this plugins