|
Container(
// parent container size(400x400)
height: 400,
width: 400,
// Layout builder as child of parent container
child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
// returned radial gauge widget in layout builder
return SfRadialGauge(axes: <RadialAxis>[
RadialAxis(
minimum: 0,
maximum: 150,
pointers: <GaugePointer>[
MarkerPointer(
value: 60,
// Got the height constraints of parent conatiner
// and divided it by 10 (i.e., 10 % of parent's height as marker height)
markerHeight: constraints.maxHeight / 10,
// Got the height constraints of parent conatiner and
// divided it by 10 (i.e., 10 % of parent's width as marker width)
markerWidth: constraints.maxWidth / 10,
)
],
)
]);
}),
), |
|
SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
annotations: <GaugeAnnotation>[
GaugeAnnotation(
// Text widget as annonation and it for size can be set using is TextStyle.fontSize property.
widget: Text(
'50.0',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20
),
))]
)
) |
|
Container(
// parent container size(400x400)
color: Colors.white,
height: 400,
width: 400,
child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return SfRadialGauge(
axes: <RadialAxis>[
RadialAxis(
minimum: 0,
maximum: 150,
annotations: [
GaugeAnnotation(
widget: Container(
// provided height and width for the image using the size constraints
width: constraints.maxWidth / 10,
height: constraints.maxHeight / 10,
decoration: new BoxDecoration(
image: new DecorationImage(
image: ExactAssetImage('images/sun.png'),
fit: BoxFit.fitHeight,
),)))
],
)
]
);
}),
) |