Просто позвоните setState()
и используйте разные цвета.
Вот пример:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
Color color1 = Colors.blue;
Color color2 = Colors.blue;
void _changeColor() {
setState(() {
color1 = Colors.red;
color2 = Colors.green;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Test"),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Buttons',
),
],
),
),
floatingActionButton: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
FloatingActionButton(
backgroundColor: color1,
onPressed: _changeColor,
child: Icon(Icons.refresh),
),
FloatingActionButton(
backgroundColor: color1,
onPressed: _changeColor,
child: Icon(Icons.refresh),
),
FloatingActionButton(
backgroundColor: color2,
onPressed: _changeColor,
child: Icon(Icons.refresh),
),
FloatingActionButton(
backgroundColor: color2,
onPressed: _changeColor,
child: Icon(Icons.refresh),
),
],
),
);
}
}