flutter - How to change ToggleButtons color

Flutter - ToggleButtons Color
The ToggleButtons class represents a set of toggle buttons. The ToggleButton’s children are laid out along direction. The state of each button in a ToggleButton widget is controlled by the isSelected property, which is a list of bools that determine if a button is in an unselected or selected state. The flutter developers can configure the ToggleButtons widget’s each toggle behavior by the onPressed callback, which can update the isSelected list however it wants to. The ToggleButtons widget has a solid, 1 logical pixel border surrounding itself by default and separating each button.

The following flutter app development tutorial will demonstrate how to set or change the ToggleButtons widget’s various colors such as text and icon color, selected toggle buttons fill color, splash color, selected toggle buttons text and icon color, enabled border color, disabled border color, and selected border color.

The ToggleButtons class’s color property value is a Color object that is the color for descendant Text and Icon widgets if the button is enabled and not selected. The selectedColor property determines the color for descendant Text and Icon widgets if the button is selected.

The fillColor property value specifies The fill color for selected toggle buttons. And the splashColor property value determines the splash color for the button's InkWell.

The ToggleButtons class’s borderColor property specifies the border color to display when the toggle button is enabled and not selected. The disabledBorderColor property determines the border color to display when the toggle button is disabled. And the selectedBorderColor property helps us to set the border color to display when the toggle button is selected.
main.dart

import 'package:flutter/material.dart';

void main() => runApp(const FlutterExample());

class FlutterExample extends StatelessWidget {
const FlutterExample({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Example',
theme: ThemeData(primarySwatch: Colors.blue),
home: const StateExample()
);
}
}

class StateExample extends StatefulWidget {
const StateExample({Key? key}) : super(key: key);

@override
_StateExampleState createState() => _StateExampleState();
}

class _StateExampleState extends State<StateExample> {
final List<bool> _selections = List.generate(4, (index) => false);

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFEDEAE0),
appBar: AppBar(
title: const Text("Flutter - ToggleButtons Color")
),
body: bodyContent()
);
}


bodyContent() {
return Center(
child: ToggleButtons(
children: const [
Icon(Icons.share),
Icon(Icons.add_location),
Icon(Icons.bookmark),
Icon(Icons.repeat)
],
onPressed: (int index){
setState(() {
_selections[index] = !_selections[index];
});
},
isSelected: _selections,
constraints: const BoxConstraints(
minWidth: 80,
minHeight: 80
),
color: Colors.pink,
selectedColor: Colors.green,
fillColor: Colors.yellow,
disabledColor: Colors.blueGrey,
borderColor: Colors.black87,
selectedBorderColor: Colors.blue,
splashColor: Colors.orange,
)
);
}
}