Как изменить цвет фона с помощью эффекта ряби? - PullRequest
0 голосов
/ 28 мая 2020
double _size = 0;
Color _color = Colors.white;

@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(),
    floatingActionButton: FloatingActionButton(
      child: Icon(Icons.refresh),
      onPressed: () {
        Timer.periodic(Duration(milliseconds: 10), (timer) {
          if (timer.tick > 100) timer.cancel();
          if (timer.tick == 1) _color = Colors.blue;
          setState(() => _size += 20);
        });
      },
    ),
    body: Stack(
      children: [
        AnimatedContainer(
          duration: Duration(seconds: 5),
          width: _size,
          height: _size,
          alignment: Alignment.center,
          decoration: BoxDecoration(color: _color, shape: BoxShape.circle),
        ),
        Placeholder(),
      ],
    ),
  );
}

Токовый выход:

enter image description here

Ожидаемый выход:

enter image description here

Кто-нибудь может сказать мне, как это сделать, я новичок во Flutter. Возможно, мой подход неверен, следует ли использовать свойство backgroundColor из Scaffold или что-то еще?

...