技术胖Flutter第三季-14布局RowWidget的详细讲解


flutter总的地址:

https://jspang.com/page/freeVideo.html

视频地址:

https://www.bilibili.com/video/av35800108/?p=15

博客的地址:

https://jspang.com/post/flutter3.html#toc-7f3

 

创建项目的时候有个坑,解决的方法

https://www.jianshu.com/p/147f0e20c312

使用flutter create demo03创建一个新的flutter的项目

 

 

flutter upgrade可以升级flutter的版本

 

把这个类重新打一遍:

评论说在AS里面直接打st就会出现这些了。

 

 

 

 

里面放了三个RaisedButton

 

后面还有空,这是不灵活的布局

 

还有灵活的布局

我们把RaisedButton的外城都套一个Expanded组件。RaisedButton就是它的child部分

 

三个按钮是平均分配的

 

 

如果想让按钮不平均分配 那就去掉外层套的Expanded组件就可以了。

import 'package:flutter/material.dart';

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

class  MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context){
    return MaterialApp(
      title:'Row Widget Demo',
      home:Scaffold(
        appBar: new AppBar(
          title: new Text('水平方向布局'),
        ),
        body:new Row(
          children: <Widget>[
            Expanded(child: new RaisedButton(
              onPressed: (){},
              color: Colors.redAccent,
              child:new Text('Red Button')
            ),),
            Expanded(child: new RaisedButton(
              onPressed: (){},
               color: Colors.orange,
              child:new Text('orange Button')
            ),),
            Expanded(child: new RaisedButton(
              onPressed: (){},
              color: Colors.lightBlue,
              child:new Text('Blue Button')
            ),),
          ],
        )
      )
    );
  }
}

 

转载于:https://www.cnblogs.com/wangjunwei/p/10556155.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值