美文网首页
15.横向类别

15.横向类别

作者: 冰点雨 | 来源:发表于2019-12-24 17:33 被阅读0次
dbbb088c0116ae0e4a4e132059b1817.png

小标签

Widget _rightInkWell(String item){
    return InkWell(
      onTap: (){

      },
      child: Container(
        padding: EdgeInsets.fromLTRB(5.0, 10.0, 5.0, 10.0),
        child: Text(
          item,
          style: TextStyle(
              fontSize:ScreenUtil().setSp(28)
          ),
        ),
      ),

    );
  }

横向标签

 child: Container(
        height: ScreenUtil().setHeight(80),
        width: ScreenUtil().setWidth(570),
        decoration: BoxDecoration(
          color: Colors.white,
          border: Border(
            bottom: BorderSide(
              width: 1,
              color: Colors.black12
            )
          )
        ),
        child: ListView.builder(
          scrollDirection: Axis.horizontal,
          itemCount: list.length,
            itemBuilder: (context,index){
            return _rightInkWell(list[index]);
            },
        ),
      ),
    );

所有代码

import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_shop/service/service_method.dart';
import '../model/category.dart';


class CategoryPage extends StatefulWidget {
  _CategoryPageState createState() => _CategoryPageState();
}

class _CategoryPageState extends State<CategoryPage> {

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('分类页面'),
      ),
        body: Container(
          child: Row(
            children: <Widget>[
              LeftCategoryNav(),
              Column(
                children: <Widget>[
                  RightCategoryNav(),
                ],
              )
            ],
          ),
        )
    );
  }
}




//左侧分类列表
class LeftCategoryNav extends StatefulWidget {

  LeftCategoryNavState createState() => new LeftCategoryNavState();
}

class LeftCategoryNavState extends State<LeftCategoryNav> {

  List list = [];

  @override
  void initState() {
    _getCategory();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      width: ScreenUtil().setWidth(180),
      decoration: BoxDecoration(
        border: Border(
          right: BorderSide(
            width: 1,
            color: Colors.black12
          )
        )
      ),
      child: ListView.builder(
//        itemCount: list.length,
          itemCount: 20,
          itemBuilder: (context, index) {
            return _leftInWel(index);
          }
      ),
    );
  }


  Widget _leftInWel(int index){
    return InkWell(
      onTap: (){},
      child: Container(
        height: ScreenUtil().setHeight(100),
        padding: EdgeInsets.only(left: 10,top: 20),
        decoration: BoxDecoration(
          color: Colors.white,
          border: Border(
            bottom: BorderSide(
              width: 1,
              color: Colors.black12,
            )
          )
        ),
        child: Text(
//         list[index].mallCategoryName,
          '分类名称',
          style: TextStyle(
            fontSize: ScreenUtil().setSp(28),
          ),
        ),

      ),
    );
  }



  void _getCategory()async{
    await request('getCategory').then((val){
      var data = json.decode(val.toString());
      CategoryModel category = CategoryModel.fromJson(data);
      setState(() {
        list = category.data;
      });
    });
  }




}



//右侧小类类别
class RightCategoryNav extends StatefulWidget {
  @override
  RightCategoryNavState createState() => new RightCategoryNavState();
}

class RightCategoryNavState extends State<RightCategoryNav> {

  List list = ['名酒','宝丰','北京二锅头','名酒','宝丰','北京二锅头','名酒','宝丰','北京二锅头'];
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Container(
        height: ScreenUtil().setHeight(80),
        width: ScreenUtil().setWidth(570),
        decoration: BoxDecoration(
          color: Colors.white,
          border: Border(
            bottom: BorderSide(
              width: 1,
              color: Colors.black12
            )
          )
        ),
        child: ListView.builder(
          scrollDirection: Axis.horizontal,
          itemCount: list.length,
            itemBuilder: (context,index){
            return _rightInkWell(list[index]);
            },
        ),
      ),
    );
  }



  Widget _rightInkWell(String item){
    return InkWell(
      onTap: (){

      },
      child: Container(
        padding: EdgeInsets.fromLTRB(5.0, 10.0, 5.0, 10.0),
        child: Text(
          item,
          style: TextStyle(
              fontSize:ScreenUtil().setSp(28)
          ),
        ),
      ),

    );
  }
}

相关文章

  • 15.横向类别

    小标签 横向标签 所有代码

  • 3.5Describe Image-表格题

    Skills: 以一个方向来找(横向或者纵向) 找极值(最大)或者(最小) 找相差最大的或者最小的 总结段写总类别...

  • 任务型

    心得体会 细心: 是否选择忠实于原文的最佳答案。 小心: 是否注意其横向、纵向的类别规律,同栏表达要有一致...

  • 4.19曹全隶书练习解读15

    15.金字旁

  • 【LeetCode通关全记录】15. 三数之和

    【LeetCode通关全记录】15. 三数之和 题目地址:15. 三数之和[https://leetcode-cn...

  • 2018-03-05

    15.版区.模特.库房.抽屉

  • 15.复活 试译艾米莉·狄金森诗选第二部分爱

    15. RESURRECTION 'T was a long parting,but the time ...

  • 类别

    俗话说物以类聚,人以群分。但是在同类里也有不同的地方,正所谓世界上没有两片完全相同的树叶。我们也没有必要去苛求别人...

  • 类别

    1、西安王玲,西溪印象城,娄谦之、静安府等,对自己内心的许多不自信不善沟通的反思,别人的建议等,梳理。 2、对世界...

  • 类别

    作用 1.将类的实现分散到多个不同文件或多个不同框架中 2.创建对私有方法的前向引用 3.向对象添加非正式协议 局...

网友评论

      本文标题:15.横向类别

      本文链接:https://www.haomeiwen.com/subject/bsufoctx.html