10 Flutter wrap图片组件

Wrap组件

1.属性

在这里插入图片描述

direction:方向

runSpacing:direction为横向,则为行间距,direction为纵向,则为列间距

runAlignment:主轴方向内容位置,

wrap:几乎等价于Android中FlowLayout

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) { 
    return MaterialApp(
        home: Scaffold(
        appBar: AppBar(title: Text('FlutterDemo')),
        body: LayoutDemo(),
      ));
  }
}
class LayoutDemo extends StatelessWidget {
 @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      height: 600,
      width: 400,
      color: Colors.pink,
      margin: EdgeInsets.fromLTRB(10, 30, 5, 0),
      padding: EdgeInsets.all(10),
      child: Wrap(
          spacing:10,
          runSpacing: 10,
          direction: Axis.vertical,
          alignment:WrapAlignment.spaceEvenly,
          // runAlignment: WrapAlignment.center,
          runAlignment: WrapAlignment.end,
          children: <Widget>[
                MyButton("第1章"),
                MyButton("第2章"),
                MyButton("第3章"),
                MyButton("第4章"),
                MyButton("第5章"),
                MyButton("第6章"),
                MyButton("第7章"),
                MyButton("第8章"),
                MyButton("第9章"),
                MyButton("第10章"),
                MyButton("第11章"),
                 MyButton("第3章"),
                MyButton("第4章"),
                MyButton("第5章"),
                MyButton("第6章"),
                MyButton("第7章"),
                MyButton("第8章"),
                MyButton("第9章"),
                MyButton("第10章"),
                MyButton("第11章"),
          ],
        ),
    );
  }
}

class MyButton extends StatelessWidget{
  final String text;
  const MyButton(this.text,{Key key}) : super(key: key); 
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return RaisedButton(
      child: Text(this.text),
      textColor:Theme.of(context).accentColor,
      onPressed: (){        
      }
    );
  }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值