Last active
January 4, 2023 19:39
-
-
Save jlamimoso/ee37eecdda61d3ab4ea502e4451840a7 to your computer and use it in GitHub Desktop.
Flutter Full screen app with transparent color in system status bar and system navigation bar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ignore: file_names | |
import 'dart:io'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter/services.dart'; | |
void main() { | |
WidgetsFlutterBinding.ensureInitialized(); | |
if (Platform.isAndroid) { | |
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); | |
SystemChrome.setSystemUIOverlayStyle( | |
SystemUiOverlayStyle( | |
systemNavigationBarColor: Colors.transparent.withOpacity(0.002), | |
systemNavigationBarIconBrightness: Brightness.light, | |
statusBarColor: Colors.transparent.withOpacity(0.002), | |
statusBarIconBrightness: Brightness.light, | |
), | |
); | |
} | |
runApp(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return const MaterialApp( | |
// Remove the debug banner | |
debugShowCheckedModeBanner: false, | |
title: 'Kindacode.com', | |
home: HomePage(), | |
); | |
} | |
} | |
class HomePage extends StatelessWidget { | |
const HomePage({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
decoration: const BoxDecoration( | |
gradient: LinearGradient( | |
begin: Alignment.topLeft, | |
end: Alignment.bottomRight, | |
colors: [Colors.purple, Colors.orange])), | |
child: Scaffold( | |
appBar: AppBar( | |
backgroundColor: Colors.transparent, | |
title: const Text('Test'), | |
centerTitle: true, | |
elevation: 0, | |
), | |
// By defaut, Scaffold background is white | |
// Set its value to transparent | |
backgroundColor: Colors.transparent, | |
body: Center( | |
child: Container( | |
width: 200, | |
height: 200, | |
color: Colors.white, | |
), | |
)), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment