Reputation: 101
I want to know how to customize a switch in Flutter to look like this :
I don't want to know how to make the shape etc. But how to put an image in the track. I know there are :
inactiveThumbImage
activeThumbImage
But it is not what I want.
Maybe something like activeTrackImage
, but I didn't find anything in the doc.
Upvotes: 0
Views: 848
Reputation: 506
you can use this package which adds the functionality to add an image to a switch widget..
AdvancedSwitch(
controller: _controller,
activeColor: Colors.green,
inactiveColor: Colors.grey,
activeImage: const AssetImage('assets/images/on.png'),
inactiveImage: const AssetImage('assets/images/off.png'),
borderRadius: const BorderRadius.all(Radius.circular(15)),
width: 100.0,
height: 30.0,
enabled: true,
disabledOpacity: 0.5,
)
which gives the following result
OFF
ON
Upvotes: 2