Reputation: 379
Im trying to set a color shade for my scaffold widget, and I'm getting this error.
The operator '[]' isn't defined for the class 'Color'. Try defining the operator '[]'.
In a previous project that i did, I dont have this problem. Does anybody know what i might be doing wrong?
Code Used:
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black[900],
appBar: AppBar(
title: Text('My App'),
centerTitle: true,
),
);
}
}
Upvotes: 1
Views: 1208
Reputation: 267584
There is no shade of Black color with 900
(maybe you were using something else in your previous project), you can use grey
Colors.grey[900]
or any other black shade like:
Colors.black12, Colors.black26
or even Colors.black.withOpacity(0.8)
if that suits your need.
Upvotes: 2