Advertisement
IvanBlue

Flutter transparent AppBar

Jul 1st, 2018
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.87 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. void main() => runApp(new MyApp());
  4.  
  5. class MyApp extends StatelessWidget {
  6.   @override
  7.   Widget build(BuildContext context) {
  8.     return new MaterialApp(
  9.       title: 'Transparent AppBar',
  10.       debugShowCheckedModeBanner: false,
  11.       theme: new ThemeData(
  12.         primarySwatch: Colors.blue,
  13.       ),
  14.       home: new MyHomePage(),
  15.     );
  16.   }
  17. }
  18.  
  19. class MyHomePage extends StatefulWidget {
  20.   @override
  21.   _MyHomePageState createState() => new _MyHomePageState();
  22. }
  23.  
  24. class _MyHomePageState extends State<MyHomePage> {
  25.  
  26.   @override
  27.   Widget build(BuildContext context) {
  28.     return Scaffold(
  29.       body: Stack(
  30.         children: <Widget>[
  31.           Container(
  32.             //color: Colors.orange,
  33.             decoration: BoxDecoration(
  34.               image: DecorationImage(
  35.                 // Replace this image with an image you have... and don't forget to declare it in pubspec.yaml
  36.                 image: AssetImage("assets/evan-kirby-226482-unsplash.jpg"),
  37.                 fit: BoxFit.cover,
  38.               ),
  39.             ),
  40.             child: Center(
  41.               child: Text("Hello World!\nwith transparent AppBar...", style: TextStyle(fontSize: 18.0, color: Colors.white))
  42.             ),
  43.           ),
  44.           AppBar(
  45.             backgroundColor: Colors.transparent,
  46.             elevation: 0.0,
  47.             leading: IconButton(
  48.               icon: Icon(
  49.                 Icons.arrow_back_ios,
  50.               ),
  51.               color: Colors.white,
  52.               onPressed: () {},
  53.             ),
  54.             title: Text("Transparent AppBar"),
  55.             actions: <Widget>[
  56.               IconButton(
  57.                 icon: Icon(
  58.                   Icons.menu,
  59.                 ),
  60.                 color: Colors.white,
  61.                 onPressed: () {},
  62.               ),
  63.             ],
  64.           )
  65.         ]
  66.       )
  67.     );
  68.   }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement