我想通过使用flutter的文本字段将行值添加到数据表中

时间:2019-07-17 06:36:57

标签: flutter

我需要将值添加到数据表中,这些值应该是从文本字段检索的值

值正在添加到数据表中,但是现在我想添加多行,行值通过Textfield设置,还有一个是如何在Datatable中使用可除数

//数据表//

DataTable(
            columns: <DataColumn>[
              DataColumn(
                label: Text("DATA"),
              ),

            ],

            rows: <DataRow>[
              DataRow(

              cells:<DataCell> [
                DataCell(
                  Text(_stext)
                ),

// TextField //

TextField(
              controller: _controller,
              maxLength: 8,
              decoration: InputDecoration(
                suffixIcon: IconButton(
                    onPressed: ()
                {
                  _controller.clear();
                },
                  icon: Icon(
                    Icons.clear,
                    color: Colors.black54,
                  ),

                ),
                  border: new OutlineInputBorder(
              borderRadius: const BorderRadius.all(
                  const Radius.circular(20.0),
        ),
              ),
            ),),
Center(
  child: RaisedButton(
      onPressed: _onPressed,
    color: Colors.redAccent,
    child: Text('Add'),
  ),
),

1 个答案:

答案 0 :(得分:0)

您尝试过吗?

  cells:<DataCell> [
            DataCell(
              Text(_controller.text)
            ),
相关问题