地图飘动

2022-05-06

以下示例是关于Text中包含地图飘动用法的示例代码,想了解地图飘动的具体用法?地图飘动怎么用?地图飘动使用的例子?那么可以参考以下相关源代码片段来学习它的具体使用方法。

文件名:map_flutter[英]:map flutter源码类型:Text
    class EmployeeDataSource extends DataGridSource {
      EmployeeDataSource({required List<Employee> employees}) {
        _employees = employees;
        updateDataGridRows();
      }
     
      List<DataGridRow> dataGridRow = [];
      late List<Employee> _employees;
     
      void updateDataGridRows() {
        dataGridRow = _employees
            .map<DataGridRow>((e) => DataGridRow(cells: [
                  DataGridCell<int>(columnName: 'id', value: e.id),
                  DataGridCell<String>(columnName: 'name', value: e.name),
                  DataGridCell<String>(
                      columnName: 'designation', value: e.designation),
                  DataGridCell<int>(columnName: 'salary', value: e.salary),
                ]))
            .toList();
      }
     
      @override
      List<DataGridRow> get rows => dataGridRow;
     
      @override
      DataGridRowAdapter buildRow(DataGridRow row) {
        return DataGridRowAdapter(
            cells: row.getCells().map<Widget>((dataGridCell) {
          Color? columnBackgroundColor;
          if (dataGridCell.columnName == 'id') {
            columnBackgroundColor = Colors.tealAccent[100];
          } else if (dataGridCell.columnName == 'designation') {
            columnBackgroundColor = Colors.amberAccent[100];
          } else {
            columnBackgroundColor = Colors.transparent;
          }
     
          return Container(
            alignment: Alignment.center,
            color: columnBackgroundColor,
            padding: EdgeInsets.symmetric(horizontal: 16.0),
            child: Text(dataGridCell.value.toString()),
          );
        }).toList());
      }
    }

本文地址:https://www.itbaoku.cn/snippets/785391.html