From 93b33513e80123510b0d2bd7f5e8bf54318d6a95 Mon Sep 17 00:00:00 2001 From: Victor Blaess Date: Mon, 31 Mar 2025 08:11:38 +0200 Subject: [PATCH 01/14] added publish-to-pubdev pipeline --- .github/workflows/publish-to-pubdev.yml | 69 +++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/publish-to-pubdev.yml diff --git a/.github/workflows/publish-to-pubdev.yml b/.github/workflows/publish-to-pubdev.yml new file mode 100644 index 0000000..0a7b7aa --- /dev/null +++ b/.github/workflows/publish-to-pubdev.yml @@ -0,0 +1,69 @@ +name: Publish to Pub.dev + +on: + push: + tags: + - 'v*.*.*' # This triggers the action for tags like v1.0.0, v2.3.4, etc. + +jobs: + build: + runs-on: ubuntu-latest + + steps: + # Checkout repository + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 # Fetches all history for all tags and branches + + # Set up Flutter + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: 'stable' + channel: 'stable' + + # Cache Flutter dependencies to speed up workflow + - name: Cache Flutter dependencies + uses: actions/cache@v3 + with: + path: ~/.pub-cache + key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.yaml') }} + restore-keys: | + ${{ runner.os }}-pub- + + # Install dependencies + - name: Install dependencies + run: flutter pub get + + # Parse the tag to get the version without 'v' prefix + - name: Extract version from tag + id: get_version + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV + + # Verify the pubspec version matches the tag + - name: Verify version + run: | + echo "Tag version: $VERSION" + PUBSPEC_VERSION=$(grep -m 1 'version:' pubspec.yaml | awk '{print $2}') + echo "Pubspec version: $PUBSPEC_VERSION" + if [ "$VERSION" != "$PUBSPEC_VERSION" ]; then + echo "Error: The version in pubspec.yaml ($PUBSPEC_VERSION) does not match the tag version ($VERSION)" + exit 1 + fi + + # Publish to pub.dev + - name: Publish to Pub.dev + env: + PUB_DEV_TOKEN: ${{ secrets.PUB_DEV_TOKEN }} + run: | + # Configure Pub credentials + mkdir -p ~/.pub-cache + echo "$PUB_DEV_TOKEN" > ~/.pub-cache/credentials.json + # Publish the package + flutter pub publish --force + + # Clean up after publish + - name: Clean up + run: | + rm -f ~/.pub-cache/credentials.json \ No newline at end of file From ed6917a0175a9a9f972cc64981ea2d198a083023 Mon Sep 17 00:00:00 2001 From: Victor Blaess Date: Mon, 31 Mar 2025 08:22:39 +0200 Subject: [PATCH 02/14] added dry run pre merge pipeline --- .github/workflows/pre-merge-checks.yml | 71 ++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/pre-merge-checks.yml diff --git a/.github/workflows/pre-merge-checks.yml b/.github/workflows/pre-merge-checks.yml new file mode 100644 index 0000000..c22da64 --- /dev/null +++ b/.github/workflows/pre-merge-checks.yml @@ -0,0 +1,71 @@ +name: Pre-merge checks + +on: + pull_request: + branches: + - main + - master + push: + branches: + - main + - master + +jobs: + test-publish: + runs-on: ubuntu-latest + + steps: + # Checkout repository + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + # Set up Flutter + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: 'stable' + channel: 'stable' + + # Cache Flutter dependencies to speed up workflow + - name: Cache Flutter dependencies + uses: actions/cache@v3 + with: + path: ~/.pub-cache + key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.yaml') }} + restore-keys: | + ${{ runner.os }}-pub- + + # Install dependencies + - name: Install dependencies + run: flutter pub get + + # Run tests + - name: Run tests + run: flutter test + + # Static code analysis + - name: Analyze code + run: flutter analyze + + # Verify package format is correct + - name: Format check + run: flutter format --set-exit-if-changed . + + # Verify package + - name: Verify package + run: flutter pub publish --dry-run + + # Check if package can be published + - name: Check publication readiness + run: | + ISSUES=$(flutter pub publish --dry-run 2>&1 | grep -i "error\|warning" || true) + if [ ! -z "$ISSUES" ]; then + echo "Publication issues found:" + echo "$ISSUES" + echo "Please fix these issues before merging." + exit 1 + else + echo "Package is ready for publication! ✅" + fi \ No newline at end of file From 6c9041617672eeb29cf76dd7003f57f7ffcb435b Mon Sep 17 00:00:00 2001 From: Victor Blaess Date: Mon, 31 Mar 2025 08:24:58 +0200 Subject: [PATCH 03/14] trying fix pre-merge pipeline error --- .github/workflows/pre-merge-checks.yml | 2 +- .github/workflows/publish-to-pubdev.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pre-merge-checks.yml b/.github/workflows/pre-merge-checks.yml index c22da64..a23f361 100644 --- a/.github/workflows/pre-merge-checks.yml +++ b/.github/workflows/pre-merge-checks.yml @@ -25,7 +25,7 @@ jobs: - name: Set up Flutter uses: subosito/flutter-action@v2 with: - flutter-version: 'stable' + flutter-version: '3.13.0' # Specify exact version instead of just 'stable' channel: 'stable' # Cache Flutter dependencies to speed up workflow diff --git a/.github/workflows/publish-to-pubdev.yml b/.github/workflows/publish-to-pubdev.yml index 0a7b7aa..fc00028 100644 --- a/.github/workflows/publish-to-pubdev.yml +++ b/.github/workflows/publish-to-pubdev.yml @@ -20,7 +20,7 @@ jobs: - name: Set up Flutter uses: subosito/flutter-action@v2 with: - flutter-version: 'stable' + flutter-version: '3.13.0' # Specify exact version instead of just 'stable' channel: 'stable' # Cache Flutter dependencies to speed up workflow From 6ee9e8728d1e6d648d31d3a9517a40150ac037fa Mon Sep 17 00:00:00 2001 From: Victor Blaess Date: Mon, 31 Mar 2025 08:35:30 +0200 Subject: [PATCH 04/14] upgraded flutter version on pipelines to current stable 3.29.0 --- .github/workflows/pre-merge-checks.yml | 2 +- .github/workflows/publish-to-pubdev.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pre-merge-checks.yml b/.github/workflows/pre-merge-checks.yml index a23f361..3fbd379 100644 --- a/.github/workflows/pre-merge-checks.yml +++ b/.github/workflows/pre-merge-checks.yml @@ -25,7 +25,7 @@ jobs: - name: Set up Flutter uses: subosito/flutter-action@v2 with: - flutter-version: '3.13.0' # Specify exact version instead of just 'stable' + flutter-version: '3.29.0' # Specify exact version instead of just 'stable' channel: 'stable' # Cache Flutter dependencies to speed up workflow diff --git a/.github/workflows/publish-to-pubdev.yml b/.github/workflows/publish-to-pubdev.yml index fc00028..e61b590 100644 --- a/.github/workflows/publish-to-pubdev.yml +++ b/.github/workflows/publish-to-pubdev.yml @@ -20,7 +20,7 @@ jobs: - name: Set up Flutter uses: subosito/flutter-action@v2 with: - flutter-version: '3.13.0' # Specify exact version instead of just 'stable' + flutter-version: '3.29.0' # Specify exact version instead of just 'stable' channel: 'stable' # Cache Flutter dependencies to speed up workflow From b79e90d3fe1844fe363eef2f48984a23d1362dd3 Mon Sep 17 00:00:00 2001 From: Victor Blaess Date: Mon, 31 Mar 2025 08:49:38 +0200 Subject: [PATCH 05/14] added run: flutter analyze --no-fatal-warnings to pre-merge --- .github/workflows/pre-merge-checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pre-merge-checks.yml b/.github/workflows/pre-merge-checks.yml index 3fbd379..0e9f226 100644 --- a/.github/workflows/pre-merge-checks.yml +++ b/.github/workflows/pre-merge-checks.yml @@ -47,7 +47,7 @@ jobs: # Static code analysis - name: Analyze code - run: flutter analyze + run: flutter analyze --no-fatal-warnings # Verify package format is correct - name: Format check From 29e3f6721f00988d7ebe65d745211f28ff05ca49 Mon Sep 17 00:00:00 2001 From: Victor Blaess Date: Mon, 31 Mar 2025 08:52:51 +0200 Subject: [PATCH 06/14] changed format check to dart format check instead of deprecated version for flutter --- .github/workflows/pre-merge-checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pre-merge-checks.yml b/.github/workflows/pre-merge-checks.yml index 0e9f226..20e9688 100644 --- a/.github/workflows/pre-merge-checks.yml +++ b/.github/workflows/pre-merge-checks.yml @@ -51,7 +51,7 @@ jobs: # Verify package format is correct - name: Format check - run: flutter format --set-exit-if-changed . + run: dart format --set-exit-if-changed . # Verify package - name: Verify package From 2454e393cb832e94b3ea49a4351de9b73e888f3d Mon Sep 17 00:00:00 2001 From: Victor Blaess Date: Mon, 31 Mar 2025 11:04:34 +0200 Subject: [PATCH 07/14] ran dart format --- example/pubspec.lock | 16 +++---- lib/src/custom_proxy.dart | 6 ++- lib/src/custom_proxy_override.dart | 6 ++- lib/src/native_proxy_reader.dart | 4 +- pubspec.lock | 76 +++++++++++++++--------------- 5 files changed, 57 insertions(+), 51 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 3d9ddb2..98e5eaa 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,18 +5,18 @@ packages: dependency: transitive description: name: characters - sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted - version: "1.4.0" + version: "1.3.0" collection: dependency: transitive description: name: collection - sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.19.1" + version: "1.18.0" flutter: dependency: "direct main" description: flutter @@ -34,10 +34,10 @@ packages: dependency: transitive description: name: meta - sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.15.0" native_flutter_proxy: dependency: "direct main" description: @@ -49,7 +49,7 @@ packages: dependency: transitive description: flutter source: sdk - version: "0.0.0" + version: "0.0.99" vector_math: dependency: transitive description: @@ -59,4 +59,4 @@ packages: source: hosted version: "2.1.4" sdks: - dart: ">=3.7.0-0 <4.0.0" + dart: ">=3.3.0-0 <4.0.0" diff --git a/lib/src/custom_proxy.dart b/lib/src/custom_proxy.dart index de5391a..5a03b89 100644 --- a/lib/src/custom_proxy.dart +++ b/lib/src/custom_proxy.dart @@ -61,7 +61,8 @@ class CustomProxy { static CustomProxy? fromString({required String proxy}) { // Check if the proxy string is empty if (proxy.isEmpty) { - assert(false, 'Proxy string passed to CustomProxy.fromString() is invalid.'); + assert( + false, 'Proxy string passed to CustomProxy.fromString() is invalid.'); return null; } @@ -79,7 +80,8 @@ class CustomProxy { /// /// Sets [HttpOverrides.global] to a new instance of [CustomProxyHttpOverride] /// configured with the proxy settings from this object's string representation. - void enable() => HttpOverrides.global = CustomProxyHttpOverride.withProxy(toString()); + void enable() => + HttpOverrides.global = CustomProxyHttpOverride.withProxy(toString()); /// Disables the global HTTP proxy settings by setting HttpOverrides.global to null. /// diff --git a/lib/src/custom_proxy_override.dart b/lib/src/custom_proxy_override.dart index 2ba572a..da40b2d 100644 --- a/lib/src/custom_proxy_override.dart +++ b/lib/src/custom_proxy_override.dart @@ -45,12 +45,14 @@ final class CustomProxyHttpOverride extends HttpOverrides { HttpClient createHttpClient(SecurityContext? context) { final client = super.createHttpClient(context) ..findProxy = (uri) { - assert(proxyString.isNotEmpty, 'You must set a valid proxy if you enable it!'); + assert(proxyString.isNotEmpty, + 'You must set a valid proxy if you enable it!'); return 'PROXY $proxyString;'; }; - if (allowBadCertificates) client.badCertificateCallback = (cert, host, port) => true; + if (allowBadCertificates) + client.badCertificateCallback = (cert, host, port) => true; return client; } diff --git a/lib/src/native_proxy_reader.dart b/lib/src/native_proxy_reader.dart index 042cc00..b84e133 100644 --- a/lib/src/native_proxy_reader.dart +++ b/lib/src/native_proxy_reader.dart @@ -23,7 +23,9 @@ abstract final class NativeProxyReader { /// Get the proxy settings from the native platform. static Future get proxySetting async { - return _channel.invokeMapMethod('getProxySetting').then(ProxySetting._fromMap); + return _channel + .invokeMapMethod('getProxySetting') + .then(ProxySetting._fromMap); } } diff --git a/pubspec.lock b/pubspec.lock index 939a55c..b6bb070 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,50 +5,50 @@ packages: dependency: transitive description: name: async - sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted - version: "2.12.0" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.1" characters: dependency: transitive description: name: characters - sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted - version: "1.4.0" + version: "1.3.0" clock: dependency: transitive description: name: clock - sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf url: "https://pub.dev" source: hosted - version: "1.1.2" + version: "1.1.1" collection: dependency: transitive description: name: collection - sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.19.1" + version: "1.18.0" fake_async: dependency: transitive description: name: fake_async - sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" url: "https://pub.dev" source: hosted - version: "1.3.2" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -63,18 +63,18 @@ packages: dependency: transitive description: name: leak_tracker - sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec + sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" url: "https://pub.dev" source: hosted - version: "10.0.8" + version: "10.0.5" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 + sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" url: "https://pub.dev" source: hosted - version: "3.0.9" + version: "3.0.5" leak_tracker_testing: dependency: transitive description: @@ -87,10 +87,10 @@ packages: dependency: transitive description: name: matcher - sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.17" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: @@ -103,71 +103,71 @@ packages: dependency: transitive description: name: meta - sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.15.0" path: dependency: transitive description: name: path - sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.9.0" sky_engine: dependency: transitive description: flutter source: sdk - version: "0.0.0" + version: "0.0.99" source_span: dependency: transitive description: name: source_span - sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted - version: "1.10.1" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.12.1" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.4" + version: "2.1.2" string_scanner: dependency: transitive description: name: string_scanner - sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" url: "https://pub.dev" source: hosted - version: "1.4.1" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 url: "https://pub.dev" source: hosted - version: "1.2.2" + version: "1.2.1" test_api: dependency: transitive description: name: test_api - sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd + sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" url: "https://pub.dev" source: hosted - version: "0.7.4" + version: "0.7.2" vector_math: dependency: transitive description: @@ -188,10 +188,10 @@ packages: dependency: transitive description: name: vm_service - sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14" + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" url: "https://pub.dev" source: hosted - version: "14.3.1" + version: "14.2.5" sdks: - dart: ">=3.7.0-0 <4.0.0" + dart: ">=3.5.0 <4.0.0" flutter: ">=3.18.0-18.0.pre.54" From c6b8301df73917ee697a615a8740c7368c067c5f Mon Sep 17 00:00:00 2001 From: Victor Blaess Date: Mon, 31 Mar 2025 11:11:39 +0200 Subject: [PATCH 08/14] added trailing commas, fixed findings by analyzer --- example/analysis_options.yaml | 2 +- example/pubspec.lock | 8 ++++++++ example/pubspec.yaml | 3 +++ lib/src/custom_proxy.dart | 3 +-- lib/src/custom_proxy_override.dart | 8 +++----- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml index fac60e2..0caccc8 100644 --- a/example/analysis_options.yaml +++ b/example/analysis_options.yaml @@ -1 +1 @@ -include: ../../analysis_options.yaml \ No newline at end of file +include: ../analysis_options.yaml \ No newline at end of file diff --git a/example/pubspec.lock b/example/pubspec.lock index 98e5eaa..b1498b0 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -58,5 +58,13 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + very_good_analysis: + dependency: "direct dev" + description: + name: very_good_analysis + sha256: "9ae7f3a3bd5764fb021b335ca28a34f040cd0ab6eec00a1b213b445dae58a4b8" + url: "https://pub.dev" + source: hosted + version: "5.1.0" sdks: dart: ">=3.3.0-0 <4.0.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 680bb4d..9539dc3 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -11,5 +11,8 @@ dependencies: sdk: flutter native_flutter_proxy: ^0.2.0 +dev_dependencies: + very_good_analysis: ^5.1.0 + flutter: uses-material-design: true diff --git a/lib/src/custom_proxy.dart b/lib/src/custom_proxy.dart index 5a03b89..10c53dc 100644 --- a/lib/src/custom_proxy.dart +++ b/lib/src/custom_proxy.dart @@ -62,8 +62,7 @@ class CustomProxy { // Check if the proxy string is empty if (proxy.isEmpty) { assert( - false, 'Proxy string passed to CustomProxy.fromString() is invalid.'); - + false, 'Proxy string passed to CustomProxy.fromString() is invalid.',); return null; } diff --git a/lib/src/custom_proxy_override.dart b/lib/src/custom_proxy_override.dart index da40b2d..41587cf 100644 --- a/lib/src/custom_proxy_override.dart +++ b/lib/src/custom_proxy_override.dart @@ -46,14 +46,12 @@ final class CustomProxyHttpOverride extends HttpOverrides { final client = super.createHttpClient(context) ..findProxy = (uri) { assert(proxyString.isNotEmpty, - 'You must set a valid proxy if you enable it!'); - + 'You must set a valid proxy if you enable it!',); return 'PROXY $proxyString;'; }; - - if (allowBadCertificates) + if (allowBadCertificates) { client.badCertificateCallback = (cert, host, port) => true; - + } return client; } } From d13d5dabde88be425b30405ba393c1a5bc90f02a Mon Sep 17 00:00:00 2001 From: Victor Blaess Date: Mon, 31 Mar 2025 11:13:35 +0200 Subject: [PATCH 09/14] fixed more findings from flutter analyze --- example/lib/main.dart | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 3b200a7..5df3952 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,5 +1,4 @@ // ignore_for_file: unused_local_variable - import 'package:flutter/material.dart'; import 'package:native_flutter_proxy/native_flutter_proxy.dart'; @@ -12,13 +11,15 @@ void main() async { var enabled = false; String? host; int? port; + try { final settings = await NativeProxyReader.proxySetting; enabled = settings.enabled; host = settings.host; port = settings.port; } catch (e) { - print(e); + // Using debugPrint instead of print for production code + debugPrint('Error fetching proxy settings: $e'); } // Enable the proxy if it is enabled and the host is not null. @@ -27,22 +28,36 @@ void main() async { debugPrint('proxy enabled'); } - runApp(MyApp()); + runApp(const MyApp()); } +/// The main application widget. +/// +/// This widget is the root of the application. class MyApp extends StatelessWidget { + /// Creates a new instance of [MyApp]. + const MyApp({super.key}); + @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData(primarySwatch: Colors.blue), - home: MyHomePage(title: 'Flutter Demo Home Page'), + home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } } +/// A widget that displays the home page of the application. +/// +/// This widget is stateful and keeps track of a counter value. class MyHomePage extends StatefulWidget { - MyHomePage({super.key, required this.title}); + /// Creates a new instance of [MyHomePage]. + /// + /// The [title] parameter is required and displayed in the app bar. + const MyHomePage({required this.title, super.key}); + + /// The title displayed in the app bar. final String title; @override @@ -52,6 +67,7 @@ class MyHomePage extends StatefulWidget { class _MyHomePageState extends State { int counter = 0; + /// Increments the counter value. void _incrementCounter() => setState(() => counter++); @override @@ -62,7 +78,7 @@ class _MyHomePageState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text('You have pushed the button this many times:'), + const Text('You have pushed the button this many times:'), Text( '$counter', style: Theme.of(context).textTheme.headlineMedium, @@ -73,7 +89,7 @@ class _MyHomePageState extends State { floatingActionButton: FloatingActionButton( onPressed: _incrementCounter, tooltip: 'Increment', - child: Icon(Icons.add), + child: const Icon(Icons.add), ), ); } From cc9ec3da929a76bc622bdfceb4fc7289749ba8f6 Mon Sep 17 00:00:00 2001 From: Victor Blaess Date: Mon, 31 Mar 2025 12:58:23 +0200 Subject: [PATCH 10/14] another try of pipeline --- example/pubspec.lock | 16 +++++----- pubspec.lock | 76 ++++++++++++++++++++++---------------------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index b1498b0..8cfd740 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,18 +5,18 @@ packages: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.4.0" collection: dependency: transitive description: name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" url: "https://pub.dev" source: hosted - version: "1.18.0" + version: "1.19.1" flutter: dependency: "direct main" description: flutter @@ -34,10 +34,10 @@ packages: dependency: transitive description: name: meta - sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.16.0" native_flutter_proxy: dependency: "direct main" description: @@ -49,7 +49,7 @@ packages: dependency: transitive description: flutter source: sdk - version: "0.0.99" + version: "0.0.0" vector_math: dependency: transitive description: @@ -67,4 +67,4 @@ packages: source: hosted version: "5.1.0" sdks: - dart: ">=3.3.0-0 <4.0.0" + dart: ">=3.7.0-0 <4.0.0" diff --git a/pubspec.lock b/pubspec.lock index b6bb070..939a55c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,50 +5,50 @@ packages: dependency: transitive description: name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 url: "https://pub.dev" source: hosted - version: "2.11.0" + version: "2.12.0" boolean_selector: dependency: transitive description: name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" characters: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.4.0" 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: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc" url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.3.2" flutter: dependency: "direct main" description: flutter @@ -63,18 +63,18 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec url: "https://pub.dev" source: hosted - version: "10.0.5" + version: "10.0.8" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 url: "https://pub.dev" source: hosted - version: "3.0.5" + version: "3.0.9" leak_tracker_testing: dependency: transitive description: @@ -87,10 +87,10 @@ packages: dependency: transitive description: name: matcher - sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 url: "https://pub.dev" source: hosted - version: "0.12.16+1" + version: "0.12.17" material_color_utilities: dependency: transitive description: @@ -103,71 +103,71 @@ packages: dependency: transitive description: name: meta - sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.16.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: name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.10.1" stack_trace: 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: name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.4.1" term_glyph: dependency: transitive description: name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.2.2" test_api: dependency: transitive description: name: test_api - sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" + sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd url: "https://pub.dev" source: hosted - version: "0.7.2" + version: "0.7.4" vector_math: dependency: transitive description: @@ -188,10 +188,10 @@ packages: dependency: transitive description: name: vm_service - sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" + sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14" url: "https://pub.dev" source: hosted - version: "14.2.5" + version: "14.3.1" sdks: - dart: ">=3.5.0 <4.0.0" + dart: ">=3.7.0-0 <4.0.0" flutter: ">=3.18.0-18.0.pre.54" From 2cbca85734c591513c2f6bc1f6ac2c3acf5374db Mon Sep 17 00:00:00 2001 From: Victor Blaess Date: Mon, 31 Mar 2025 13:01:40 +0200 Subject: [PATCH 11/14] formatted --- lib/src/custom_proxy.dart | 7 ++++--- lib/src/custom_proxy_override.dart | 6 ++++-- lib/src/native_proxy_reader.dart | 4 +--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/src/custom_proxy.dart b/lib/src/custom_proxy.dart index 10c53dc..a22590e 100644 --- a/lib/src/custom_proxy.dart +++ b/lib/src/custom_proxy.dart @@ -62,7 +62,9 @@ class CustomProxy { // Check if the proxy string is empty if (proxy.isEmpty) { assert( - false, 'Proxy string passed to CustomProxy.fromString() is invalid.',); + false, + 'Proxy string passed to CustomProxy.fromString() is invalid.', + ); return null; } @@ -79,8 +81,7 @@ class CustomProxy { /// /// Sets [HttpOverrides.global] to a new instance of [CustomProxyHttpOverride] /// configured with the proxy settings from this object's string representation. - void enable() => - HttpOverrides.global = CustomProxyHttpOverride.withProxy(toString()); + void enable() => HttpOverrides.global = CustomProxyHttpOverride.withProxy(toString()); /// Disables the global HTTP proxy settings by setting HttpOverrides.global to null. /// diff --git a/lib/src/custom_proxy_override.dart b/lib/src/custom_proxy_override.dart index 41587cf..2058bbf 100644 --- a/lib/src/custom_proxy_override.dart +++ b/lib/src/custom_proxy_override.dart @@ -45,8 +45,10 @@ final class CustomProxyHttpOverride extends HttpOverrides { HttpClient createHttpClient(SecurityContext? context) { final client = super.createHttpClient(context) ..findProxy = (uri) { - assert(proxyString.isNotEmpty, - 'You must set a valid proxy if you enable it!',); + assert( + proxyString.isNotEmpty, + 'You must set a valid proxy if you enable it!', + ); return 'PROXY $proxyString;'; }; if (allowBadCertificates) { diff --git a/lib/src/native_proxy_reader.dart b/lib/src/native_proxy_reader.dart index b84e133..042cc00 100644 --- a/lib/src/native_proxy_reader.dart +++ b/lib/src/native_proxy_reader.dart @@ -23,9 +23,7 @@ abstract final class NativeProxyReader { /// Get the proxy settings from the native platform. static Future get proxySetting async { - return _channel - .invokeMapMethod('getProxySetting') - .then(ProxySetting._fromMap); + return _channel.invokeMapMethod('getProxySetting').then(ProxySetting._fromMap); } } From aaac275067e20d644ae446f94d124fc011f9040d Mon Sep 17 00:00:00 2001 From: Victor Blaess Date: Mon, 31 Mar 2025 13:05:12 +0200 Subject: [PATCH 12/14] added pubignore file --- .pubignore | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .pubignore diff --git a/.pubignore b/.pubignore new file mode 100644 index 0000000..a664257 --- /dev/null +++ b/.pubignore @@ -0,0 +1,23 @@ +.dart_tool/ +.idea/ +.vscode/ +build/ +.packages +pubspec.lock +.DS_Store +.pub/ +.git/ +.github/ +.gitignore +.travis/ +.travis.yml +test/ +android/.idea +example/build/ +example/.dart_tool/ +example/.packages +example/pubspec.lock + +# Don't exclude these files even though they are in .gitignore +!.idea/codeStyleConfig.xml +!.vscode/settings.json \ No newline at end of file From 70c671924e84d376c66ddb52438692a1511b1f10 Mon Sep 17 00:00:00 2001 From: Victor Blaess Date: Mon, 31 Mar 2025 13:08:32 +0200 Subject: [PATCH 13/14] deleted vscode folder & idea folder --- .idea/codeStyleConfig.xml | 12 ------------ .vscode/settings.json | 9 --------- 2 files changed, 21 deletions(-) delete mode 100644 .idea/codeStyleConfig.xml delete mode 100644 .vscode/settings.json diff --git a/.idea/codeStyleConfig.xml b/.idea/codeStyleConfig.xml deleted file mode 100644 index 673acd8..0000000 --- a/.idea/codeStyleConfig.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 391e560..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "[dart]": { - "editor.rulers": [ - 100 - ], - "editor.formatOnSave": true - }, - "dart.lineLength": 100 -} \ No newline at end of file From 055f5f99f045b778358d0a7b4298f1a3592726ee Mon Sep 17 00:00:00 2001 From: Victor Blaess Date: Mon, 31 Mar 2025 14:09:20 +0200 Subject: [PATCH 14/14] changed to simple dry run command --- .github/workflows/pre-merge-checks.yml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/pre-merge-checks.yml b/.github/workflows/pre-merge-checks.yml index 20e9688..8df74ce 100644 --- a/.github/workflows/pre-merge-checks.yml +++ b/.github/workflows/pre-merge-checks.yml @@ -59,13 +59,4 @@ jobs: # Check if package can be published - name: Check publication readiness - run: | - ISSUES=$(flutter pub publish --dry-run 2>&1 | grep -i "error\|warning" || true) - if [ ! -z "$ISSUES" ]; then - echo "Publication issues found:" - echo "$ISSUES" - echo "Please fix these issues before merging." - exit 1 - else - echo "Package is ready for publication! ✅" - fi \ No newline at end of file + run: flutter pub publish --dry-run \ No newline at end of file