如何将传递的值放入构造中,使计时器四舍五入到小数点后一位并显示在RaisedButton的子文本中?我已经尝试过但没有运气。我设法使用一个简单的Timer来使回调函数起作用,但没有周期性,并且文本中没有实时更新值...
import 'package:flutter/material.dart';
import 'dart:ui';
import 'dart:async';
class TimerButton extends StatefulWidget {
final Duration timerTastoPremuto;
TimerButton(this.timerTastoPremuto);
@override
_TimerButtonState createState() => _TimerButtonState();
}
class _TimerButtonState extends State<TimerButton> {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.all(5.0),
height: 135.0,
width: 135.0,
child: new RaisedButton(
elevation: 100.0,
color: Colors.white.withOpacity(.8),
highlightElevation: 0.0,
onPressed: () {
int _start = widget.timerTastoPremuto.inMilliseconds;
const oneDecimal = const Duration(milliseconds: 100);
Timer _timer = new Timer.periodic(
oneDecimal,
(Timer timer) =>
setState(() {
if (_start < 100) {
_timer.cancel();
} …
Run Code Online (Sandbox Code Playgroud) 我想用一个图标制作一个带有圆形波纹效果的按钮,我在网上看到过一些东西,但我做不到。它并不像它应该的那样直截了当。现在尝试使用此代码。
InkWell(
onTap: () {},
splashColor: Colors.red,
highlightColor: Colors.white,
child: new Icon(
FontAwesomeIcons.chevronCircleUp,
size: 100,
),
)
Run Code Online (Sandbox Code Playgroud)
另一个尝试是用这个,但我不明白为什么那些不能完美地相互集中。
Container(
margin: EdgeInsets.all(0.0),
height: 100.0,
width: 100.0,
child: new RaisedButton(
padding: EdgeInsets.all(0.0),
elevation: 100.0,
color: Colors.black,
highlightElevation: 0.0,
onPressed: () {},
splashColor: Colors.red,
highlightColor: Colors.red,
//shape: RoundedRectangleBorder e tutto il resto uguale
shape: CircleBorder(
side: BorderSide(color: Colors.black, width: 5),
),
child: Icon(
FontAwesomeIcons.chevronCircleUp,
color: Colors.white.withOpacity(.8),
size: 80,
)),
),
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助
我看到 FAB 采用的飞溅和高亮颜色与 MaterialApp 小部件中的参数颜色相关联。有没有办法覆盖这些颜色?我发现只有前景色和背景色,这些不是我想要的。谢谢
我在我的应用程序中实现了numberpicker。我想修改突出显示值和非突出显示值的数字大小和颜色。我设法修改突出显示的内容,将其包装在主题小部件中并修改强调颜色,但不知道如何进行其他自定义?
Theme(
data: Theme.of(context).copyWith(
accentColor: Colors.red,
),
child: NumberPicker.integer(
initialValue: _currentPickerValue,
minValue: 0,
maxValue: 100,
onChanged: (newValue) =>
setState(() => _currentPickerValue = newValue)))
Run Code Online (Sandbox Code Playgroud) 我不明白为什么这个 FAB 不以它的孩子为中心。我尝试了不同的东西,但不能完美地居中。因为例如仅在图标底部添加填充可以使其以设备为中心,但可能并非全部。这是我的代码
Theme(
data: Theme.of(context).copyWith(
highlightColor: Colors.red, splashColor: Colors.red),
child: SizedBox(
height: MediaQuery.of(context).size.height / 7,
width: MediaQuery.of(context).size.height / 7,
child: FloatingActionButton(
elevation: 100,
shape: new CircleBorder(
side: new BorderSide(
color: Colors.black, width: 5.0)),
backgroundColor: Colors.orangeAccent,
onPressed: () {},
child: new Icon(
FontAwesomeIcons.chevronUp,
size: 80,
)),
),
),
Run Code Online (Sandbox Code Playgroud)
这是带有图标子项的不居中 FAB。
只有我觉得图标没有居中吗?