Flutter 中Color 使用
  sA55qgboe2zL 2023年11月02日 29 0


bottomNavigationBar: BottomNavigationBar(
items: const<BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home), title: Text("Home")),
BottomNavigationBarItem(
icon: Icon(Icons.cake), title: Text("Center")),
BottomNavigationBarItem(
icon: Icon(Icons.edit), title: Text("End")),

],
currentIndex: _selectIndex,
unselectedItemColor: Colors.blue,
backgroundColor: Color(0xFFff5656),
selectedFontSize: 22,
selectedItemColor: Colors.amber[900],
onTap: _onItemTapped,
),
backgroundColor: Color(0xFFff5656),  //红色  严格按照 0x +透明度+red+green+blue
selectedItemColor: Colors.amber[900], //琥珀色

 

新建自定义color:

 

import 'package:flutter/material.dart';

class CostomColors {
static const Color colorPrimaryDark = Color(0xff388E3C);
static const Color colorAccent = Color(0xff8BC34A);
static const Color colorPrimaryLight = Color(0xffC8E6C9);

static const Color primaryText = Color(0xff212121);
static const Color secondaryText = Color(0xff757575);
}

 


使用:selectedItemColor: CostomColors.colorPrimaryDark,


发现个问题:包名和调用名称 不一致但是只要代码中的class名一直就行,说明这个可以做成配置文件。

Flutter  中Color 使用_flutter

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  4koL3J55wyKx   2023年11月13日   37   0   0 icogitCentOS
  b1UHV4WKBb2S   2023年11月13日   34   0   0 裁剪ideflutter
  b1UHV4WKBb2S   2023年11月13日   27   0   0 flutterDart
sA55qgboe2zL