sort method Null safety

void sort()

Call this method when you are adding the SortColumnDetails programmatically to the DataGridSource.sortedColumns.

@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      title: const Text('Syncfusion Flutter DataGrid'),
    ),
    body: Column(
      children: [
        FlatButton(
          child: Text('Click'),
          onPressed: () {
            _employeeDataSource.sortedColumns
                .add(SortColumnDetails('id', SortDirection.ascending));
            _employeeDataSource.sort();
          },
        ),
        SfDataGrid(
          source: _employeeDataSource,
          allowSorting: true,
          columns: <GridColumn>[
              GridColumn(columnName: 'id', label:Text('ID')),
              GridColumn(columnName: 'name', label:Text('Name')),
              GridColumn(columnName: 'designation', label: Text('Designation')),
              GridColumn(columnName: 'salary', label: Text('Salary')),
          ],
        ),
      ],
    ),
  );
}

Implementation

void sort() {
  _updateDataSource();
  _notifyDataGridPropertyChangeListeners(propertyName: 'Sorting');
}