Sliver App Bar In Flutter

 Sliver App Bar In Flutter



UserInterface:



Code:

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';


void main() => runApp(
MaterialApp(
title: "Sliver App bar",
debugShowCheckedModeBanner: false,
home: sliver_appbar(),
),
);

class sliver_appbar extends StatelessWidget {
//const sl({Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: [
SliverAppBar(
backgroundColor: Colors.greenAccent,
expandedHeight: 200,
title: Text('Flexible App Bar'),
centerTitle: true,
floating: true,
pinned: true,
leading: Icon(Icons.arrow_back),
actions: [
Icon(Icons.settings),
SizedBox(width: 12),
],
flexibleSpace: FlexibleSpaceBar(
background: Image.network(
'https://images.unsplash.com/photo-1629732676198-fe5cd0933cfd?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=346&q=80',
fit: BoxFit.cover),
),
),
SliverToBoxAdapter(
child: GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
),
primary: false,
shrinkWrap: true,
itemCount: 20,
itemBuilder: (Context, index) => Container(
child: Image.network(
'https://images.unsplash.com/photo-1494145904049-0dca59b4bbad?ixid=MnwxMjA3fDB8MHxzZWFyY2h8OHx8YnVpbGRpbmdzfGVufDB8fDB8fA%3D%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60',
fit: BoxFit.cover),
),
),
),
],
),
);
}
}



Comments