I'm currently playing around with flutter by recreating the google files app. I followed some tutorials and stuff but are now stuck at a problem I can't find a solution for. I want the bottomNavigationBar
to extend behind the systemNavigationBar
which I made transparent.
The left image is my flutter app, the right one is the real deal.
Here's the code for that so far:
void main() {
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
systemNavigationBarColor: Colors.transparent));
runApp(const Main());
}
class Main extends StatelessWidget {
const Main({Key? key}) : super(key: key);
static const _brandColor = Colors.blue;
@override
Widget build(BuildContext context) {
// Wrap MaterialApp with a DynamicColorBuilder.
return DynamicColorBuilder(
builder: (ColorScheme? lightDynamic, ColorScheme? darkDynamic) {
ColorScheme lightColorScheme;
ColorScheme darkColorScheme;
if (lightDynamic != null && darkDynamic != null) {
lightColorScheme = lightDynamic.harmonized();
darkColorScheme = darkDynamic.harmonized();
} else {
lightColorScheme = ColorScheme.fromSeed(
seedColor: _brandColor,
);
darkColorScheme = ColorScheme.fromSeed(
seedColor: _brandColor,
brightness: Brightness.dark,
);
}
return MaterialApp(
theme: ThemeData(
colorScheme: lightColorScheme,
useMaterial3: true,
),
darkTheme: ThemeData(
colorScheme: darkColorScheme,
useMaterial3: true,
),
home: const RootPage(),
debugShowCheckedModeBanner: false,
);
},
);
}
}
class RootPage extends StatefulWidget {
const RootPage({Key? key}) : super(key: key);
@override
State<RootPage> createState() => _RootPageState();
}
class _RootPageState extends State<RootPage> {
int currentPage = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Title'),
),
body: const HomePage(),
floatingActionButton: FloatingActionButton(
onPressed: () {
debugPrint("Button pressed");
},
child: const Icon(Icons.add),
),
bottomNavigationBar: NavigationBar(
destinations: const [
NavigationDestination(icon: Icon(Icons.home_filled), label: "Start"),
NavigationDestination(
icon: Icon(Icons.star_outline), label: "Markiert"),
NavigationDestination(
icon: Icon(Icons.people_alt_outlined), label: "Freigegeben"),
NavigationDestination(
icon: Icon(Icons.folder_open_outlined), label: "Dateien"),
],
onDestinationSelected: (int i) {
setState(() {
currentPage = i;
});
},
selectedIndex: currentPage,
),
);
}
}