maxim-saplin / data_table_2

In-place substitute for Flutter's DataTable and PaginatedDataTable with fixed/sticky header and extra features
https://pub.dev/packages/data_table_2
BSD 3-Clause "New" or "Revised" License
202 stars 135 forks source link

Only start stopwatch when dataTableShowLogs && kDebugMode is true #278

Open stan-at-work opened 4 months ago

stan-at-work commented 4 months ago

Now every build a stopwatch is created in debug and release mode.

If the properties dataTableShowLogs && kDebugMode are not true, it's created and started every build.

This is unnecessary.

Quick fix: Now


@override
Widget build(BuildContext context) {
var sw = Stopwatch();
sw.start();
...

sw.stop();

if (dataTableShowLogs && kDebugMode) {
  debugPrint('DataTable2 built: ${sw.elapsedMilliseconds}ms');
}

**How it could be**
```dart
    Stopwatch? sw;

  @override
  Widget build(BuildContext context) {
     if (dataTableShowLogs && kDebugMode){
     sw = Stopwatch();
     sw.start();
     }

...

    if (dataTableShowLogs && kDebugMode) {
      sw.stop();
      debugPrint('DataTable2 built: ${sw.elapsedMilliseconds}ms');
    }
npateras commented 3 months ago

And also pls add a property to disable the debug completely