how can I make BottomNavigationBar stick on top of keyboard flutter

前端 未结 4 933
礼貌的吻别
礼貌的吻别 2021-02-05 08:32

I am trying to make a simple chat app, so I created a scaffold and my body, will be the messages and my bottomNavigationBar would be my typing field and sending ico

4条回答
  •  庸人自扰
    2021-02-05 08:35

    Literally just worked through the same issue. Given the code i was refactoring, this worked like a charm. Peep the github link, review his change and apply. Couldn't be much more straight forward: https://github.com/GitJournal/GitJournal/commit/f946fe487a18b2cb8cb1d488026af5c64a8f2f78..

    Content of the link above in case the link goes down:

    (-)BottomAppBar buildEditorBottonBar(
    (+)Widget buildEditorBottonBar(
      BuildContext context,
      Editor editor,
      EditorState editorState,
    BottomAppBar buildEditorBottonBar(
        folderName = "Root Folder";
      }
    
      *REPLACE* return BottomAppBar(
        elevation: 0.0,
        color: Theme.of(context).scaffoldBackgroundColor,
        child: Row(
          children: [
            FlatButton.icon(
              icon: Icon(Icons.folder),
              label: Text(folderName),
              onPressed: () {
                var note = editorState.getNote();
                editor.moveNoteToFolderSelected(note);
              },
            )
          ],
          mainAxisAlignment: MainAxisAlignment.center,
    
      *WITH THE WRAPPER* return StickyBottomAppBar(
        child: BottomAppBar(
          elevation: 0.0,
          color: Theme.of(context).scaffoldBackgroundColor,
          child: Row(
            children: [
              FlatButton.icon(
                icon: Icon(Icons.folder),
                label: Text(folderName),
                onPressed: () {
                  var note = editorState.getNote();
                  editor.moveNoteToFolderSelected(note);
                },
              )
            ],
            mainAxisAlignment: MainAxisAlignment.center,
          ),
        ),
      );
    }
    
    class StickyBottomAppBar extends StatelessWidget {
      final BottomAppBar child;
      StickyBottomAppBar({@required this.child});
    
      @override
      Widget build(BuildContext context) {
        return Transform.translate(
          offset: Offset(0.0, -1 * MediaQuery.of(context).viewInsets.bottom),
          child: child,
        );
      }
    }
    

提交回复
热议问题