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');
          },
        ),
      ),
    );
  }
}

 

posted on 2019-11-29 15:36  高彰  阅读(1467)  评论(0编辑  收藏  举报

导航