小编Suv*_*kka的帖子

如何更改BottomNavigationBar背景颜色?

我正在制作一个带有选项卡栏的简单应用程序。我需要将底部导航栏的背景颜色更改为蓝色。应用程序的其余部分应为白色背景,导航栏应为蓝色背景。我该怎么做呢?在 ThemeData 中设置 canvasColor 不起作用。

这是我的代码:

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  State<StatefulWidget> createState(){
    return MyAppState();
}
}

class MyAppState extends State<MyApp>{

  int _selectedPage = 0;
  final _pageOptions = [
    Text('Item1'),
    Text('Item2'),
    Text('Item3')
  ];

  @override
  Widget build(BuildContext context) {

    return MaterialApp(
      title: 'sddsd',

      theme: ThemeData(
        primaryColor: Colors.blueAccent,
        fontFamily: "Google Sans"

      ),

      home: Scaffold(
        appBar: AppBar(
            title:Text("LQ2018"),
            backgroundColor: Colors.blueAccent,
        ),

      body: _pageOptions[_selectedPage],

      bottomNavigationBar: BottomNavigationBar(
        fixedColor: Colors.blueAccent,
        currentIndex: _selectedPage,
        onTap: (int index){
          setState(() {
            _selectedPage= index;
          }); …
Run Code Online (Sandbox Code Playgroud)

android hybrid-mobile-app flutter

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×1

flutter ×1

hybrid-mobile-app ×1