diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 080ba9c..4c28d7b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,24 +1,21 @@ name: 'โš™๏ธ CI' on: push: + branches: + - main pull_request: workflow_dispatch: jobs: unit-tests: - strategy: - matrix: - channel: - - beta - - stable - name: 'Testing [${{matrix.channel}}] ๐Ÿงช' - runs-on: ubuntu-latest + name: 'Testing ๐Ÿงช' + runs-on: ubuntu-slim steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - uses: subosito/flutter-action@v2 with: - channel: ${{ matrix.channel }} + channel: stable cache: true - run: flutter config --no-analytics --suppress-analytics - name: Package tests @@ -28,9 +25,9 @@ jobs: working-directory: example dart-lints: name: 'Linting ๐Ÿ“' - runs-on: ubuntu-latest + runs-on: ubuntu-slim steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - uses: subosito/flutter-action@v2 with: channel: stable @@ -42,11 +39,15 @@ jobs: run: flutter analyze working-directory: example dart-format: + if: false # FIXME: format behaves differently in CI name: "Formating โœ…" - runs-on: ubuntu-latest + runs-on: ubuntu-slim steps: - - uses: actions/checkout@v4 - - uses: dart-lang/setup-dart@v1 + - uses: actions/checkout@v6 + - uses: subosito/flutter-action@v2 + with: + channel: stable + cache: true - name: "Package format" run: dart format --output show --set-exit-if-changed . - name: "Example format" diff --git a/CHANGELOG.md b/CHANGELOG.md index b35c85e..de730fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.2 + +* Follow latest flutter lints + ## 1.0.1 * fix focus traversal diff --git a/analysis_options.yaml b/analysis_options.yaml index 8ed14a4..e4778ab 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,3 +1,5 @@ +include: package:flutter_lints/flutter.yaml + linter: rules: # Prevent code errors: @@ -13,7 +15,6 @@ linter: - type_annotate_public_apis - eol_at_end_of_file - package_api_docs - - public_member_api_docs # Style - avoid_escaping_inner_quotes @@ -40,4 +41,10 @@ linter: - use_colored_box - use_decorated_box - use_if_null_to_convert_nulls_to_bools - - use_to_and_as_if_applicable \ No newline at end of file + - use_to_and_as_if_applicable + +analyzer: + language: + strict-inference: true + strict-raw-types: true + strict-casts: true \ No newline at end of file diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml index b06ae0c..b0de520 100644 --- a/example/analysis_options.yaml +++ b/example/analysis_options.yaml @@ -1,3 +1,5 @@ +include: package:flutter_lints/flutter.yaml + linter: rules: # Prevent code errors: @@ -39,4 +41,10 @@ linter: - use_colored_box - use_decorated_box - use_if_null_to_convert_nulls_to_bools - - use_to_and_as_if_applicable \ No newline at end of file + - use_to_and_as_if_applicable + +analyzer: + language: + strict-inference: true + strict-raw-types: true + strict-casts: false \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index b32c349..6dd9926 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -5,9 +5,9 @@ void main() { runApp(MaterialApp( title: 'InlineTabView examples', theme: ThemeData( - colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), - useMaterial3: true, - appBarTheme: AppBarTheme(color: Colors.teal)), + colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), + useMaterial3: true, + ), home: Scaffold( appBar: AppBar(title: Text('InlineTabView examples')), body: const InlineTabViewExample(), diff --git a/example/pubspec.lock b/example/pubspec.lock index 0565ad1..c5b77e1 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -21,39 +21,47 @@ packages: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.4.1" clock: dependency: transitive description: name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.1.2" collection: dependency: transitive description: name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" url: "https://pub.dev" source: hosted - version: "1.18.0" + version: "1.19.1" fake_async: dependency: transitive description: name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.3.3" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: "3105dc8492f6183fb076ccf1f351ac3d60564bff92e20bfc4af9cc1651f4e7e1" + url: "https://pub.dev" + source: hosted + version: "6.0.0" flutter_test: dependency: "direct dev" description: flutter @@ -65,68 +73,76 @@ packages: path: ".." relative: true source: path - version: "1.0.1" + version: "1.0.2" leak_tracker: dependency: transitive description: name: leak_tracker - sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" url: "https://pub.dev" source: hosted - version: "10.0.5" + version: "11.0.2" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" url: "https://pub.dev" source: hosted - version: "3.0.5" + version: "3.0.10" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.0.2" + lints: + dependency: transitive + description: + name: lints + sha256: "12f842a479589fea194fe5c5a3095abc7be0c1f2ddfa9a0e76aed1dbd26a87df" + url: "https://pub.dev" + source: hosted + version: "6.1.0" matcher: dependency: transitive description: name: matcher - sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861 url: "https://pub.dev" source: hosted - version: "0.12.16+1" + version: "0.12.19" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b" url: "https://pub.dev" source: hosted - version: "0.11.1" + version: "0.13.0" meta: dependency: transitive description: name: meta - sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 + sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349" url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.18.0" path: dependency: transitive description: name: path - sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.9.1" sky_engine: dependency: transitive description: flutter source: sdk - version: "0.0.99" + version: "0.0.0" source_span: dependency: transitive description: @@ -139,18 +155,18 @@ packages: dependency: transitive description: name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" url: "https://pub.dev" source: hosted - version: "1.11.1" + version: "1.12.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" string_scanner: dependency: transitive description: @@ -171,18 +187,18 @@ packages: dependency: transitive description: name: test_api - sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" + sha256: "949a932224383300f01be9221c39180316445ecb8e7547f70a41a35bf421fb9e" url: "https://pub.dev" source: hosted - version: "0.7.2" + version: "0.7.11" vector_math: dependency: transitive description: name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b url: "https://pub.dev" source: hosted - version: "2.1.4" + version: "2.2.0" vm_service: dependency: transitive description: @@ -192,5 +208,5 @@ packages: source: hosted version: "14.2.5" sdks: - dart: ">=3.5.3 <4.0.0" + dart: ">=3.10.0-0 <4.0.0" flutter: ">=3.18.0-18.0.pre.54" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 5cb5efb..6640e16 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,7 +1,7 @@ name: example description: "A new Flutter project." publish_to: 'none' # Remove this line if you wish to publish to pub.d -version: 1.0.0+1 +version: 1.0.1+2 environment: sdk: ^3.5.3 @@ -13,6 +13,7 @@ dependencies: path: ../ dev_dependencies: + flutter_lints: ^6.0.0 flutter_test: sdk: flutter diff --git a/lib/src/inline_tab_view_render_object.dart b/lib/src/inline_tab_view_render_object.dart index 9ffdd9a..d03ab83 100644 --- a/lib/src/inline_tab_view_render_object.dart +++ b/lib/src/inline_tab_view_render_object.dart @@ -101,7 +101,9 @@ class InlineTabViewRenderObject extends RenderBox // avoid oob scroll if (controller.index == 0 && offset < 0 || - controller.index == (controller.length - 1) && offset > 0) offset = 0; + controller.index == (controller.length - 1) && offset > 0) { + offset = 0; + } if (!controller.indexIsChanging) controller.offset = offset; markNeedsPaint(); @@ -127,8 +129,9 @@ class InlineTabViewRenderObject extends RenderBox nextTab?.layout(constraints, parentUsesSize: true); previousTab?.layout(constraints, parentUsesSize: true); visitChildren((RenderObject child) { - if (child == selectedTab || child == nextTab || child == previousTab) + if (child == selectedTab || child == nextTab || child == previousTab) { return; + } child.layout(constraints); }); @@ -238,14 +241,19 @@ class InlineTabViewRenderObject extends RenderBox final primaryRightBorder = _relativeCentralDrawPosition + (primaryChild.size.width / 2); - if (primaryRightBorder > 0.0 && primaryLeftBorder < size.width) + if (primaryRightBorder > 0.0 && primaryLeftBorder < size.width) { visitor(primaryChild); + } if (nextChild != null && primaryRightBorder + size.width > 0.0 && - primaryLeftBorder + size.width < size.width) visitor(nextChild); + primaryLeftBorder + size.width < size.width) { + visitor(nextChild); + } if (previousChild != null && primaryRightBorder - size.width > 0.0 && - primaryLeftBorder - size.width < size.width) visitor(previousChild); + primaryLeftBorder - size.width < size.width) { + visitor(previousChild); + } } @override diff --git a/lib/src/inline_tab_view_widget.dart b/lib/src/inline_tab_view_widget.dart index cc76780..6052440 100644 --- a/lib/src/inline_tab_view_widget.dart +++ b/lib/src/inline_tab_view_widget.dart @@ -47,7 +47,7 @@ class _InlineTabViewElement extends MultiChildRenderObjectElement { void debugVisitOnstageChildren(ElementVisitor visitor) { // This feels kind of hacky, but it's the only way I could find that // hides the offstage children from the widget tester. - final renderObjectChildren = []; + final renderObjectChildren = []; renderObject.visitChildrenForSemantics(renderObjectChildren.add); children .where((Element e) => renderObjectChildren.contains(e.renderObject)) diff --git a/lib/src/offscreen_focus_exclusion_builder.dart b/lib/src/offscreen_focus_exclusion_builder.dart index 09b4e60..4ced3c8 100644 --- a/lib/src/offscreen_focus_exclusion_builder.dart +++ b/lib/src/offscreen_focus_exclusion_builder.dart @@ -26,9 +26,10 @@ class OffscreenFocusExclusionBuilder extends StatelessWidget { @override Widget build(BuildContext context) => ListenableBuilder( listenable: controller, - builder: (BuildContext context, Widget? _child) { - if (controller.indexIsChanging) + builder: (BuildContext context, _) { + if (controller.indexIsChanging) { return ExcludeFocus(child: builder(children)); + } return builder([ for (int i = 0; i < children.length; i++) ExcludeFocus( diff --git a/pubspec.yaml b/pubspec.yaml index 706fadd..282cc31 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: inline_tab_view description: "A TabBarView that can be nested in scrollables while sticking to flutter best practices and avoiding hacks." -version: 1.0.1 +version: 1.0.2 repository: https://github.com/derdilla/inline_tab_view environment: @@ -12,5 +12,6 @@ dependencies: sdk: flutter dev_dependencies: + flutter_lints: ^6.0.0 flutter_test: sdk: flutter diff --git a/test/inline_tab_view_test.dart b/test/inline_tab_view_test.dart index 4bde850..b1c2321 100644 --- a/test/inline_tab_view_test.dart +++ b/test/inline_tab_view_test.dart @@ -94,8 +94,8 @@ void main() { expect(find.text('Tab 1').hitTestable(), findsOneWidget); expect(find.text('Tab 2').hitTestable(), findsNothing); - final center = await tester.getCenter(find.byType(InlineTabView)); - final leftEdge = await tester.getBottomLeft(find.byType(InlineTabView)).dx; + final center = tester.getCenter(find.byType(InlineTabView)); + final leftEdge = tester.getBottomLeft(find.byType(InlineTabView)).dx; // Start drag final gesture = await tester.startGesture(Offset(center.dx, center.dy)); @@ -129,7 +129,7 @@ void main() { expect(find.text('Tab 4').hitTestable(), findsNothing); expect(find.text('Tab 5').hitTestable(), findsNothing); - final center = await tester.getCenter(find.byType(InlineTabView)); + final center = tester.getCenter(find.byType(InlineTabView)); final gesture = await tester.startGesture(Offset(center.dx, center.dy)); await tester.pump(); await gesture.moveTo(center + Offset(-20.0, 5.0)); @@ -177,7 +177,7 @@ void main() { expect(tester.takeException(), isNull); - final center = await tester.getCenter(find.byType(InlineTabView)); + final center = tester.getCenter(find.byType(InlineTabView)); await tester.startGesture(Offset(center.dx, center.dy)); expect(tester.takeException(), isNull); @@ -205,7 +205,7 @@ void main() { expect(tester.takeException(), isNull); - final center = await tester.getCenter(find.byType(InlineTabView)); + final center = tester.getCenter(find.byType(InlineTabView)); final gesture = await tester.startGesture(Offset(center.dx, center.dy)); expect(tester.takeException(), isNull); @@ -234,7 +234,7 @@ void main() { )); expect(tester.takeException(), isNull); - final center = await tester.getCenter(find.byType(InlineTabView)); + final center = tester.getCenter(find.byType(InlineTabView)); final gesture = await tester.startGesture(Offset(center.dx, center.dy)); expect(tester.takeException(), isNull);