Я использую виджет Flutter Table. Я хочу скрыть одну из строк таблицы на основе определенных условий.
Я пробовал виджет видимости над Tablerow, но он не позволяет. Я также пробовал булево условие, например. бул? Tablerow (...): Tablerow (), кажется, не работает должным образом, поскольку дал нулевое исключение - вероятно, Tablerow пуст.
child: Table(
border: TableBorder.all(width: 1.0, color: Colors.black),
children: [
TableRow(
children: [
TableCell(
child: Row(
children: <Widget>[
new Padding(
padding: const EdgeInsets.all(5.0),
child: new Text('ID1'),
),
]
)
),
TableCell(
child: Row(
children: <Widget>[
new Padding(
padding: const EdgeInsets.all(5.0),
child: new Text('Name1'),
),
]
)
)
]
),
TableRow(
children: [
TableCell(
child: Row(
children: <Widget>[
new Padding(
padding: const EdgeInsets.all(5.0),
child: new Text('ID2'),
),
]
)
),
TableCell(
child: Row(
children: <Widget>[
new Padding(
padding: const EdgeInsets.all(5.0),
child: new Text('Name2'),
),
]
)
)
]
),
TableRow(
children: [
TableCell(
child: Row(
children: <Widget>[
new Padding(
padding: const EdgeInsets.all(5.0),
child: new Text('ID3'),
),
]
)
),
TableCell(
child: Row(
children: <Widget>[
new Padding(
padding: const EdgeInsets.all(5.0),
child: new Text('Name3'),
),
]
)
)
]
),
],
)
UPDATE:
bool_row ? TableRow(
children: [
TableCell(
child: Row(
children: <Widget>[
new Padding(
padding: const EdgeInsets.all(5.0),
child: new Text('ID2'),
),
]
)
),
TableCell(
child: Row(
children: <Widget>[
new Padding(
padding: const EdgeInsets.all(5.0),
child: new Text('Name2'),
),
]
)
)
]
) : TableRow(),
Используя логический метод, bool_row имеет значение false, 2-е условие «TableRow ()» выдает ошибку:
: метод 'any' был вызван для null.
: получатель: ноль
: пробный вызов: любой (закрытие: (виджет) => bool)
Я не знаю, как создать пустую невидимую TableRow.
На основании приведенного выше кода, если я хочу скрыть или установить 2-ую строку как невидимую. Как мне этого добиться?
Заранее спасибо!