'How to print to console from within the widget in flutter
I'm Trying to know whether the product Controller is setup ,Because as the app is hot restrat the ui doesn't build itself, now i know that the cause is product controller.
So i want to print the product Controller to the console, when the app is hot restarted.
@override
Widget build(BuildContext context) {
return Row(
children: [
Expanded(
child: SizedBox(
height: 150,
child: ListView(
// print("The productController instance is :"+ productController); <-- Giving an error
scrollDirection: Axis.horizontal,
children:
productsController.products.map((ProductModel product) {
print("These are the products" + product.toString());
return ProductCard(product: product);
}).toList()),
),
)
],
);
}
Solution 1:[1]
Use print to indicate every step like if you want to know whether the controller stated just put print statement in the onInit(), if you want to see if a variable is populated just print it in the last line of the function or before return.
Try using Logger to make your indications clearer
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | LMech |
