0

I am struggling making a FAB move up when a snackbar is showing. Here is my set up.

I have my main page with a bottom navigation bar with 3 items. The first item is basically a widget with a ListView and a floating action button. Once you click an item of the list view, you navigate to a details page. If you then delete the item from the details page, you come back to the main page. A snackbar then appears as a result from deleting the item. The problem I have is that the snack bar is not moving up and hides the FAB. It assumes it has something to do with context, but I don't know how. If I move the FAB to the main page, the FAB goes up but it then hides last item of the listview.

Page with list view and FAB:

 @override
 Widget build(BuildContext context) {
   return Scaffold(
    appBar: AppBar(
      centerTitle: true,
      title: Text(
        title,
        style: Theme.of(context).textTheme.titleMedium,
      ),
    ),
    body: WidgetWithListView(),
    floatingActionButton: FloatingActionButton.extended(
      onPressed: () {
        //do something
      },
      label: Text('label'),
      icon: const Icon(Icons.add),
    ));
 }

Main page:

@override
Widget build(BuildContext context) {
return Scaffold(
  appBar: AppBar(
      title: Text(appBarTitle,
          style: Theme.of(context)
              .textTheme
              .titleLarge!
              .copyWith(fontWeight: FontWeight.bold)),
      actions: <Widget>[
        IconButton(
          icon: const Icon(some icon),
          tooltip: 'some tooltip',
          onPressed: () {
            //do something;
          },
        ),
      ]),
  body: Center(
    child: getBody(_selectedIndex),
  ),
  bottomNavigationBar: BottomNavigationBar(
    items: <BottomNavigationBarItem>[
      BottomNavigationBarItem(
        icon: const Icon(someIcon),
        label: 'a label'y,
      ),
      BottomNavigationBarItem(
        icon: const Icon(someIcon),
        label: 'a label',
      ),
      BottomNavigationBarItem(
        icon: const Icon(someIcon),
        label: 'a label',
      ),
    ],
    currentIndex: _selectedIndex,
    type: BottomNavigationBarType.fixed,
    onTap: _onItemTapped,
  ),
);
}

Thanks.

DeKekem
  • 589
  • 10
  • 20

0 Answers0