cate.dart 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import 'package:flutter/material.dart';
  2. import 'package:twong/config/style.dart';
  3. class CatePage extends StatefulWidget {
  4. @override
  5. State<StatefulWidget> createState() {
  6. return _CatePageState();
  7. }
  8. }
  9. class _CatePageState extends State<CatePage> {
  10. int _currentIndex = 0;
  11. List<Widget> _buildTabs () {
  12. List<Widget> list = List<Widget>();
  13. var tabs = ['10元', '20元', '50元', '99元'];
  14. for(var item in tabs) {
  15. list.add(ListTile(
  16. title: Text(item),
  17. leading: Icon(Icons.cake),
  18. onTap: () {
  19. setState(() {
  20. _currentIndex = tabs.indexOf(item);
  21. print(_currentIndex);
  22. });
  23. })
  24. );
  25. }
  26. return list;
  27. }
  28. @override
  29. Widget build(BuildContext context) {
  30. return Scaffold(
  31. appBar: PreferredSize(
  32. preferredSize: DStyle.appBarHeight,
  33. child: AppBar(
  34. centerTitle: true,
  35. title: Text('分类'),
  36. automaticallyImplyLeading: false,
  37. backgroundColor: Colors.black,
  38. actions: <Widget>[
  39. Container(
  40. padding: EdgeInsets.only(right: 20),
  41. alignment: Alignment.center,
  42. child: InkWell(
  43. child: Text("返回"),
  44. onTap: () {
  45. Navigator.pop(context);
  46. },
  47. ),
  48. ),
  49. ],
  50. ),
  51. ),
  52. body: Flex(
  53. direction: Axis.horizontal,
  54. children: <Widget>[
  55. Expanded(flex: 1, child: Container(
  56. decoration: BoxDecoration(
  57. color: Colors.white,
  58. boxShadow: [
  59. BoxShadow(
  60. offset: Offset(10, 0),
  61. color: Colors.grey,
  62. blurRadius: 1.0, //阴影模糊程度
  63. spreadRadius: 1.0 //阴影扩散程度
  64. )
  65. ]
  66. ),
  67. child: Column(
  68. children: _buildTabs()
  69. )
  70. ),),
  71. Expanded(flex: 2, child: Container(
  72. color: Color.fromRGBO(233, 233, 233, 1),
  73. ),)
  74. ],
  75. ),
  76. );
  77. }
  78. }