Hellow, Im newbie in flutter..please help me to pass data from parent to child statefullwidget.. then..send to API..
This is my code
class Home extends StatefulWidget {
final String user; // I will passing this into getCategory()
final String email;
Home(this.user, this.email);
@override
HomeState createState() => HomeState();
}
class HomeState extends State<Home> {
CategoryList listCategory = CategoryList();
void getCategory() async {
var json = await ApiCategoryList().getCategoryList(widget.user); //not working ..
setState(() {
listCategory = CategoryList.fromJson(json);
});
}
@override
void initState() {
super.initState();
this.getCategory();
}
@override
Widget build(BuildContext context) {
return ListTile(data from API here)
}
Thanks for helping me..regards