flutter floatingActionButton懸浮按鈕控件


import 'package:flutter/material.dart';

void main() {
  runApp( MaterialApp(
    title: 'Flutter gesture',
    home: LearnFloatingActionButton(),
  ));
}

class LearnFloatingActionButton extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {
    return _LearnFloatingActionButton();
  }
}
class _LearnFloatingActionButton extends State<LearnFloatingActionButton>{
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: new Center(
        child:new FloatingActionButton(
          child: new Icon(Icons.ac_unit),//子Widet 可以是文本或者圖片
          tooltip: '長按之后提示的文字',//長按提示的文字
          foregroundColor: Colors.red,//設置顯示圖標或者文本的顏色//前提是子child沒有設置
          backgroundColor: Colors.blueAccent,//設置按鈕的背景色
//          heroTag: ,//類似於一個標識
          elevation: 10.0,//設置陰影
          highlightElevation: 50.0,
          shape: const CircleBorder(),
//          isExtended: true,
          onPressed: (){
            print('aaaaaaaaaaaaaa點擊了懸浮按鈕aaaaaaaaaaaaa');
          },
        ),
      ),
    );
  }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM