'How to add ripples effect while using circleavatar in flutter

CircleAvatar(
  backgroundColor: Colors.blue,
  radius: 25,
  child: Icon(Icons.add_call),
),

How to add ripples of different color inside circleavatar



Solution 1:[1]

You can use InkWell in this case, and import 'dart:math'; use get Random.

 late Color _rippleColor = getRandomColor();

  Color getRandomColor() =>
      Color((Random().nextDouble() * 0xFFFFFF).toInt()).withOpacity(1.0);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Center(
      child: InkWell(
        radius: 25,
        splashColor: _rippleColor,
        customBorder: const CircleBorder(),
        child: const Padding(
          padding: EdgeInsets.all(8.0),
          child: Icon(
            Icons.add_call,
          ),
        ),
        onTap: () {
          setState(() {
            _rippleColor = getRandomColor();
          });
        },
      ),
    ));
  }

Solution 2:[2]

Use Ink and InkWell with Material on top of it and set Material shape with CircleBorder()

Material(
  elevation: 4.0,
  shape: CircleBorder(),
  clipBehavior: Clip.antiAlias,
  color: Colors.transparent,
  child: Ink.image(
    image: AssetImage('assets/profile_default.jpg'),
    fit: BoxFit.cover,
    width: 120.0,
    height: 120.0,
    child: InkWell(
      onTap: () {},
    ),
  ),
)

you can change splash color in InkWell property

source: https://medium.com/@RayLiVerified/create-a-rounded-image-icon-with-ripple-effect-in-flutter-eb0f4a720b90

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Yeasin Sheikh
Solution 2 Fajrul