亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Flutter 系統(tǒng)是如何實(shí)現(xiàn)ExpansionPanelList的示例代碼

 更新時間:2020年05月08日 09:01:46   作者:老孟Flutter  
Flutter組件有一個很大的特色,那就是很多復(fù)雜的組件都是通過一個一個小組件拼裝而成的,今天就來說說系統(tǒng)的ExpansionPanelList是如何實(shí)現(xiàn)的,需要的朋友可以參考下

在了解ExpansionPanelList實(shí)現(xiàn)前,先來了解下MergeableMaterial,它展示多個MergeableMaterialItem組件,當(dāng)子組件發(fā)生變化時,以動畫的方式打開或者關(guān)閉子組件,MergeableMaterial的父控件需要在主軸方向是一個沒有限制的控件,比如SingleChildScrollView、Row、Column等。

基本用法如下:

SingleChildScrollView(
 child: MergeableMaterial(
 children: [
  MaterialSlice(
   key: ValueKey(1),
   child: Container(
   height: 45,
   color: Colors.primaries[1 % Colors.primaries.length],
   )),
  MaterialGap(key: ValueKey(2)),
  MaterialSlice(
   key: ValueKey(3),
   child: Container(
   height: 45,
   color: Colors.primaries[1 % Colors.primaries.length],
   )),
  MaterialGap(key: ValueKey(4)),
  MaterialSlice(
   key: ValueKey(5),
   child: Container(
   height: 45,
   color: Colors.primaries[1 % Colors.primaries.length],
   )),
 ],
 ),
)

效果如下:

MergeableMaterial的子控件只能是MaterialSlice和MaterialGap,MaterialSlice是帶子控件的控件,顯示實(shí)際內(nèi)容,MaterialGap用于分割,只能放在MaterialSlice中間。

靜態(tài)情況下,看不出具體的效果,動態(tài)改變子組件用法如下:

List<MergeableMaterialItem> items = [];
List.generate(_count, (index) {
 items.add(MaterialSlice(
  key: ValueKey(index * 2),
  child: Container(
  height: 45,
  color: Colors.primaries[index % Colors.primaries.length],
  )));
});

return SingleChildScrollView(
 child: MergeableMaterial(
 children: items,
 ),
)

效果如下:

主要看增加/刪除子組件時的動畫效果。

增加分割線和陰影:

MergeableMaterial(
 hasDividers: true,
 elevation: 24,
 children: items,
)

效果如下:

陰影值不能隨便設(shè)置,只能設(shè)置如下值:1, 2, 3, 4, 6, 8, 9, 12, 16, 24

此控件可以實(shí)現(xiàn)什么樣的效果呢?看下面效果:

實(shí)現(xiàn)代碼:

bool _expand = false;

@override
Widget build(BuildContext context) {
 return Column(
 children: <Widget>[
  Container(
  height: 45,
  color: Colors.green.withOpacity(.3),
  alignment: Alignment.centerRight,
  child: IconButton(
   icon: Icon(Icons.arrow_drop_down),
   onPressed: () {
   setState(() {
    _expand = !_expand;
   });
   },
  ),
  ),
  _expand
   ? MergeableMaterial(
    hasDividers: true,
    elevation: 24,
    children: [
    MaterialSlice(
     key: ValueKey(1),
     child: Container(
      height: 200,
      color: Colors.green.withOpacity(.3),
     ))
    ],
   )
   : Container(),
  Container(
  height: 45,
  color: Colors.red.withOpacity(.3),
  ),
 ],
 );
}

看到這個效果是否想到了ExpansionPanelList呢?系統(tǒng)控件ExpansionPanelList就是使用此控件實(shí)現(xiàn)的。

交流

Flutter博客地址(近200個控件用法):http://laomengit.com

總結(jié)

到此這篇關(guān)于Flutter 系統(tǒng)是如何實(shí)現(xiàn)ExpansionPanelList的示例代碼的文章就介紹到這了,更多相關(guān)Flutter 實(shí)現(xiàn)ExpansionPanelList內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Android實(shí)現(xiàn)關(guān)機(jī)與重啟的幾種方式(推薦)

    Android實(shí)現(xiàn)關(guān)機(jī)與重啟的幾種方式(推薦)

    這篇文章主要介紹了Android實(shí)現(xiàn)關(guān)機(jī)與重啟的幾種方式(推薦)的相關(guān)資料,非常不錯,具有參考借鑒價(jià)值,需要的朋友可以參考下
    2016-07-07
  • Android實(shí)現(xiàn)瘋狂連連看游戲之狀態(tài)數(shù)據(jù)模型(三)

    Android實(shí)現(xiàn)瘋狂連連看游戲之狀態(tài)數(shù)據(jù)模型(三)

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)瘋狂連連看游戲之狀態(tài)數(shù)據(jù)模型,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-03-03
  • Kotlin fun函數(shù)使用方法

    Kotlin fun函數(shù)使用方法

    函數(shù)是執(zhí)行特定任務(wù)的一組相互關(guān)聯(lián)的代碼塊。函數(shù)用于將程序分解為不同的子模塊。它使代碼可重用,并使程序更易于管理,這篇文章主要介紹了Kotlin fun函數(shù)使用方法
    2022-12-12
  • AndroidView與Compose框架交互實(shí)現(xiàn)介紹

    AndroidView與Compose框架交互實(shí)現(xiàn)介紹

    Android Compose自推出正式版本后,google 就一直推薦使用Compose來開發(fā)。正好疫情期間,作為一個 Android 摸魚達(dá)人,就來摸索一下Compose的開發(fā)。說實(shí)話開發(fā)了2天感覺對Android 開發(fā)人員來說變化是巨大的,但是作為從業(yè)者我們還必須學(xué)習(xí)和學(xué)會,才能不被甩開
    2022-09-09
  • android @override 報(bào)錯解決方案

    android @override 報(bào)錯解決方案

    android @override 報(bào)錯:就是說Java 1.5的編譯器默認(rèn)對父類的方法進(jìn)行覆蓋,采用@Override進(jìn)行說明;但1.6已經(jīng)擴(kuò)展到對接口的方法;所以如果還是以Java 1.5的編譯器來編譯的話,會出現(xiàn)錯誤
    2012-12-12
  • Android畫圖實(shí)現(xiàn)MPAndroidchart折線圖示例詳解

    Android畫圖實(shí)現(xiàn)MPAndroidchart折線圖示例詳解

    這篇文章主要為大家介紹了Android畫圖實(shí)現(xiàn)MPAndroidchart折線圖示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-07-07
  • android?sharedUserId?使用知識盲點(diǎn)解析

    android?sharedUserId?使用知識盲點(diǎn)解析

    這篇文章主要為大家介紹了android?sharedUserId使用的知識盲點(diǎn)解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-02-02
  • RecyclerView的使用之HelloWorld

    RecyclerView的使用之HelloWorld

    RecyclerView是伴隨Android 5.0發(fā)布的新控件,是一種列表容器,Google意在用新的RecyclerView來取代老舊的ListView和GridView,它的使用靈活性和性能都要優(yōu)于ListView,通過本文給大家介紹RecyclerView的使用之HelloWorld,需要的朋友參考下
    2016-03-03
  • Android實(shí)現(xiàn)異步加載圖片

    Android實(shí)現(xiàn)異步加載圖片

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)異步加載圖片的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • Android切換前后臺點(diǎn)擊通知進(jìn)入當(dāng)前頁面

    Android切換前后臺點(diǎn)擊通知進(jìn)入當(dāng)前頁面

    這篇文章主要介紹了Android切換前后臺點(diǎn)擊通知進(jìn)入當(dāng)前頁面,主要講述當(dāng)App退出到后臺的后,怎么點(diǎn)擊通知回到原來按下HOME鍵之前的前臺頁面,需要的朋友可以參考下
    2023-03-03

最新評論