Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:stretchy_header/stretchy_header.dart';
- class StretchyHeaderTest extends StatefulWidget {
- @override
- _StretchyHeaderTestState createState() => _StretchyHeaderTestState();
- }
- class _StretchyHeaderTestState extends State<StretchyHeaderTest> {
- int selectedAmount = 0;
- void selectAmount(int amount) {
- selectedAmount = amount;
- }
- List<Widget> getAmountWidgetsList() {
- List<Widget> list = new List();
- for (int i = 1; i < 8; i++) {
- var selected = (selectedAmount == i);
- var amountWidget = Padding(
- padding: EdgeInsets.symmetric(horizontal: 15.0, vertical: 22.5),
- child: Material(
- color: selected ? Colors.grey[100] : Colors.white,
- borderRadius: BorderRadius.circular(10.0),
- elevation: selected ? 15.0 : 3.0,
- child: new InkWell(
- borderRadius: BorderRadius.circular(10.0),
- onTap: () {
- setState(() {
- selectAmount(i);
- });
- },
- child: Padding(
- padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 20.0),
- child: Column(
- children: <Widget>[
- Text("Size x$i",
- style: TextStyle(fontSize: 15.0)),
- SizedBox(height: 5.0),
- Text("really cute",
- style: TextStyle(
- fontSize: 12.5,
- color: Colors.grey,
- //fontStyle: FontStyle.italic
- )),
- SizedBox(height: 5.0),
- Text("${i * 75}\$",
- style: TextStyle(fontSize: 20.0)),
- ],
- ),
- ),
- ),
- ),
- );
- list.add(amountWidget);
- }
- return list;
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(title: Text("Teddy Bear")),
- body: Container(
- child: StretchyHeader.singleChild(
- headerData: HeaderData(
- headerHeight: 250,
- header: Image(
- image: NetworkImage("https://www.o2lifestyle.es/wp-content/uploads/2016/07/osito-ted.jpg"),
- fit: BoxFit.cover),
- blurContent: false,
- blurColor: Color.fromRGBO(255, 255, 255, 0.1)),
- child: Column(
- children: <Widget>[
- SizedBox(
- height: 15,
- ),
- Text(
- "Teddy Bear",
- style: TextStyle(fontSize: 45),
- ),
- SingleChildScrollView(
- controller: ScrollController(keepScrollOffset: false),
- scrollDirection: Axis.horizontal,
- child: Padding(
- padding: const EdgeInsets.only(
- bottom: 15.0, left: 7.0, right: 7.0),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceEvenly,
- children: getAmountWidgetsList(),
- ),
- ),
- ),
- SizedBox(height: 15),
- RaisedButton(
- child: Text("Add to cart"),
- onPressed: () {},
- ),
- SizedBox(height: 15),
- ],
- ),
- ),
- )
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement