diff --git a/.fvmrc b/.fvmrc new file mode 100644 index 0000000..cf74490 --- /dev/null +++ b/.fvmrc @@ -0,0 +1,3 @@ +{ + "flutter": "3.22.3" +} \ No newline at end of file diff --git a/.github/workflows/code_check.yaml b/.github/workflows/code_check.yaml index 421e8ed..a49c430 100644 --- a/.github/workflows/code_check.yaml +++ b/.github/workflows/code_check.yaml @@ -15,8 +15,8 @@ jobs: pull-requests: read outputs: flutter-file-changed: ${{ steps.filter.outputs.flutter-file-changed }} - lowest-flutter-version: ${{ steps.flutter-version-constraint.outputs.lowest }} - highest-flutter-version: ${{ steps.flutter-version-constraint.outputs.highest }} + flutter-lower-bound: ${{ steps.flutter-version-constraint.outputs.lower-bound }} + flutter-upper-bound: ${{ steps.flutter-version-constraint.outputs.upper-bound }} steps: - uses: actions/checkout@v4 @@ -32,22 +32,19 @@ jobs: - name: Get Flutter SDK version constraint id: flutter-version-constraint + # Extract the lower bound from pubspec.yaml and the upper bound from .fvmrc run: | sdk_constraint=$(cat pubspec.yaml | yq .environment.flutter) - lowest=$(echo "$sdk_constraint" | grep -oP '(?<=\>=)[0-9]+\.[0-9]+\.[0-9]+' | head -1) - highest=$(echo "$sdk_constraint" | grep -oP '(?<=\<)[0-9]+\.[0-9]+\.[0-9]+' | head -1) - # If no upper bound is specified, default to 3.x - if [ -z "$highest" ]; then - highest="3.x" - fi - echo "lowest=$lowest" >> "$GITHUB_OUTPUT" - echo "highest=$highest" >> "$GITHUB_OUTPUT" + lower_bound=$(echo "$sdk_constraint" | grep -oP '(?<=\>=)[0-9]+\.[0-9]+\.[0-9]+' | head -1) + upper_bound=$(cat .fvmrc | jq -r .flutter) + echo "lower-bound=$lower_bound" >> "$GITHUB_OUTPUT" + echo "upper-bound=$upper_bound" >> "$GITHUB_OUTPUT" - name: Print output values run: | echo "flutter-file-changed=${{ steps.filter.outputs.flutter-file-changed }}" - echo "lowest-flutter-version=${{ steps.flutter-version-constraint.outputs.lowest }}" - echo "highest-flutter-version=${{ steps.flutter-version-constraint.outputs.highest }}" + echo "flutter-lower-bound=${{ steps.flutter-version-constraint.outputs.lower-bound }}" + echo "flutter-upper-bound=${{ steps.flutter-version-constraint.outputs.upper-bound }}" analysis: needs: setup @@ -56,8 +53,8 @@ jobs: strategy: matrix: flutter-version: - - ${{ needs.setup.outputs.lowest-flutter-version }} - - ${{ needs.setup.outputs.highest-flutter-version }} + - ${{ needs.setup.outputs.flutter-lower-bound }} + - ${{ needs.setup.outputs.flutter-upper-bound }} steps: - name: Checkout uses: actions/checkout@v4 @@ -87,8 +84,8 @@ jobs: strategy: matrix: flutter-version: - - ${{ needs.setup.outputs.lowest-flutter-version }} - - ${{ needs.setup.outputs.highest-flutter-version }} + - ${{ needs.setup.outputs.flutter-lower-bound }} + - ${{ needs.setup.outputs.flutter-upper-bound }} steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.gitignore b/.gitignore index 6bc4ab4..3b67647 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ migrate_working_dir/ .dart_tool/ .packages build/ + +# FVM Version Cache +.fvm/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..acb7585 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "dart.flutterSdkPath": ".fvm/versions/3.22.3" +} \ No newline at end of file diff --git a/example/pubspec.lock b/example/pubspec.lock index dcbd692..b8618ad 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -195,7 +195,7 @@ packages: path: ".." relative: true source: path - version: "0.9.3" + version: "0.9.4" source_span: dependency: transitive description: diff --git a/test/modal/modal_sheet_test.dart b/test/modal/modal_sheet_test.dart index cfeeaaf..5e3fba1 100644 --- a/test/modal/modal_sheet_test.dart +++ b/test/modal/modal_sheet_test.dart @@ -147,4 +147,79 @@ void main() { }, ); }); + + // Regression test for https://github.com/fujidaiti/smooth_sheets/issues/233 + group('PopScope test', () { + late bool isOnPopInvokedCalled; + late Widget testWidget; + + setUp(() { + isOnPopInvokedCalled = false; + testWidget = MaterialApp( + home: Builder( + builder: (context) { + return Scaffold( + body: Center( + child: ElevatedButton( + onPressed: () { + Navigator.push( + context, + ModalSheetRoute( + swipeDismissible: true, + builder: (context) { + return DraggableSheet( + child: PopScope( + canPop: false, + onPopInvoked: (didPop) { + isOnPopInvokedCalled = true; + }, + child: Container( + key: const Key('sheet'), + color: Colors.white, + width: double.infinity, + height: 200, + ), + ), + ); + }, + ), + ); + }, + child: const Text('Open modal'), + ), + ), + ); + }, + ), + ); + }); + + testWidgets( + 'PopScope.onPopInvoked should be called when tap on barrier', + (tester) async { + await tester.pumpWidget(testWidget); + await tester.tap(find.text('Open modal')); + await tester.pumpAndSettle(); + await tester.tap(find.byType(AnimatedModalBarrier)); + await tester.pumpAndSettle(); + expect(isOnPopInvokedCalled, isTrue); + }, + ); + + testWidgets( + 'PopScope.onPopInvoked should be called when swipe to dismiss', + (tester) async { + await tester.pumpWidget(testWidget); + await tester.tap(find.text('Open modal')); + await tester.pumpAndSettle(); + await tester.fling( + find.byKey(const Key('sheet')), + const Offset(0, 200), + 2000, + ); + await tester.pumpAndSettle(); + expect(isOnPopInvokedCalled, isTrue); + }, + ); + }); }