我想为BottomNavigationBar的背景使用图像,但是我什么都没找到。有什么建议吗?建议的唯一属性是backgroundColor,它只需要一个Color即可。
答案 0 :(得分:3)
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
bottomNavigationBar: Container(
decoration: BoxDecoration(
image: DecorationImage(image: AssetImage('images/img.png'), fit: BoxFit.fill),
),
child: BottomNavigationBar(
backgroundColor: Colors.transparent,
elevation: 0,
items: [
BottomNavigationBarItem(icon: Icon(Icons.add), title: Text('title')),
BottomNavigationBarItem(icon: Icon(Icons.remove), title: Text('title')),
],
),
),
),
);
}
}