您无法看到任何内容,因为您正在从返回容器列表生成. 相反,您应该返回Ink小部件。请参见以下代码:
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: Test(),
),
),
);
}
}
class Test extends StatefulWidget {
@override
_TestState createState() => _TestState();
}
class _TestState extends State<Test> {
bool changeColor = false;
List _fabBarIcons = [
Icon(Icons.ac_unit),
Icon(Icons.access_time),
Icon(Icons.accessible),
Icon(Icons.ad_units),
Icon(Icons.search),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Container(),
floatingActionButton: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: List.generate(
_fabBarIcons.length,
(index) {
return Ink(
decoration: const ShapeDecoration(
color: Colors.cyan,
shape: CircleBorder(),
),
child: IconButton(
onPressed: () {},
icon: _fabBarIcons[index],
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
),
);
},
),
),
);
}
}