0

The parameter 'image_caption' can't have a value of 'null' because of its type, but the implicit default value is 'null'.

doing some research. he parameter 'image_caption' can't have a value of 'null' because of its type, but the implicit default value is 'null'.

import 'package:flutter/material.dart';

class HorizontalList extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
        height: 80.0,
        child: ListView(
          scrollDirection: Axis.horizontal,
          children: <Widget>[
            Category(
              image_location: 'images/cats/tshirt.png',
              image_caption: 'shirt',
            )
          ],
        ));
  }
}

class Category extends StatelessWidget {
  final String image_location;
  final String image_caption;

  Category({
    this.image_location, 
    this.image_caption
    });

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.all(2.0),
      child: InkWell(
        onTap: () {},
        child: Container(
          width: 100.0,
          child: ListTile(
            title: Image.asset(
              image_location,
              width: 100.0,
              height: 80.0,
            ),
            subtitle: Text(image_caption),
          ),
        ),
      ),
    );
  }
}

enter image description here

  • I think it is similar to https://stackoverflow.com/questions/64560461/the-parameter-cant-have-a-value-of-null-because-of-its-type-in-dart – iqfareez Nov 29 '22 at 13:35

0 Answers0