简体   繁体   中英

How to make reusable inheritance of TableRow in Flutter

I was wondering, why my IDE gives me error A value of type 'TableRow' can't be returned from the method 'build' because it has a return type of 'Widget' dart(return_of_invalid_type) .

Then I found that TableRow isn't a widget within this post What is causing the error "Return Type 'TableRow' isn't a 'Widget', as defined by method 'build'" .

Then how can I efficiently write code like widget does ? I have bunch of TableRow that each piece has conditional statement.

Or is there any recommended package or solution that could I use to make similar things like Table does ? In this case, I used Table to make indented pair text key and value to be more visually clean.

Best regards, thanks!

Create a list of TableRow and add each table row to that list. Add a table and then assign the list to its children parameter. TableRow doesn't inherit a widget and hence cannot be returned as a Widget.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM