Reputation: 512
I am creating a card component that contains icons and text as a children's widget.
I initialize these icons and wanted to make use of them inside its children widget but it's giving errors
The error is indicated above the image. It happened on widget.icon, widget.title, and it's also happened if I used it on widget.subtitle. Below is the full code
import 'package:flutter/rendering.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:api_example_app/constants.dart';
import 'package:flutter/widgets.dart';
class CardsParent extends StatefulWidget {
const CardsParent({
Key key,
@required this.size,
this.icon,
this.title,
this.subtitle,
}) : super(key: key);
final Size size;
final IconData icon;
final String title;
final String subtitle;
@override
_CardsParentState createState() => _CardsParentState();
}
class _CardsParentState extends State<CardsParent> {
@override
Widget build(BuildContext context) {
return Container(
width: 140,
height: 100,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
color: Colors.white,
elevation: 10,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const ListTile(
leading: Icon(
widget.icon,
size: 50,
color: kOrangeColor,
),
title: Text('Temp',
style: TextStyle(fontSize: 18.0, color: kOrangeColor)),
subtitle: Text('33C', style: TextStyle(color: kOrangeColor)),
),
],
),
),
);
}
}
Am I doing something wrongly?
Upvotes: 1
Views: 1082