flutter控件之Material

import 'package:flutter/material.dart';
class LearnMaterial extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {
    return new _LearnMaterial();
  }
}
class _LearnMaterial extends State<LearnMaterial>{
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: new Column(
        children: <Widget>[
          new Center(
            child: new Material(
              color: Colors.blueAccent,
              shape: new BeveledRectangleBorder(//斜角矩形邊框
                side:new BorderSide(
                  width: 1.0,
                  color: Colors.blueAccent,
                  style: BorderStyle.none,
                ),
                borderRadius:new BorderRadius.circular(50.0),
              ),
              child: new Container(
                padding: EdgeInsets.all(20.0),
                child: new Text('斜角矩形邊框'),
              ),
            ),
          ),
          new Center(
            child: new Material(
              color: Colors.blueAccent,
              shape: new BeveledRectangleBorder(//斜角矩形邊框
                side:new BorderSide(
                  width: 1.0,
                  color: Colors.blueAccent,
                  style: BorderStyle.none,
                ),
                borderRadius:new BorderRadius.circular(10.0),
              ),
              child: new Container(
                padding: EdgeInsets.all(20.0),
                child: new Text('斜角矩形邊框'),
              ),
            ),
          ),
          new Center(
            child: new Material(
              color: Colors.blueAccent,
              shape:new BorderDirectional(
                start: new BorderSide(
                  color: Colors.yellow,
                  width: 10.0,
                ),
                top: new BorderSide(
                  color: Colors.deepOrange,
                  width: 10.0,
                ),
                end: new BorderSide(
                  color: Colors.black87,
                  width: 10.0,
                ),
                bottom: new BorderSide(
                  color: Colors.purpleAccent,
                  width: 10.0,
                )
              ),
              child:new Container(
                padding: EdgeInsets.all(30.0),
                child: new Text('多彩邊框'),
              ),
            ),
          ),
          new Center(
            child: new Material(
              color: Colors.blueAccent,
              shape: new CircleBorder(
                side: new BorderSide(
                  color: Colors.yellow,
                  width: 10.0,
                )
              ),
              child: new Container(
                padding: EdgeInsets.all(50.0),
                child: new Text('圓形邊框'),
              ),
            ),
          ),
          new Center(
            child: new Material(
              color: Colors.blueAccent,
              shape: new RoundedRectangleBorder(
                side: new BorderSide(
                  color: Colors.purpleAccent,
                  width: 5.0,
                ),
                borderRadius:new BorderRadius.circular(20.0), //如果[borderRadius]被指定,那么[type]屬性不能是 [MaterialType.circle]。
              ),
              child: new Container(
                padding: EdgeInsets.all(30.0),
                child: new Text('圓角矩形'),
              ),
            ),
          ),
          new Center(
            child: new Material(
              color: Colors.purpleAccent,
              elevation: 10.0,
              shadowColor: Colors.yellow,
              shape: new StadiumBorder(
                side: new BorderSide(
                  color: Colors.brown,
                  width: 5.0,
                )
              ),
              child: new Container(
                padding: EdgeInsets.all(30.0),
                child: new Text('體育場(chǎng)形狀'),
              ),
            ),
          )
        ],
      )
    );
  }
}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容