Created
January 15, 2021 06:18
-
-
Save cKreymborg/675d10a19e7437230923f779454351bc to your computer and use it in GitHub Desktop.
A Glass Morphism AppBar in Flutter
This file contains hidden or 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
import 'dart:ui'; | |
import 'package:flutter/material.dart'; | |
final Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
final List<String> listImages = [ | |
'https://images.unsplash.com/photo-1610652492500-ded49ceeb378?ixid=MXwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHwxfHx8ZW58MHx8fA%3D%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60', | |
'https://images.unsplash.com/photo-1610644914804-226806772ca4?ixid=MXwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHw0fHx8ZW58MHx8fA%3D%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60', | |
'https://images.unsplash.com/photo-1610573501789-6816396466ca?ixid=MXwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHwxNHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60', | |
'https://images.unsplash.com/photo-1610643721369-108113c23c9c?ixid=MXwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHwyMHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60', | |
'https://images.unsplash.com/photo-1610637760748-1ecb105211d8?ixid=MXwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHwyNXx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60', | |
'https://images.unsplash.com/photo-1610636913550-bb4af5250510?ixid=MXwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHw2N3x8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60', | |
'https://images.unsplash.com/photo-1610626991429-19f2fc76fa3c?ixid=MXwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHwxMDh8fHxlbnwwfHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60', | |
'https://images.unsplash.com/photo-1610602112940-3a14f7403224?ixid=MXwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHwxNDZ8fHxlbnwwfHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60', | |
'https://images.unsplash.com/photo-1610581542028-21dd9d5ce330?ixid=MXwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHwxNzB8fHxlbnwwfHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60', | |
'https://images.unsplash.com/photo-1610555423081-85ec0b8eabac?ixid=MXwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHwxODB8fHxlbnwwfHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60', | |
]; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue), | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
extendBodyBehindAppBar: true, | |
appBar: PreferredSize( | |
child: ClipRRect( | |
child: BackdropFilter( | |
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5), | |
child: AppBar( | |
backgroundColor: Colors.black.withOpacity(0.2), | |
title: Text('Glassmorphism AppBar'), | |
leading: Icon(Icons.chevron_left), | |
elevation: 0.0, | |
), | |
), | |
), | |
preferredSize: Size( | |
double.infinity, | |
56.0, | |
), | |
), | |
body: Center( | |
child: MyWidget(), | |
), | |
), | |
); | |
} | |
} | |
class MyWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return ListView.builder( | |
itemCount: listImages.length, | |
itemBuilder: (BuildContext context, int index) { | |
return ListTile( | |
leading: CircleAvatar( | |
backgroundImage: NetworkImage(listImages[index]), | |
), | |
title: Text('List item #${index + 1}'), | |
); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment