前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >flutter-样式

flutter-样式

原创
作者头像
易寒
发布2022-01-13 20:04:34
3810
发布2022-01-13 20:04:34
举报
文章被收录于专栏:Android知识
代码语言:txt
复制
//  服务页item
Widget _buildGridService() {
  return Scaffold(
      appBar: AppBar(
        elevation: 8.0, //阴影的高度
        title: Text('便民服务'),
        backgroundColor: MyColors.color_red,
        centerTitle: true, //标题是否居中,默认为false
      ),
      body: Center(
          child: GridView.extent(
        //禁止滚动
        physics: new NeverScrollableScrollPhysics(),
        //横轴的最大长度
        maxCrossAxisExtent: 150.0,
        padding: const EdgeInsets.all(5.0),
        //主轴间隔 纵轴
        mainAxisSpacing: 1.0,
        //横轴间隔 次轴
        crossAxisSpacing: 4.0,
        semanticChildCount: 3,
        children: _buildGridTileList(serviceList),
      )));
}
代码语言:txt
复制
List<Container> _buildGridTileList(List<MyService> list) {
  return new List.generate(
      list.length,
      (int index) => new Container(
            child: new GestureDetector(
              onTap: () {
                print("---点击了:" + serviceList[index].text);
                Navigator.push(
                    context,
                    new MaterialPageRoute(
                        builder: (context) => new ServiceWebPage(
                            from: serviceList[index].text)));
              },
              child: Column(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  Image.asset(
                    list[index].iconImage,
                    width: 50.0,
                    height: 50.0,
                    fit: BoxFit.fill,
                  ),
                  new Container(
                    padding: EdgeInsets.only(top: 5.0),
                    child: new Text(
                      list[index].text,
                      style: new TextStyle(
                        fontSize: 14.0,
                      ),
                    ),
                  )
                ],
              ),
            ),
          ));
}

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档