I get this error: Another exception was thrown: Assertion failed: file:///C:/flutter/packages/flutter/lib/src/rendering/box.dart:1965:12
Another exception was thrown: Assertion failed: file:///C:/flutter/packages/flutter/lib/src/rendering/sliver_multi_box_adaptor.dart:546:12
Another exception was thrown: Unexpected null value.
I am developing a website for a telegram bot.
I have such a class
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: CatalogPage(),
),
);
}
}
class CatalogPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(height: 20), // Indent at the top
Image.asset(
'assets/images/Vector.png',
width: 36,
height: 36,
),
SizedBox(height: 20), // Indent at the top
Text(
'Good morning!',
style: TextStyle(
fontSize: 30,
fontFamily: 'Montserrat',
),
),
SizedBox(height: 20),
Expanded(
child: ListView(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CatalogItem(
image: 'assets/images/pic-1.jpg',
title: 'Чіпси nяблуневі ',
price: '₴40',
weight: 50,
),
SizedBox(width: 10),
CatalogItem(
image: 'assets/images/pic-2.jpg',
title: 'Пастила nфруктова',
price: '₴50',
weight: 50,
),
],
),
SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CatalogItem(
image: 'assets/images/pic-3.jpg',
title: 'Тістечко nз цукатами',
price: '₴30',
weight: 50,
),
SizedBox(width: 10),
CatalogItem(
image: 'assets/images/pic-4.jpg',
title: 'Печиво nбезлактозне nвівсяне',
price: '₴30',
weight: 120,
),
],
),
SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CatalogItem(
image: 'assets/images/pic-5.jpg',
title: 'Печиво nшпинат не n«мармурове»',
price: '₴30',
weight: 100,
),
SizedBox(width: 10),
CatalogItem(
image: 'assets/images/pic-6.jpg',
title: 'Печиво nсендвіч nз зефіром',
price: '₴30',
weight: 50,
),
],
),
SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CatalogItem(
image: 'assets/images/pic-7.jpg',
title: 'Печиво nшоколадне n«мармурове»',
price: '₴30',
weight: 100,
),
],
),
],
),
),
],
),
);
}
}
Here’s the consturtor …
class CatalogItem extends StatelessWidget {
final String image;
final String title;
final String price;
final int weight;
CatalogItem({
required this.image,
required this.title,
required this.price,
required this.weight,
});
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(10),
),
margin: EdgeInsets.symmetric(horizontal: 10),
padding: EdgeInsets.all(4),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 149, // Adjust the size of the images as needed
height: 192, // Adjust the size of the images as needed
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
image: DecorationImage(
image: AssetImage(image),
fit: BoxFit.cover,
),
),
),
SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
title,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 16
),
),
Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
'$weight г',
style: TextStyle(
color: Colors.white,
fontSize: 10
),
),
SizedBox(height: 5),
Text(
price,
style: TextStyle(
color: Colors.white,
fontSize: 11,
fontWeight: FontWeight.bold,
),
),
],
),
],
),
],
),
);
}
}
And when I try to place the elements on the right side, I get the error that I indicated earlier, and even when I want to make the container in which the product is located the same, I also get an error, and nothing is displayed on the screen.