Created
April 29, 2019 06:36
-
-
Save JuliusNM/912bb306ae31e37dabf4ee87cbf2966c 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
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context)=> MaterialApp( | |
title: 'Nested Views', | |
theme: ThemeData( | |
brightness: Brightness.light, | |
primaryColor: Color(0xFF44318e), | |
accentColor: Color(0xFFe98074), | |
fontFamily: 'Quicksand', | |
textTheme: TextTheme( | |
headline: TextStyle( | |
fontSize: 55.0, fontWeight: FontWeight.bold, fontFamily: "Quicksand", | |
color: Color(0xFFe98074)), | |
title: TextStyle( | |
fontSize: 20.0, fontWeight: FontWeight.bold, fontFamily: "Quicksand"))), | |
home: Home() | |
); | |
} | |
class Home extends StatefulWidget { | |
Home({Key key}) : super(key: key); | |
@override | |
_HomeState createState() => _HomeState(); | |
} | |
class _HomeState extends State<Home> with TickerProviderStateMixin { | |
_HomeState({Key key}); | |
@override | |
void initState() { | |
super.initState(); | |
} | |
@override | |
void dispose() { | |
super.dispose(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
Widget _nestedView(){ | |
return NestedScrollView( | |
headerSliverBuilder: | |
(BuildContext context, bool innerBoxIsScrolled) { | |
return <Widget>[ | |
SliverAppBar( | |
backgroundColor: Colors.white, | |
expandedHeight: 400.0, | |
title: Text( | |
"Nested Scrollview", | |
), | |
floating: false, | |
pinned: true, | |
flexibleSpace: FlexibleSpaceBar( | |
collapseMode: CollapseMode.parallax, | |
centerTitle: true, | |
background: Container( | |
color: Colors.blue, | |
) | |
), | |
bottom: PreferredSize( | |
child: Padding( | |
padding: const EdgeInsets.all(2.0), | |
child: Container( | |
width: MediaQuery.of(context).size.width, | |
child: Text("My take"), | |
decoration: new BoxDecoration( | |
borderRadius: BorderRadius.all(Radius.circular(4.0)), | |
color: Colors.white70, | |
border: new Border.all(color: Colors.grey[200], | |
) | |
), | |
), | |
), | |
preferredSize: Size(double.infinity, 40.0))), | |
]; | |
}, | |
body: Container( | |
height: MediaQuery.of(context).size.height*2, | |
decoration: BoxDecoration( | |
color: Colors.grey[50], | |
borderRadius: BorderRadius.all(Radius.circular(0.0) // | |
), | |
), | |
child: ListView( | |
children: <Widget>[ | |
ListTile( | |
title: Text("Testing Scrollview"), | |
onTap: () {}, | |
), | |
Container( | |
height: 410.0, | |
child: Text("Testing Scrollview"), | |
), | |
SizedBox(height: 240.0), | |
Container( | |
height: 210.0, | |
child: Text("Testing Scrollview"), | |
), | |
], | |
), | |
), | |
); | |
} | |
return Scaffold( | |
appBar: AppBar(title: Text("Nested Views"),), | |
body: _nestedView() | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment