Flutter: stack between widgets inside different classes

Viewed 36

I have 2 classes: a camera class and a bottom bar class. I would like the camera button to overlap the bottom bar. (see example).

The problem is that these are 2 different classes. So an option would be:

Stack(children: [
      CameraClass(),
      BottomBarClass(),
      CameraButton(),
    ],);

But the camera button uses a lot of class variables and member functions (for animation etc), so this wouldn't be an efficient option & good practice for clean code.

Is there a different option?

Thanks

enter image description here

1 Answers

You can also do this using FloatingActionButtonLocation and Expanded widget like this:

Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
      ),
      body: _buildTodoList(),
      floatingActionButton: new FloatingActionButton(
        onPressed: _pushAddTodoScreen,
        tooltip: 'Increment',
        child: new Icon(Icons.add),
        elevation: 4.0,
      ),
      bottomNavigationBar: BottomAppBar(
        child: new Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Expanded(child: IconButton(icon: Icon(Icons.home)),),
            Expanded(child: IconButton(icon: Icon(Icons.show_chart)),),
            Expanded(child: new Text('')),
            Expanded(child: IconButton(icon: Icon(Icons.tab)),),
            Expanded(child: IconButton(icon: Icon(Icons.settings)),),
          ],
        ),
      ),
      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
    );
  }

enter image description here

Related