I'm using Flutter's CircleAvatar
with a backgroundImage
property to display a network image. However, I want to implement a fallback mechanism, so that if the network image fails to load , it should display a local image stored on my computer.
I believe using an if
-else
statement can solve this problem, but I'm struggling to figure out how to implement it properly. Could someone please guide me on how to achieve this behavior?
drawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: [
const DrawerHeader(
decoration: BoxDecoration(
color: Colors.white,
),
// child: Text('Drawer Header'),
child: CircleAvatar(
radius: 40,
backgroundImage: NetworkImage('https://~~'),
),
),