syncfusion / flutter-widgets

Syncfusion Flutter widgets libraries include high quality UI widgets and file-format packages to help you create rich, high-quality applications for iOS, Android, and web from a single code base.
1.48k stars 702 forks source link

[syncfusion_date_picker] The getter 'isAltPressed' isn't defined for the class 'HardwareKeyboard'. #1733

Open nashihu opened 3 months ago

nashihu commented 3 months ago

Hello, I'm using Flutter 3.16.9

I added syncfusion_flutter_datepicker: ^24.2.9 to pubspec.

I'm not using any code from syncfusion yet, but after adding to pubspec, i got this error

log ../../../../.pub-cache/hosted/pub.dev/syncfusion_flutter_datepicker-24.2.9/lib/src/date_picker/date_picker.dart:10064:35: Error: The getter 'isAltPressed' isn't defined for the class 'HardwareKeyboard'. 'HardwareKeyboard' is from 'package:flutter/src/services/hardware_keyboard.dart' ('../../../../flutter/packages/flutter/lib/src/services/hardware_keyboard.dart'). Try correcting the name to the name of an existing getter, or defining a getter or field named 'isAltPressed'. if (HardwareKeyboard.instance.isAltPressed) { ^^^^^^^^^^^^ ../../../../.pub-cache/hosted/pub.dev/syncfusion_flutter_datepicker-24.2.9/lib/src/date_picker/date_picker.dart:10108:35: Error: The getter 'isShiftPressed' isn't defined for the class 'HardwareKeyboard'. 'HardwareKeyboard' is from 'package:flutter/src/services/hardware_keyboard.dart' ('../../../../flutter/packages/flutter/lib/src/services/hardware_keyboard.dart'). Try correcting the name to the name of an existing getter, or defining a getter or field named 'isShiftPressed'. HardwareKeyboard.instance.isShiftPressed) { ^^^^^^^^^^^^^^ ../../../../.pub-cache/hosted/pub.dev/syncfusion_flutter_datepicker-24.2.9/lib/src/date_picker/date_picker.dart:10131:35: Error: The getter 'isShiftPressed' isn't defined for the class 'HardwareKeyboard'. 'HardwareKeyboard' is from 'package:flutter/src/services/hardware_keyboard.dart' ('../../../../flutter/packages/flutter/lib/src/services/hardware_keyboard.dart'). Try correcting the name to the name of an existing getter, or defining a getter or field named 'isShiftPressed'. HardwareKeyboard.instance.isShiftPressed) { ^^^^^^^^^^^^^^ ../../../../.pub-cache/hosted/pub.dev/syncfusion_flutter_datepicker-24.2.9/lib/src/date_picker/date_picker.dart:10320:35: Error: The getter 'isShiftPressed' isn't defined for the class 'HardwareKeyboard'. 'HardwareKeyboard' is from 'package:flutter/src/services/hardware_keyboard.dart' ('../../../../flutter/packages/flutter/lib/src/services/hardware_keyboard.dart'). Try correcting the name to the name of an existing getter, or defining a getter or field named 'isShiftPressed'. if (HardwareKeyboard.instance.isShiftPressed && ^^^^^^^^^^^^^^ ../../../../.pub-cache/hosted/pub.dev/syncfusion_flutter_datepicker-24.2.9/lib/src/date_picker/date_picker.dart:10335:35: Error: The getter 'isControlPressed' isn't defined for the class 'HardwareKeyboard'. 'HardwareKeyboard' is from 'package:flutter/src/services/hardware_keyboard.dart' ('../../../../flutter/packages/flutter/lib/src/services/hardware_keyboard.dart'). Try correcting the name to the name of an existing getter, or defining a getter or field named 'isControlPressed'. if (HardwareKeyboard.instance.isControlPressed) { ^^^^^^^^^^^^^^^^ ../../../../.pub-cache/hosted/pub.dev/syncfusion_flutter_datepicker-24.2.9/lib/src/date_picker/date_picker.dart:10563:35: Error: The getter 'isShiftPressed' isn't defined for the class 'HardwareKeyboard'. 'HardwareKeyboard' is from 'package:flutter/src/services/hardware_keyboard.dart' ('../../../../flutter/packages/flutter/lib/src/services/hardware_keyboard.dart'). Try correcting the name to the name of an existing getter, or defining a getter or field named 'isShiftPressed'. if (HardwareKeyboard.instance.isShiftPressed && ^^^^^^^^^^^^^^ ../../../../.pub-cache/hosted/pub.dev/syncfusion_flutter_datepicker-24.2.9/lib/src/date_picker/date_picker.dart:10586:42: Error: The getter 'isShiftPressed' isn't defined for the class 'HardwareKeyboard'. 'HardwareKeyboard' is from 'package:flutter/src/services/hardware_keyboard.dart' ('../../../../flutter/packages/flutter/lib/src/services/hardware_keyboard.dart'). Try correcting the name to the name of an existing getter, or defining a getter or field named 'isShiftPressed'. } else if (HardwareKeyboard.instance.isShiftPressed && ^^^^^^^^^^^^^^ ../../../../.pub-cache/hosted/pub.dev/syncfusion_flutter_datepicker-24.2.9/lib/src/date_picker/date_picker.dart:10609:42: Error: The getter 'isShiftPressed' isn't defined for the class 'HardwareKeyboard'. 'HardwareKeyboard' is from 'package:flutter/src/services/hardware_keyboard.dart' ('../../../../flutter/packages/flutter/lib/src/services/hardware_keyboard.dart'). Try correcting the name to the name of an existing getter, or defining a getter or field named 'isShiftPressed'. } else if (HardwareKeyboard.instance.isShiftPressed && ^^^^^^^^^^^^^^ ../../../../.pub-cache/hosted/pub.dev/syncfusion_flutter_datepicker-24.2.9/lib/src/date_picker/date_picker.dart:10632:42: Error: The getter 'isShiftPressed' isn't defined for the class 'HardwareKeyboard'. 'HardwareKeyboard' is from 'package:flutter/src/services/hardware_keyboard.dart' ('../../../../flutter/packages/flutter/lib/src/services/hardware_keyboard.dart'). Try correcting the name to the name of an existing getter, or defining a getter or field named 'isShiftPressed'. } else if (HardwareKeyboard.instance.isShiftPressed &&
nashihu commented 3 months ago

for me it works using syncfusion_flutter_datepicker: "24.2.6"

i suggest to add sdk constraint in pubspec if it's related to flutter sdk requirement

Yuvaraj-Gajaraj commented 3 months ago

Hi @nashihu ,

We have migrated our source which is compatible with Flutter SDK 3.19.0, in Flutter SDK version 3.19.0 they have done breaking changes in the RawKeyEvent and replaced it with HardWareKeyBoard. So, we kindly request you to upgrade the Flutter SDK version to 3.19.0 or else use the packages syncfusion_flutter_datepicker version below 24.2.7. We have also shared the breaking changes documentation below for your reference.

We hope it will help you to resolve the issue, if you have any further queries please get back to us. We are always happy to assist you.

Flutter 3.19.0 breaking change, https://docs.flutter.dev/release/breaking-changes/key-event-migration#migrating-iskeypressed-and-related-functions

Regards, Yuvaraj.

SwethaRajendran07 commented 1 month ago

Hi @nashihu ,

We have migrated our source which is compatible with Flutter SDK 3.19.0, in Flutter SDK version 3.19.0 they have done breaking changes in the RawKeyEvent and replaced it with HardWareKeyBoard. So, we kindly request you to upgrade the Flutter SDK version to 3.19.0 or else use the packages syncfusion_flutter_datepicker version below 24.2.7. We have also shared the breaking changes documentation below for your reference.

We hope it will help you to resolve the issue, if you have any further queries please get back to us. We are always happy to assist you.

Flutter 3.19.0 breaking change, https://docs.flutter.dev/release/breaking-changes/key-event-migration#migrating-iskeypressed-and-related-functions

Regards, Yuvaraj.

hi ,

i have an issue similar to this My error: Error: The getter 'isControlPressed' isn't defined for the class 'HardwareKeyboard'.

Code: @override Widget build(BuildContext context) { final callsProvider = Provider.of(context); return Scaffold( appBar: AppBar( title: Text('Calls'), ), body: Column( children: [ SfDataGrid( source: CallsDataTableSource(callsProvider.calls), headerGridLinesVisibility: GridLinesVisibility.horizontal, frozenColumnsCount: 2, columns: [ GridColumn(label: Text('ID'), columnName: 'ID'), GridColumn(label: Text('Sender'), columnName: 'SENDER'), GridColumn(label: Text('Recipient'), columnName: 'RECIPIENT'), GridColumn(label: Text('Call Notes'), columnName: 'ID'), GridColumn(label: Text('Time Stamp'), columnName: 'ID'), GridColumn(label: Text('Created On'), columnName: 'ID'), ],

      )
    ],
  ),
);

} } class CallsDataTableSource extends DataGridSource { final List calls; // Assuming Call is the type of objects in callsProvider.calls

CallsDataTableSource(this.calls);

@override DataRow? getRow(int index) { if (index >= calls.length) { return null; } final call = calls[index]; return DataRow(cells: [ DataCell(Text("${index +1}",style: MyTextStyle.blackText15)), // Replace field1, field2, etc. with actual fields from Call DataCell(Text(call.userId!.firstName.toString(),style: MyTextStyle.blackText15,)), // Replace field1, field2, etc. with actual fields from Call DataCell(Text(call.leadId!.name.toString(),style: MyTextStyle.blackText15)), DataCell(Text(call.callNotes.toString(),style: MyTextStyle.blackText15)), DataCell(Text(call.timestamp.toString(),style: MyTextStyle.blackText15)), DataCell(Text(call.startAt.toString(),style: MyTextStyle.blackText15)), // Add more DataCells as needed for each field in Call ]); }

@override bool get isRowCountApproximate => true;

@override int get rowCount => calls.length;

@override int get selectedRowCount => 0;

@override DataGridRowAdapter? buildRow(DataGridRow row) { // TODO: implement buildRow throw UnimplementedError(); } }

but the below code works fine : class _MyDataGridState extends State { final int _rowsPerPage = 5; final List _data = List.generate( 50, (index) => DataGridRow(cells: [ DataGridCell(columnName: 'Index', value: index + 1), DataGridCell(columnName: 'Value', value: 'Value ${index + 1}'), DataGridCell(columnName: 'Value', value: 'Value ${index + 1}'), DataGridCell(columnName: 'Value', value: 'Value ${index + 1}'), DataGridCell(columnName: 'Value', value: 'Value ${index + 1}'), ]), );

@override Widget build(BuildContext context) { return SfDataGrid( frozenColumnsCount: 2, source: _MyDataSource(), columns: [ GridColumn( columnName: 'Index', label: Container( padding: EdgeInsets.all(8), alignment: Alignment.center, color: Colors.blueGrey[100], child: Text( 'Index', style: TextStyle(fontWeight: FontWeight.bold), ), ), width: 100, // headerText: 'Index', // headerTextAlignment: Alignment.center, ), GridColumn( columnName: 'Value', label: Container( padding: EdgeInsets.all(8), alignment: Alignment.center, color: Colors.blueGrey[100], child: Text( 'Value', style: TextStyle(fontWeight: FontWeight.bold), ), ), // headerText: 'Value', // headerTextAlignment: Alignment.center, ), GridColumn( columnName: 'Value1', label: Container( padding: EdgeInsets.all(8), alignment: Alignment.center, color: Colors.blueGrey[100], child: Text( 'Value1', style: TextStyle(fontWeight: FontWeight.bold), ), ), // headerText: 'Value', // headerTextAlignment: Alignment.center, ), GridColumn( columnName: 'Value2', label: Container( padding: EdgeInsets.all(8), alignment: Alignment.center, color: Colors.blueGrey[100], child: Text( 'Value2', style: TextStyle(fontWeight: FontWeight.bold), ), ), // headerText: 'Value', // headerTextAlignment: Alignment.center, ), GridColumn( columnName: 'Value3', label: Container( padding: EdgeInsets.all(8), alignment: Alignment.center, color: Colors.blueGrey[100], child: Text( 'Value3', style: TextStyle(fontWeight: FontWeight.bold), ), ), // headerText: 'Value', // headerTextAlignment: Alignment.center, ), // Add more columns as needed ], allowSorting: true, // paginationMode: PagingMode.paging, // pageSize: _rowsPerPage, headerGridLinesVisibility: GridLinesVisibility.horizontal, ); } }

class _MyDataSource extends DataGridSource { @override List get rows => _MyDataGridState()._data;

@override DataGridRowAdapter buildRow(DataGridRow row) { return DataGridRowAdapter( cells: row.getCells().map((dataCell) { return Container( alignment: Alignment.center, padding: EdgeInsets.all(8), child: Text(dataCell.value.toString()), ); }).toList(), ); } }

LokeshPalani commented 1 month ago

Hi @nashihu,

We have updated our package from version 24.2.7 to be compatible with Flutter SDK v3.19.0. In Flutter SDK v3.19.0 they have done breaking changes in the RawKeyEvent and replaced it with HardWareKeyBoard. So, we kindly request you to upgrade the Flutter SDK version to 3.19.0. We have also shared the breaking changes documentation below for your reference.

Flutter 3.19.0 breaking change, https://docs.flutter.dev/release/breaking-changes/key-event-migration#migrating-iskeypressed-and-related-functions

Also, we would like to share our package compatibility with respect to the Flutter SDK below.

UG: https://help.syncfusion.com/flutter/system-requirements#sdk-version-compatibility

We hope it will help you to resolve the issue. If you are still facing issue, we recommend that you check by clearing the cache using the below mentioned methods:

Regards, Lokesh P.