Flutter Water Counter App

 


import 'package:flutter/material.dart';
import 'package:gradient_app_bar/gradient_app_bar.dart';
import 'dart:ui';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  int _increment = 0;
  void _incrementCounter() {
    setState(() {
      _increment++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: GradientAppBar(
        gradient: LinearGradient(colors: [Colors.pink, Colors.blue]),
        elevation: 10.0,
        title: Center(
          child: Padding(
            padding: const EdgeInsets.only(top: 30),
            child: Text(
              "Water Drinker Counter",
              style: TextStyle(fontSize: 25),
            ),
          ),
        ),
        bottom: PreferredSize(
          preferredSize: const Size.fromHeight(40.0),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Padding(
                padding: const EdgeInsets.only(left: 6.0, bottom: 4.0),
                child: Icon(
                  Icons.face,
                  color: Colors.white,
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(right: 6.0, bottom: 6.0),
                child: Icon(
                  Icons.tag_faces,
                  color: Colors.white,
                ),
              )
            ],
          ),
        ),
      ),
      body: Container(
        child: Stack(
          children: [
            Center(
              child: Image.network(
                  "https://cdn4.vectorstock.com/i/1000x1000/14/73/water-glass-cup-vector-22411473.jpg"),
            ),
            Container(
              margin: EdgeInsets.only(top: 140.0),
              child: Center(
                  child: Text(
                "$_increment",
                style: TextStyle(fontSize: 40.0, color: Colors.white),
              )),
            ),
            Container(
              margin: EdgeInsets.only(top: 520.0),
              color: Colors.white,
              height: 40.0,
              width: double.infinity,
            )
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          setState(() {
            _incrementCounter();
          });
        },
        child: Icon(Icons.add),
      ),
    );
  }
}