栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

带有快速拨盘的Flutter浮动动作按钮

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

带有快速拨盘的Flutter浮动动作按钮

这是有关如何使用进行快速拨号的示意图

FloatingActionButton
.

import 'package:flutter/material.dart';import 'dart:math' as math;void main() {  runApp(new MyApp());}class MyApp extends StatelessWidget {  @override  Widget build(BuildContext context) {    return new MaterialApp(      home: new MyHomePage(),    );  }}class MyHomePage extends StatefulWidget {  @override  State createState() => new MyHomePageState();}class MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {  AnimationController _controller;  static const List<IconData> icons = const [ Icons.sms, Icons.mail, Icons.phone ];  @override  void initState() {    _controller = new AnimationController(      vsync: this,      duration: const Duration(milliseconds: 500),    );  }  Widget build(BuildContext context) {    Color backgroundColor = Theme.of(context).cardColor;    Color foregroundColor = Theme.of(context).accentColor;    return new Scaffold(      appBar: new AppBar(title: new Text('Speed Dial Example')),      floatingActionButton: new Column(        mainAxisSize: MainAxisSize.min,        children: new List.generate(icons.length, (int index) {          Widget child = new Container( height: 70.0, width: 56.0, alignment: FractionalOffset.topCenter, child: new ScaleTransition(   scale: new CurvedAnimation(     parent: _controller,     curve: new Interval(       0.0,       1.0 - index / icons.length / 2.0,       curve: Curves.easeOut     ),   ),   child: new FloatingActionButton(     heroTag: null,     backgroundColor: backgroundColor,     mini: true,     child: new Icon(icons[index], color: foregroundColor),     onPressed: () {},   ), ),          );          return child;        }).toList()..add(          new FloatingActionButton( heroTag: null, child: new AnimatedBuilder(   animation: _controller,   builder: (BuildContext context, Widget child) {     return new Transform(       transform: new Matrix4.rotationZ(_controller.value * 0.5 * math.pi),       alignment: FractionalOffset.center,       child: new Icon(_controller.isDismissed ? Icons.share : Icons.close),     );   }, ), onPressed: () {   if (_controller.isDismissed) {     _controller.forward();   } else {     _controller.reverse();   } },          ),        ),      ),    );  }}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/366926.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号