Category.dart 1.38 KB
Newer Older
Meghana Mahadasyam's avatar
Meghana Mahadasyam committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
import 'package:flutter/material.dart';

class Category extends StatefulWidget {
  @override
  _CategoryState createState() => _CategoryState();
}

class _CategoryState extends State<Category> {
  List<String> category = [
    'First Floor',
    'Second Floor',
    'Third Floor',
    'Fourth Floor',
    'Dashboard',
    'Fifth floor',
    'Login',
    'Sixth Floor',
    'AddLater'
  ];
  GlobalKey<ScaffoldState> _key = new GlobalKey();
  int row = 2;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: _key,
      appBar: new AppBar(
        title: new Text('Category'),
      ),
      body: new GridView.count(
        crossAxisCount: row,
        childAspectRatio: 3.0 / row,
        children: new List<Widget>.generate(
          category.length,
          (index) {
            return new GridTile(
              child: InkWell(
                child: new Card(
                  color: Colors.purple[700 - (100 * (index % 5))],
                  child: new Center(
                    child: new Text(
                      category[index],
                      style: TextStyle(fontSize: 18.0, color: Colors.white),
                    ),
                  ),
                ),
                onTap: () {
                  Navigator.pushNamed(context, '/${category[index]}');
                },
              ),
            );
          },
        ),
      ),
    );
  }
}