From a762525d91e87ea45f0ceeded50f093e9a8cbb82 Mon Sep 17 00:00:00 2001 From: Maxim Saplin Date: Mon, 16 Dec 2024 09:28:30 +0300 Subject: [PATCH] Fixing warnings, minor changes to align with Flutter 3.27.0 --- example/lib/screens/async_paginated_data_table2.dart | 2 +- example/macos/Runner/AppDelegate.swift | 6 +++++- lib/src/async_paginated_data_table_2.dart | 4 +++- lib/src/data_table_2.dart | 4 ++-- test/chasing_coverage_test.dart | 4 ++-- test/data_table_2_data_column_2_test.dart | 2 +- test/data_table_2_test.dart | 2 +- 7 files changed, 15 insertions(+), 9 deletions(-) diff --git a/example/lib/screens/async_paginated_data_table2.dart b/example/lib/screens/async_paginated_data_table2.dart index 1d9ce1fe..563db899 100644 --- a/example/lib/screens/async_paginated_data_table2.dart +++ b/example/lib/screens/async_paginated_data_table2.dart @@ -244,7 +244,7 @@ class _ErrorAndRetry extends StatelessWidget { Widget build(BuildContext context) => Center( child: Container( padding: const EdgeInsets.all(10), - height: 70, + height: 80, color: Colors.red, child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, diff --git a/example/macos/Runner/AppDelegate.swift b/example/macos/Runner/AppDelegate.swift index d53ef643..b3c17614 100644 --- a/example/macos/Runner/AppDelegate.swift +++ b/example/macos/Runner/AppDelegate.swift @@ -1,9 +1,13 @@ import Cocoa import FlutterMacOS -@NSApplicationMain +@main class AppDelegate: FlutterAppDelegate { override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { return true } + + override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { + return true + } } diff --git a/lib/src/async_paginated_data_table_2.dart b/lib/src/async_paginated_data_table_2.dart index 1ce3f046..20ab7188 100644 --- a/lib/src/async_paginated_data_table_2.dart +++ b/lib/src/async_paginated_data_table_2.dart @@ -293,7 +293,9 @@ abstract class AsyncDataTableSource extends DataTableSource { @override DataRow? getRow(int index) { if (index - _firstRowAbsoluteIndex < 0 || - index >= _rows.length + _firstRowAbsoluteIndex) return null; + index >= _rows.length + _firstRowAbsoluteIndex) { + return null; + } index -= _firstRowAbsoluteIndex; _fixSelectedState(index); diff --git a/lib/src/data_table_2.dart b/lib/src/data_table_2.dart index 6c7f959c..3fce01d0 100644 --- a/lib/src/data_table_2.dart +++ b/lib/src/data_table_2.dart @@ -519,7 +519,7 @@ class DataTable2 extends DataTable { child: DefaultTextStyle( style: effectiveDataTextStyle.copyWith( color: placeholder - ? effectiveDataTextStyle.color!.withOpacity(0.6) + ? effectiveDataTextStyle.color!.withValues(alpha: 0.6) : null, ), child: DropdownButtonHideUnderline(child: label), @@ -589,7 +589,7 @@ class DataTable2 extends DataTable { final defaultRowColor = WidgetStateProperty.resolveWith( (Set states) { if (states.contains(WidgetState.selected)) { - return theme.colorScheme.primary.withOpacity(0.08); + return theme.colorScheme.primary.withValues(alpha: 0.08); } return null; }, diff --git a/test/chasing_coverage_test.dart b/test/chasing_coverage_test.dart index 30d6df0a..ec3aa6b3 100644 --- a/test/chasing_coverage_test.dart +++ b/test/chasing_coverage_test.dart @@ -73,7 +73,7 @@ void main() { .first .widget as DefaultTextStyle; - expect(t.style.color!.opacity, 0.6); + expect(t.style.color!.a, 0.6); }); testWidgets('DataTable2, placholder text is 0.6 opacity', (WidgetTester tester) async { @@ -107,7 +107,7 @@ void main() { .first .widget as DefaultTextStyle; - expect(t.style.color!.opacity, 0.6); + expect(t.style.color!.a, 0.6); }); testWidgets('DataTable2, divider thickness 0 shows no border', diff --git a/test/data_table_2_data_column_2_test.dart b/test/data_table_2_data_column_2_test.dart index 013b2d78..332cabd7 100644 --- a/test/data_table_2_data_column_2_test.dart +++ b/test/data_table_2_data_column_2_test.dart @@ -1466,7 +1466,7 @@ void main() { await tester.pumpWidget(buildTable(selected: true)); expect( lastTableRowBoxDecoration().color, - themeData.colorScheme.primary.withOpacity(0.08), + themeData.colorScheme.primary..withValues(alpha: 0.08), ); }); diff --git a/test/data_table_2_test.dart b/test/data_table_2_test.dart index e1bcf6a8..51d216f0 100644 --- a/test/data_table_2_test.dart +++ b/test/data_table_2_test.dart @@ -1971,7 +1971,7 @@ void main() { await tester.pumpWidget(buildTable(selected: true)); expect( lastTableRowBoxDecoration().color, - themeData.colorScheme.primary.withOpacity(0.08), + themeData.colorScheme.primary.withValues(alpha: 0.08), ); });