How to set a graphical frame image as a background for the radial gauge widget
Description
This article describes how to set a graphical frame image as background for the radial gauge widget.
Solution
You can show the graphical frame image as background for radial gauge with the backgroundImage property of radial axis.
The backgroundImage property of radial axis is a type of ImageProvider. Therefore, you can set the following types of image for backgroundImage property:
The following steps explain how to set an AssetImage to backgroundImage property of the axis:
Step 1: Create a folder named as images and copy the desired image.
Step 2: To access the image added in the sample, you need to define the folder, which contains the image as assets in pubspec.yaml as like the following snippet.
Step 3: Create the radial gauge widget and set the corresponding image, which needs to be displayed as the background image for the radial axis to its backgroundImage property as demonstrated in the following code example.
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfRadialGauge(
axes: <RadialAxis>[
RadialAxis(
backgroundImage: const AssetImage('images/dark_theme_gauge.png'),
)
],
))),
);
}
Output:
You can download the demo sample from this link.