我想改变颜色的 AppBar 和使用一个自定义的颜色,我尝试了很多选项,但似乎没有一个工作。 有什么我不知道的吗?
import 'package:flutter/material.dart';
final ThemeData CompanyThemeData = new ThemeData(
brightness: Brightness.light,
primaryColorBrightness: Brightness.light,
accentColor: CompanyColors.black[500],
accentColorBrightness: Brightness.light
);
class CompanyColors {
CompanyColors._(); // this basically makes it so you can instantiate this class
static const _blackPrimaryValue = 0xFF000000;
static const MaterialColor black = const MaterialColor(
_blackPrimaryValue,
const <int, Color>{
50: const Color(0xFFe0e0e0),
100: const Color(0xFFb3b3b3),
200: const Color(0xFF808080),
300: const Color(0xFF4d4d4d),
400: const Color(0xFF262626),
500: const Color(_blackPrimaryValue),
600: const Color(0xFF000000),
700: const Color(0xFF000000),
800: const Color(0xFF000000),
900: const Color(0xFF000000),
},
);
}
然后我用它在主要。飞镖作为
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or press Run > Flutter Hot Reload in IntelliJ). Notice that the
// counter didn't reset back to zero; the application is not restarted.
primarySwatch:Theme1.CompanyColors.black[50],
),
home: new MyHomePage(title: 'Flutter Demo Home Page'),
);
}
但行刑后,上面写着
Color 类型不属于 Material Color 子类型