there is error in override function body error
import 'package:flutter/material.dart';
class Home extends StatefulWidget {
const Home({super.key});
@override
State<Home> createState() => _HomeState();
}
class _HomeState extends State<Home> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Row(
children: [
Text("Flutter"),
Text(
"News",
style: TextStyle(color: Colors.blue, fontWeight: FontWeight.bold),
)
],
),
centerTitle: true,
),
body: Container(),
);
}
}
class CategoryTile extends StatelessWidget {
final image, categoryName;
CategoryTile({super.key, this.categoryName, this.image})
// ignore: empty_constructor_bodies
@override
Widget build(BuildContext context) {
return Container(
child: Stack( children: [
Image.asset(image,
width: 120,
height: 60,
)
],),
);
}
}
a function body must be provided error
i dont know how to solve this & so I can get some help.
2
Answers
You are missing a
;
after your constructor :It should be better like this
When you define a constructor, you need to provide a function body for it.
Here is the updated code: