首頁 行業(yè) 活動 項目 快訊 文娛 時尚 娛樂 科技 汽車 綜合 生活

    InkWell操作代碼怎么打?

    2020-12-23 11:30:43 來源:互聯(lián)網(wǎng)

    InkWell是什么意思?

    InkWell是Flutter提供的一個用于實現(xiàn)Material觸摸水波效果的Widget,相當(dāng)于Android里的Ripple

    使用的操作代碼怎么打?

    import 'package:flutter/material.dart';

    class LearnInkWell extends StatefulWidget{

    @override

    State createState() {

    return new _LearnInkWell();

    }

    }

    class _LearnInkWell extends State{

    @override

    Widget build(BuildContext context) {

    return new Scaffold(

    body:new Column(

    children: [

    new Center(

    child:new Material(

    child: new InkWell(

    onTap: (){

    print('###########################點擊了##################################');

    },

    child: new Container(//不要在這里設(shè)置背景色,for則會遮擋水波紋效果,如果設(shè)置的話盡量設(shè)置Material下面的color來實現(xiàn)背景色

    width: 300.0,

    height: 100.0,

    margin: EdgeInsets.all(0.0),

    ),

    ),

    color: Colors.yellow,

    ),

    ),

    new Center(

    child: new Material(

    child: new Ink(//INK可以實現(xiàn)裝飾容器,實現(xiàn)矩形 設(shè)置背景色

    color: Colors.black,

    child:new InkWell(

    onTap: (){

    print("@@@@@@@@@@@@@@@@@@@@@@@@@@@點擊了@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");

    },

    child: new Container(

    width: 300.0,

    height: 100.0,

    ),

    ),

    ),

    ),

    ),

    new Center(

    child: new Material(

    child: new Ink(//用ink圓角矩形

    // color: Colors.red,

    decoration: new BoxDecoration(

    /**

    * assert(color == null || decoration == null,'Cannot provide both a color and

    * a decoration\n'The color argument is just a shorthand

    * for "decoration: new BoxDecoration(color: color)".')

    * 在dart中使用assert 語句來中斷正常的執(zhí)行流程。

    * “不能同時”使用Ink的變量color屬性以及decoration屬性,“兩個只能存在一個”。

    */

    color: Colors.purple,

    borderRadius:new BorderRadius.all(new Radius.circular(20.0)),

    ),

    child: new InkWell(

    borderRadius:new BorderRadius.circular(20.0),//給水波紋也設(shè)置同樣的圓角

    onTap: (){

    print('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');

    },

    child: new Container(

    width: 300.0,

    height: 100.0,

    ),

    ),

    ),

    ),

    ),

    new Center(

    child: new Material(

    child:new Ink(

    decoration: new BoxDecoration(

    color: Colors.red,

    borderRadius: new BorderRadius.all(new Radius.circular(30.0)),

    ),

    child:new InkResponse(

    borderRadius: new BorderRadius.all(new Radius.circular(30.0)),

    // highlightColor: Colors.yellowAccent,//點擊或者toch控件高亮?xí)r顯示的控件在控件上層,水波紋下層

    highlightShape: BoxShape.rectangle,//點擊或者toch控件高亮的shape形狀

    //.InkResponse內(nèi)部的radius這個需要注意的是,我們需要半徑大于控件的寬,如果radius過小,顯示的水波紋就是一個很小的圓,

    radius: 300.0,//水波紋的半徑

    splashColor: Colors.black,//水波紋的顏色

    containedInkWell: true,//true表示要剪裁水波紋響應(yīng)的界面 false不剪裁 如果控件是圓角不剪裁的話水波紋是矩形

    onTap: (){

    print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');

    },

    child: new Container(//1.不能在InkResponse的child容器內(nèi)部設(shè)置裝飾器顏色,否則會遮蓋住水波紋顏色的,containedInkWell設(shè)置為false就能看到是否是遮蓋了。

    width: 300.0,

    height: 100.0,

    ),

    ),

    ),

    ),

    ),

    new Center(

    child: new Material(

    child:new Ink(

    decoration: new BoxDecoration(

    color: Colors.red,

    borderRadius: new BorderRadius.all(new Radius.circular(30.0)),

    ),

    child:new InkResponse(

    borderRadius: new BorderRadius.all(new Radius.circular(30.0)),

    highlightColor: Colors.yellowAccent,//點擊或者toch控件高亮?xí)r顯示的控件在控件上層,水波紋下層

    highlightShape: BoxShape.rectangle,//點擊或者toch控件高亮的shape形狀

    //.InkResponse內(nèi)部的radius這個需要注意的是,我們需要半徑大于控件的寬,如果radius過小,顯示的水波紋就是一個很小的圓,

    radius: 0.0,//水波紋的半徑

    // splashColor: Colors.black,//水波紋的顏色

    containedInkWell: true,//true表示要剪裁水波紋響應(yīng)的界面 false不剪裁 如果控件是圓角不剪裁的話水波紋是矩形

    onTap: (){

    print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');

    },

    child: new Container(//1.不能在InkResponse的child容器內(nèi)部設(shè)置裝飾器顏色,否則會遮蓋住水波紋顏色的,containedInkWell設(shè)置為false就能看到是否是遮蓋了。

    width: 300.0,

    height: 100.0,

    ),

    ),

    ),

    ),

    ),

    ],

    ),

    );

    }

    }

    Flutter使用InkWell無水波紋效果如何設(shè)置?

    正常情況下使用方式:

    undefined

    InkWell(

    onTap: () { },

    child: Container(

    height: 50,

    child: Text( "是速度",

    maxLines: 1,

    style: TextStyle(color: color),

    overflow: TextOverflow.ellipsis,

    ),

    ),

    )

    如果在InkWell的上下都出現(xiàn)的顏色的設(shè)置,如上中的Container中如果加入了color:Colors.white,這時候InkWell的水波紋效果會無效

    解決方案是:在InkWell的外層再套上Matetial 以及 Ink組件

    undefined

    Material(

    child: Ink(

    child:

    InkWell(

    onTap: () { },

    child: Container(

    height: 50.0,

    color: Colors.white,

    child: Text( "是速度",

    maxLines: 1,

    style: TextStyle(color: color),

    overflow: TextOverflow.ellipsis,

    ),

    ),

    ),

    ),

    )

    關(guān)鍵詞: InkWell

    上一篇:峰峰值指的是什么?只有正的嗎?

    下一篇:VB 中的dim是什么意思?

    責(zé)任編輯:

    最近更新

    點擊排行
    推薦閱讀

    亚洲精品无码av片| 久久精品国产亚洲沈樵| 亚洲av无码专区国产乱码在线观看| 亚洲?V乱码久久精品蜜桃 | 亚洲一区二区三区写真 | 久久精品国产亚洲AV高清热| 亚洲国产精品一区二区成人片国内| 久久国产成人精品国产成人亚洲| 亚洲А∨精品天堂在线| 欧美激情综合亚洲一二区| 亚洲成a人无码亚洲成www牛牛| 国产成人精品日本亚洲11| 91在线亚洲综合在线| 亚洲日韩国产欧美一区二区三区| 亚洲免费福利在线视频| 亚洲字幕AV一区二区三区四区| 亚洲性线免费观看视频成熟| 亚洲一线产区二线产区区| 亚洲精品久久久久无码AV片软件| 亚洲AV永久无码精品一福利 | 亚洲VA成无码人在线观看天堂 | 亚洲高清视频在线| 亚洲欧美成aⅴ人在线观看| 亚洲AV噜噜一区二区三区 | 亚洲人成网址在线观看| 亚洲自偷自偷精品| 精品亚洲国产成AV人片传媒| 亚洲精品一卡2卡3卡三卡四卡| 亚洲制服丝袜在线播放| 亚洲伊人久久大香线蕉AV| 亚洲GV天堂无码男同在线观看| www.亚洲精品| 自拍偷自拍亚洲精品被多人伦好爽| 国产亚洲色婷婷久久99精品| 亚洲成人在线电影| 国产日本亚洲一区二区三区| 亚洲AV无码AV日韩AV网站| 亚洲日本中文字幕天堂网| 亚洲AV综合色区无码一区爱AV | 久久精品国产亚洲AV无码偷窥| 亚洲毛片基地日韩毛片基地|