Last active
December 20, 2021 20:22
-
-
Save Jahidul007/69f750416e03992acee2d56c4d093a8c to your computer and use it in GitHub Desktop.
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
import 'package:flutter/material.dart'; | |
class MerchantSilverAppbar extends StatefulWidget { | |
const MerchantSilverAppbar({Key key}) : super(key: key); | |
@override | |
_MerchantSilverAppbarState createState() => _MerchantSilverAppbarState(); | |
} | |
class _MerchantSilverAppbarState extends State<MerchantSilverAppbar> { | |
@override | |
Widget build(BuildContext context) { | |
return SafeArea( | |
child: Scaffold( | |
body: DefaultTabController( | |
length: 2, | |
child: NestedScrollView( | |
headerSliverBuilder: | |
(BuildContext context, bool innerBoxIsScrolled) { | |
return <Widget>[ | |
SliverAppBar( | |
expandedHeight: 200, | |
floating: false, | |
pinned: true, | |
snap: false, | |
flexibleSpace: FlexibleSpaceBar( | |
background: Stack( | |
children: [ | |
Container( | |
height: 200, | |
width: double.infinity, | |
decoration: BoxDecoration( | |
image: DecorationImage( | |
image: AssetImage('assets/images/test.jpg'), | |
fit: BoxFit.fill, | |
), | |
), | |
), | |
Positioned(top: 10, right: 10, child: Icon(Icons.search)), | |
Align( | |
alignment: Alignment.bottomCenter, | |
child: Container( | |
height: 70, | |
child: Row( | |
mainAxisAlignment: MainAxisAlignment.spaceEvenly, | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: [ | |
Icon(Icons.home,size: 80,), | |
Column( | |
crossAxisAlignment: CrossAxisAlignment.center, | |
children: [Text("Name"), SizedBox(height: 10,), Text("Follow")], | |
), | |
Column( | |
crossAxisAlignment: CrossAxisAlignment.center, | |
children: [Text("4.7"), SizedBox(height: 10,),Text("4.8")], | |
), | |
Icon(Icons.question_answer_sharp,size: 80,), | |
], | |
), | |
)), | |
], | |
), | |
), | |
), | |
SliverPersistentHeader( | |
delegate: _SliverAppBarDelegate( | |
TabBar( | |
labelColor: Colors.black87, | |
unselectedLabelColor: Colors.grey, | |
tabs: [ | |
Tab(icon: Icon(Icons.info), text: "Tab 1"), | |
Tab(icon: Icon(Icons.lightbulb_outline), text: "Tab 2"), | |
], | |
), | |
), | |
pinned: true, | |
), | |
]; | |
}, | |
body: Center( | |
child: Text("Sample text"), | |
), | |
), | |
), | |
), | |
); | |
} | |
} | |
class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { | |
_SliverAppBarDelegate(this._tabBar); | |
final TabBar _tabBar; | |
@override | |
double get minExtent => _tabBar.preferredSize.height; | |
@override | |
double get maxExtent => _tabBar.preferredSize.height; | |
@override | |
Widget build( | |
BuildContext context, double shrinkOffset, bool overlapsContent) { | |
return new Container( | |
child: _tabBar, | |
); | |
} | |
@override | |
bool shouldRebuild(_SliverAppBarDelegate oldDelegate) { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment