Reputation:
I was trying to give my Container a Color but but it's saying, for example: red is not defined for the type 'Color'
.
Does anyone know how to fix this?
import 'package:flutter/material.dart';
import 'package:color/color.dart';
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: [
Container(
color: Color.red,
)
],
),
);
}
}
Upvotes: 0
Views: 752
Reputation: 84
import 'package:flutter/material.dart';
import 'package:color/color.dart';
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: [
Container(
color: Colors.red,
)
],
),
);
}
}
Upvotes: 0
Reputation: 1463
It's Colors
, not Color
.
You can look up the Color Class on the official documentation.
Container(
color: Colors.red,
)
Upvotes: 1