最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Flutter懸浮按鈕FloatingActionButton使用詳解

 更新時(shí)間:2021年07月12日 10:42:15   作者:sugood  
本文主要介紹了Flutter懸浮按鈕FloatingActionButton使用,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

1、普通用法

floatingActionButton: FloatingActionButton(
    child: Icon(Icons.add),
      onPressed: (){
         print('不要啊~');
      },
 ),

2、修改懸浮按鈕位置

繼承FloatingActionButtonLocation類,重寫對(duì)應(yīng)方法自定義位置

import 'package:flutter/material.dart';

class CustomFloatingActionButtonLocation extends FloatingActionButtonLocation {
  FloatingActionButtonLocation location;
  double offsetX;    // X方向的偏移量
  double offsetY;    // Y方向的偏移量
  CustomFloatingActionButtonLocation(this.location, this.offsetX, this.offsetY);

  @override
  Offset getOffset(ScaffoldPrelayoutGeometry scaffoldGeometry) {
    Offset offset = location.getOffset(scaffoldGeometry);
    return Offset(offset.dx + offsetX, offset.dy + offsetY);
  }
}

使用

floatingActionButtonLocation:CustomFloatingActionButtonLocation(
             FloatingActionButtonLocation.endFloat, 0, -DpUtils.setWidth(20)),

3、修改懸浮按鈕大小

floatingActionButton: SizedBox(
  height: 100.0,
  width: 100.0,
  child:FloatingActionButton(
    child: Icon(Icons.add),
    onPressed: () {},
  ),
),

4、去除懸浮按鈕切換動(dòng)畫

繼承FloatingActionButtonAnimator類并重寫對(duì)應(yīng)的方法

import 'package:flutter/material.dart';

class NoScalingAnimation extends FloatingActionButtonAnimator{
  double _x;
  double _y;
  @override
  Offset getOffset({Offset begin, Offset end, double progress}) {
    _x = begin.dx +(end.dx - begin.dx)*progress ;
    _y = begin.dy +(end.dy - begin.dy)*progress;
    return Offset(_x,_y);
  }

  @override
  Animation<double> getRotationAnimation({Animation<double> parent}) {
    return Tween<double>(begin: 1.0, end: 1.0).animate(parent);
  }

  @override
  Animation<double> getScaleAnimation({Animation<double> parent}) {
    return Tween<double>(begin: 1.0, end: 1.0).animate(parent);
  }
}

使用

floatingActionButtonAnimator: NoScalingAnimation(),

5、一般的自定義懸浮按鈕樣式

@override
  Widget build(BuildContext context) {
    return Scaffold(
       floatingActionButton: FloatingActionButton(
          child: Container(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                Image.asset(
                  "images/float_button.png",
                  width: DpUtils.setWidth(32),
                  height: DpUtils.setWidth(32),
                ),
                Text(
                  "懸浮按鈕",
                  style: TextStyle(fontWeight: FontWeight.bold, 
                        fontSize: DpUtils.setSp(20), color: Colors.white),
                ),
              ],
            ),
          ),
          elevation: 0,
          onPressed: () {
            _doSome();
          },
          backgroundColor: Colors.black,
          heroTag: "floatHome",
        ),
    )
)}

6、徹底的自定義懸浮按鈕樣式

其實(shí),floatingActionButton 可以直接傳入普通的widget。所以該干嘛干嘛咯

@override
  Widget build(BuildContext context) {
    return Scaffold(
        floatingActionButton: Container(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              Image.asset(
                "images/home_icon_publishing.png",
                width: DpUtils.setWidth(32),
                height: DpUtils.setWidth(32),
              ),
              Text(
                "發(fā)主題",
                style: TextStyle(fontWeight: FontWeight.bold, 
                     fontSize: DpUtils.setSp(20), color: Colors.white),
              ),
            ],
          ),
        ),
    );
  }

到此這篇關(guān)于Flutter懸浮按鈕FloatingActionButton使用詳解的文章就介紹到這了,更多相關(guān)Flutter懸浮按鈕FloatingActionButton內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家! 

相關(guān)文章

  • Android子線程與更新UI問題的深入講解

    Android子線程與更新UI問題的深入講解

    首先和其他許多的GUI庫一樣,Android的UI線程是不安全的。所以下面這篇文章主要給大家介紹了關(guān)于Android子線程與更新UI問題的相關(guān)資料,需要的朋友可以參考借鑒,下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-03-03
  • Android AsyncTask用法巧用實(shí)例代碼

    Android AsyncTask用法巧用實(shí)例代碼

    這篇文章主要介紹了Android AsyncTask用法巧用實(shí)例代碼的相關(guān)資料,需要的朋友可以參考下
    2017-01-01
  • Android自定義彈出窗口PopupWindow使用技巧

    Android自定義彈出窗口PopupWindow使用技巧

    這篇文章主要介紹了Android自定義彈出窗口PopupWindow使用技巧,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • kotlin Standard中的內(nèi)聯(lián)函數(shù)示例詳解

    kotlin Standard中的內(nèi)聯(lián)函數(shù)示例詳解

    這篇文章主要給大家介紹了關(guān)于kotlin Standard中內(nèi)聯(lián)函數(shù)的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用kotlin具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-08-08
  • Android利用Canvas標(biāo)點(diǎn)畫線并加入位移動(dòng)畫(1)

    Android利用Canvas標(biāo)點(diǎn)畫線并加入位移動(dòng)畫(1)

    這篇文章主要為大家詳細(xì)介紹了Android利用Canvas標(biāo)點(diǎn)畫線并加入位移動(dòng)畫的第一篇,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-09-09
  • Android學(xué)習(xí)教程之滑動(dòng)布局(14)

    Android學(xué)習(xí)教程之滑動(dòng)布局(14)

    這篇文章主要為大家詳細(xì)介紹了Android學(xué)習(xí)教程之滑動(dòng)布局使用方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • Android 實(shí)例開發(fā)基于ArcSoft實(shí)現(xiàn)人臉識(shí)別

    Android 實(shí)例開發(fā)基于ArcSoft實(shí)現(xiàn)人臉識(shí)別

    人臉識(shí)別,是基于人的臉部特征信息進(jìn)行身份識(shí)別的一種生物識(shí)別技術(shù)。用攝像機(jī)或攝像頭采集含有人臉的圖像或視頻流,并自動(dòng)在圖像中檢測(cè)和跟蹤人臉,進(jìn)而對(duì)檢測(cè)到的人臉進(jìn)行識(shí)別的一系列相關(guān)技術(shù),通常也叫做人像識(shí)別、面部識(shí)別
    2021-11-11
  • Android使用Retrofit上傳文件功能

    Android使用Retrofit上傳文件功能

    這篇文章主要為大家詳細(xì)介紹了Android使用Retrofit上傳文件,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-01-01
  • 詳解adb工具的基本使用

    詳解adb工具的基本使用

    adb全稱Android Debug Bridge,是Android SDK中的一個(gè)工具, 使用adb可以直接操作管理Android模擬器或者真實(shí)的Andriod設(shè)備,就是起到調(diào)試橋的作用,這篇文章主要介紹了adb工具的基本使用,需要的朋友可以參考下
    2022-08-08
  • Android動(dòng)畫實(shí)現(xiàn)原理和代碼

    Android動(dòng)畫實(shí)現(xiàn)原理和代碼

    這篇文章主要介紹了Android動(dòng)畫實(shí)現(xiàn)原理和代碼分析,如果你對(duì)此感興趣,跟著小編學(xué)習(xí)下吧。
    2017-12-12

最新評(píng)論

湾仔区| 德化县| 方正县| 永福县| 阳原县| 中山市| 乐平市| 桂东县| 湟中县| 收藏| 通河县| 萝北县| 江都市| 北流市| 怀仁县| 齐河县| 新化县| 内黄县| 霞浦县| 北川| 红河县| 博兴县| 黑山县| 武陟县| 桦川县| 陕西省| 新巴尔虎左旗| 商都县| 松桃| 高邑县| 射洪县| 清水县| 诏安县| 昌乐县| 泰来县| 衢州市| 彰化市| 平利县| 郎溪县| 博客| 天祝|