将原来的 FloatingActionButton 替换为 MaterialButton,并设置为胶囊型:

Stack(children: [
  Container(
    width: MediaQuery.of(context).size.width * 0.5,
    height: MediaQuery.of(context).size.width * 0.5,
    child: RiveAnimation.asset(
      'assets/birds.riv',
      controllers: [_controller],
      animations: ['行走', '起飞', '保持飞翔', '降落'],
    ),
  ),
  Positioned(
    bottom: 30.0,
    right: 20.0,
    child: MaterialButton(
      onPressed: () {
        _controller = SimpleAnimation('起飞');
        Future.delayed(Duration(seconds: 2), () {
          _controller = SimpleAnimation('保持飞翔');

          _controller = SimpleAnimation('降落');
          Future.delayed(Duration(seconds: 2), () {
            _controller = SimpleAnimation('行走');
          });
        });
        hItems(DateTime.now());
        setState(() {
          print('回到今天');
          _calendarAgendaControllerAppBar.goToDay(DateTime.now());
        });
      },
      child: Text(
        '回到今天',
      ),
      shape: StadiumBorder(),
      textColor: Colors.white,
      color: Global.home_currentcolor,
    ),
  )
]);
Flutter 将 FloatingActionButton 替换为胶囊型 MaterialButton

原文地址: https://www.cveoy.top/t/topic/occK 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录