Search code examples
flutterdatatableflutter-layout

Flutter DataTable header pinning issue


I could not find the flutter datatable header fixing process. How do I do this? I could not find this feature on the fixed datatable with Flutter. I used the DataTable2 library. But I couldn't come to a conclusion with this library either.


Solution

  • You can use SfDataGrid for alternative. https://pub.dev/packages/syncfusion_flutter_datagrid

    for example :

    List<Employee> employees = <Employee>[];
    
    late EmployeeDataSource employeeDataSource;
    
    @override
    void initState() {
      super.initState();
      employees= getEmployees();
      employeeDataSource = EmployeeDataSource(employees: employees);
    }
    
     List<Employee> getEmployees() {
      return[
      Employee(10001, 'James', 'Project Lead', 20000),
      Employee(10002, 'Kathryn', 'Manager', 30000),
      Employee(10003, 'Lara', 'Developer', 15000),
      Employee(10004, 'Michael', 'Designer', 15000),
      Employee(10005, 'Martin', 'Developer', 15000),
      Employee(10006, 'Newberry', 'Developer', 15000),
      Employee(10007, 'Balnc', 'Developer', 15000),
      Employee(10008, 'Perry', 'Developer', 15000),
      Employee(10009, 'Gable', 'Developer', 15000),
      Employee(10010, 'Grimes', 'Developer', 15000)
      ];
    }
    

    result :

    result SfDataGrid