Created
December 5, 2019 17:01
-
-
Save guilhermecarvalhocarneiro/67eda6c577ee1fc1871dbfd010679363 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 ExampleTwo extends StatefulWidget { | |
ExampleTwo({Key key, this.title}) : super(key: key); | |
final String title; | |
@override | |
_ExampleTwoState createState() => new _ExampleTwoState(); | |
} | |
class _ExampleTwoState extends State<ExampleTwo> { | |
@override | |
Widget build(BuildContext context) { | |
return new Scaffold( | |
body: _buildMainContent(), | |
); | |
} | |
_buildMainContent() { | |
return CustomScrollView( | |
slivers: <Widget>[ | |
SliverAppBar( | |
pinned: true, | |
leading: Container(), // Ocultando a seta de retorno para a página anterior | |
expandedHeight: 180.0, // Altura máxima do Elemento | |
flexibleSpace: FlexibleSpaceBar( | |
background: Padding( | |
padding: const EdgeInsets.only(top: 22.0), | |
child: Column( | |
children: <Widget>[ | |
Padding( | |
padding: const EdgeInsets.symmetric(horizontal: 32.0, vertical: 12.0), | |
child: Row( // Primeira linha do Head que desaparecerá conforme o Scroll | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: <Widget>[ | |
Text("Linha 1 Coluna 1"), | |
Text("Linha 1 Coluna 2"), | |
], | |
), | |
), | |
Padding( | |
padding: const EdgeInsets.symmetric(horizontal: 32.0), | |
child: Row( // Segunda linha do Head que desaparecerá conforme o Scroll | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: <Widget>[ | |
Text("Linha 2 Coluna 1"), | |
Text("Linha 2 Coluna 2"), | |
], | |
), | |
) | |
], | |
), | |
), | |
), | |
bottom: PreferredSize( // Elemento que ficará fixo | |
preferredSize: const Size.fromHeight(44.0), | |
child: Container( | |
height: 100, | |
color: Colors.white, | |
child: Padding( | |
padding: const EdgeInsets.symmetric(horizontal: 32.0), | |
child: Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: <Widget>[ | |
Text("Primeiro Item"), | |
Text("Segundo Item") | |
], | |
), | |
), | |
), | |
), | |
), | |
SliverList( // Área que comporta o ListView | |
delegate: SliverChildListDelegate([ | |
_buildListItem(), | |
_buildListItem(), | |
_buildListItem(), | |
_buildListItem(), | |
_buildListItem(), | |
_buildListItem(), | |
]), | |
) | |
], | |
); | |
} | |
Widget _buildListItem() { // Método para criar a ListView | |
return Column( | |
children: <Widget>[ | |
Padding( | |
padding: EdgeInsets.only(top: 16.0, left: 16.0, right: 16.0), | |
child: Align( // Cabeçalho de cada ListView | |
alignment: Alignment.center, | |
child: Text( | |
'List header', | |
style: Theme.of(context).textTheme.body2, | |
), | |
), | |
), | |
ListView.builder( // ListView Propriamente dito | |
padding: EdgeInsets.only(top: 8.0), | |
itemBuilder: (context, index) { | |
return Padding( | |
padding: EdgeInsets.symmetric( | |
horizontal: 16.0, | |
vertical: 8.0, | |
), | |
child: Text( | |
'Nested list item $index', | |
style: Theme.of(context).textTheme.body1, | |
), | |
); | |
}, | |
itemCount: 8, | |
shrinkWrap: true, | |
physics: ClampingScrollPhysics(), // Propriedade responsável por "ativar o Scroll na ListView" | |
), | |
], | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment