Ad
A Hole In Bottom Nav Bar With A Fab Inside It - Flutter
With flutter, how can I create a hole inside the bottom nav bar and put the fab inside it, something like the image below
I have tried wrapping the fab with padding, increase the top padding to move it down and increase the notch margin but the bottom nav bar did not look like I want.
FAb code:
Padding(
padding: const EdgeInsets.only(top: 90),
child: FloatingActionButton(...)
)
bottom nav bar code:
BottomAppBar(
elevation: 0,
color: Colors.transparent,
shape: const CircularNotchedRectangle(),
clipBehavior: Clip.antiAlias,
notchMargin: 50.0,
child: SizedBox(...)
)
Here is how I want it to look like
Ad
Answer
I am using Stack to draw on UI. play with widget's size, position, and color.
Run on dartPad
bottomNavigationBar: LayoutBuilder(
builder: (context, constraints) => SizedBox(
width: constraints.maxWidth,
height: kToolbarHeight,
child: Stack(
children: [
Positioned.fill(
child: Container(
color: Colors.white,
),
),
/// middle fab
Positioned(
bottom: -20,
top: -20,
left: 0,
right: 0,
child: Container(
height: kToolbarHeight * 1.5,
width: kToolbarHeight * 1.5,
decoration: BoxDecoration(
color: Theme.of(context).scaffoldBackgroundColor,
// Colors.deepPurple,
shape: BoxShape.circle,
),
),
),
Align(
alignment: Alignment.center,
child: Container(
width: kToolbarHeight * .8,
height: kToolbarHeight * .8,
alignment: Alignment.center,
decoration: const BoxDecoration(
color: Colors.amber,
shape: BoxShape.circle,
),
child: const Text("A"),
),
)
],
),
),
),
Ad
source: stackoverflow.com
Related Questions
- → How do you create a 12 or 24 mnemonics code for multiple cryptocurrencies (ETH, BTC and so on..)
- → Flutter: input text field don't work properly in a simple example..... where am I wrong?
- → Can I customize the code formatting of Dart code in Atom?
- → Is it possible to develop iOS apps with Flutter on a Linux virtual machine?
- → Display SnackBar in Flutter
- → JSON ObjectMapper in Flutter
- → Material flutter app source code
- → TabBarSelection No such method error
- → How do I set the animation color of a LinearProgressIndicator?
- → Add different routes/screens to Flutter app
- → Is there a way to get the size of an existing widget?
- → How to share a file using flutter
- → Is there an easy way to find particular text built from RichText in a Flutter test?
Ad