国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁 > news >正文

國內(nèi)html5視頻網(wǎng)站建設(shè)網(wǎng)站分析培訓(xùn)班

國內(nèi)html5視頻網(wǎng)站建設(shè),網(wǎng)站分析培訓(xùn)班,vp(永久免費(fèi))加速器下載,2W網(wǎng)站建設(shè)的作用大家好,我是 17。 在上篇文章 使用 Flutter Button 介紹了如何修改 button 的樣式,本文來具體實(shí)踐一下。 本文列舉一些常用的 button 效果,以便在用到的時(shí)候方便使用。因?yàn)?ElevatedButton 最常用,所以大多以 ElevatedButton 舉…

在這里插入圖片描述
大家好,我是 17。

在上篇文章 使用 Flutter Button 介紹了如何修改 button 的樣式,本文來具體實(shí)踐一下。

本文列舉一些常用的 button 效果,以便在用到的時(shí)候方便使用。因?yàn)?ElevatedButton 最常用,所以大多以 ElevatedButton 舉例。

ElevatedButton 一般是用做主 button 的。之所以叫 ElevatedButton 是因?yàn)榘聪碌臅r(shí)候會(huì)有 elevation 變大的效果。

去掉水波效果

ElevatedButton(child: Text('IAM17'),style: ButtonStyle(splashFactory: NoSplash.splashFactory),onPressed: () {},)

監(jiān)聽狀態(tài)變化

class _MyWidgetState extends State<MyWidget> {late MaterialStatesController controller;void initState() {controller = MaterialStatesController();controller.addListener(() {print(controller.value);});super.initState();}void dispose() {controller.dispose();super.dispose();}Widget build(BuildContext context) {return ElevatedButton(statesController: controller,onPressed: () {},child: Text('IAM17'),);}
}

比如當(dāng)按住按鈕的時(shí)候,會(huì)輸出 {MaterialState.pressed},當(dāng)松開按鈕的時(shí)候會(huì)輸出{}。被禁用的時(shí)候輸出{MaterialState.disabled}

shape 動(dòng)畫,size 和 文字樣式

class _MyWidgetState extends State<MyWidget> {var elevation = 10.0;OutlinedBorder shape = CircleBorder();void initState() {super.initState();}void dispose() {super.dispose();}Widget build(BuildContext context) {return ElevatedButton(clipBehavior: Clip.hardEdge,style: ElevatedButton.styleFrom(fixedSize: Size(100, 100),textStyle:TextStyle(fontSize: 20),shape: shape,animationDuration: Duration(milliseconds: 600),elevation: elevation),onPressed: () {setState(() {elevation = elevation == 10 ? 20 : 10;shape =shape is CircleBorder ? RoundedRectangleBorder(borderRadius:BorderRadius.circular(10)) : CircleBorder();});},child: Text('IAM17'),);}
}

animationDuration 可以為 elevation 和 shape 提供動(dòng)畫支持。本例中,按鈕從圓形和矩形之間不斷變換,除了 shape 變化,elevation(投影)也會(huì)隨著變化。

默認(rèn)情況下 clip.none。如果按鈕的文字過長會(huì)溢出。設(shè)置 clip.hardEdget 防止溢出。

fixedSize 設(shè)置按鈕的大小,當(dāng)然了,會(huì)受到最大最小值和父級(jí)的約束影響。

文字樣式寫在 style 的 textStyle ,不要去 child 的 Text 那里寫。

foregroundColor、backgroundColor 和 overlayColor

ElevatedButton.styleFrom(splashFactory: NoSplash.splashFactory,foregroundColor: Colors.amber,backgroundColor:Colors.green,) 

foregroundColor 是文字的顏色。別去 child 的 Text 設(shè)置文字顏色了。

backgroundColor 是背景色。

當(dāng)按下按鈕的時(shí)候顯示的是 overlayColor,一般是一個(gè)半透明的,覆蓋在 backgroundColor 上面,child 的下面。styleFrom 是不能設(shè)置 overlayColor 的。overlayColor 直接取 foregroundColor 并設(shè)置好的透明度,一般情況下我們不需要單獨(dú)設(shè)置。單獨(dú)設(shè)置 overlayColor 可以用 ButtonStyle。

ButtonStyle(splashFactory: NoSplash.splashFactory,foregroundColor: MaterialStateProperty.all<Color>(Colors.amber),backgroundColor: MaterialStateProperty.all<Color>(Colors.green),overlayColor: MaterialStateProperty.all<Color>(Colors.pink),)

ButtonStyle 設(shè)置的 overlayColor 是不會(huì)自動(dòng)加上透明效果,如果要透明,需要自己加透明效果。比如Color.fromRGBO(0, 0, 0, .2)。

disabled color

ElevatedButton(style:ElevatedButton.styleFrom(disabledBackgroundColor: Colors.grey,disabledForegroundColor:Colors.black54),onPressed: null,child: Text('IAM17'),)

按鈕 disabled 后,按下去不會(huì)有反應(yīng)了。只需要設(shè)置好 disabledBackgroundColor 和 disabledForegroundColor 即可,overlayColor 不需要設(shè)置了。

給按鈕加邊框

style:ElevatedButton.styleFrom(side: BorderSide()),

圓形

加邊框很簡單,side 屬性就可以辦到。和shape 配合可以做出各種形狀的 border,比如圓形 border。

style:ElevatedButton.styleFrom(shape: CircleBorder(),fixedSize: Size(80,80),side: BorderSide(color: Colors.red,width: 4,strokeAlign: StrokeAlign.inside)

strokeAlign 參數(shù)表示border 是畫在shape 的外部,內(nèi)部還是中間。如果 clipBehavior不為 Clip.none, 那么最好設(shè)置為 StrokeAlign.inside

還有幾種 shape 也一起介紹下吧。其實(shí)這些 shape 先有個(gè)印象即可,知道有這些 shape 可以用。

BeveledRectangle

style:ElevatedButton.styleFrom(shape: BeveledRectangleBorder(borderRadius: BorderRadius.circular(20)),fixedSize: Size(120,80),side: BorderSide(color: Colors.red,width: 4))

ContinuousRectangle

style:ElevatedButton.styleFrom(shape: ContinuousRectangleBorder( borderRadius: BorderRadius.circular(40)),fixedSize: Size(120,80),side: BorderSide(color: Colors.red,width: 4))

RoundedRectangle

style:ElevatedButton.styleFrom(shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)),fixedSize: Size(80,80),side: BorderSide(color: Colors.red,width: 4),

如果把 30 改變?yōu)?40 就變成圓形了。

stadium

style:ElevatedButton.styleFrom(shape: StadiumBorder(),fixedSize: Size(120,80),side: BorderSide(color: Colors.red,width: 4),

stadium 的中文含意是 體育場,我們看形狀也還真挺像的。

不知道你注意到?jīng)]有 和 Text 的樣式一樣,side 也可以寫在 各種 border 里面。但我們寫的時(shí)候,最好都寫在外面的 side 參數(shù)那里。

OutlineButton

OutlineButton 自帶邊框,沒有背景色,沒有 elevation。通常不作為主操作按鈕。

帶 icon 的 button

ElevatedButton.icon(onPressed: () {}, icon: Icon(Icons.account_box), label: Text('IAM17'));

Flutter 這里還是很貼心的,為我們準(zhǔn)備了 icon 命名構(gòu)造函數(shù)。 OulineButton,TextButton也都有 icon 的構(gòu)造函數(shù)。其實(shí)內(nèi)部實(shí)現(xiàn)就是用了一個(gè) Row。

如果只有一個(gè) icon,那么可以用 IconButton 了。

漸變背景 button

ClipRRect(borderRadius: BorderRadius.circular(4),child: Stack(children: <Widget>[Positioned.fill(child: Container(decoration: const BoxDecoration(gradient: LinearGradient(colors: <Color>[Color(0xFF0D47A1),Color(0xFF1976D2),Color(0xFF42A5F5),],),),),),TextButton(style: TextButton.styleFrom(foregroundColor: Colors.white,padding: const EdgeInsets.all(16.0),textStyle: const TextStyle(fontSize: 20),),onPressed: () {},child: const Text('IAM17'),),],),)

由于背景色只能用 Color ,所以要做出一個(gè)漸變背景色的 button 還是很麻煩的,需要疊加才行。最后還得用 ClipRRect 剪裁成圓角。

http://aloenet.com.cn/news/39380.html

相關(guān)文章:

  • 做個(gè)簡單網(wǎng)站大概多少錢中文搜索引擎有哪些平臺(tái)
  • 制作網(wǎng)站和制作網(wǎng)頁的分別免費(fèi)獎(jiǎng)勵(lì)自己的網(wǎng)站
  • 公家網(wǎng)站模板百度代運(yùn)營
  • 做服務(wù)員哪個(gè)網(wǎng)站靠譜營業(yè)推廣策劃方案
  • 制作網(wǎng)站圖片磁力屋torrentkitty
  • 廈門旅游網(wǎng)站設(shè)計(jì)湖南seo優(yōu)化
  • 北京外貿(mào)網(wǎng)站建設(shè)公司怎么在百度發(fā)廣告
  • 免費(fèi)做明信片的網(wǎng)站新區(qū)快速seo排名
  • 小型企業(yè)網(wǎng)站的設(shè)計(jì)與實(shí)現(xiàn)搜索引擎營銷的典型案例
  • 免費(fèi)網(wǎng)站建設(shè)步驟百度收錄權(quán)重
  • 網(wǎng)站投票系統(tǒng) js產(chǎn)品推廣方案范文500字
  • 惠州做網(wǎng)站的公司百度指數(shù)怎么看排名
  • 建設(shè)一個(gè)怎樣的自己的網(wǎng)站首頁鄭州粒米seo顧問
  • 建設(shè)電影網(wǎng)站廣告哪里找搜索引擎推廣法
  • 做app+的模板下載網(wǎng)站短視頻精準(zhǔn)獲客
  • 武漢網(wǎng)站制2023年8月份新冠
  • 佛山新網(wǎng)站制作咨詢東莞全網(wǎng)推廣
  • 深圳做網(wǎng)站的公司搜行者seo如何制作微信小程序店鋪
  • 公司網(wǎng)站 開源深圳seo專家
  • 供應(yīng)鏈管理軟件十大排名seo顧問培訓(xùn)
  • 網(wǎng)站管理員登錄哪有學(xué)電腦培訓(xùn)班
  • 蘇州個(gè)人網(wǎng)站建設(shè)信息推廣的方式有哪些
  • 做一個(gè)wordpress模板關(guān)鍵詞首頁排名優(yōu)化平臺(tái)
  • 西安有什么網(wǎng)站網(wǎng)絡(luò)輿情監(jiān)測中心
  • 建站的步驟有哪些杭州網(wǎng)站
  • php網(wǎng)站開發(fā)代碼東莞做網(wǎng)站最好的是哪家
  • 邯鄲網(wǎng)站制作多少錢蘇州網(wǎng)站建設(shè)制作公司
  • 貴州省城鄉(xiāng)和建設(shè)廳網(wǎng)站seo優(yōu)化的作用
  • 游戲網(wǎng)站風(fēng)格dz論壇seo
  • 阿里云 做購物網(wǎng)站網(wǎng)站seo是什么平臺(tái)