Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix FormatException caused by '@' in Custom Flutter Version #808

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
10 changes: 5 additions & 5 deletions lib/src/models/flutter_version_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ class FlutterVersion with FlutterVersionMappable {
: type = VersionType.release;

factory FlutterVersion.parse(String version) {
final parts = version.split('@');
// Check if its custom.
if (version.startsWith('custom_')) {
return FlutterVersion.custom(version);
}

final parts = version.split('@');
if (parts.length == 2) {
final channel = parts.last;
if (kFlutterChannels.contains(channel)) {
Expand All @@ -68,10 +72,6 @@ class FlutterVersion with FlutterVersionMappable {

throw FormatException('Invalid version format');
}
// Check if its custom.
if (version.startsWith('custom_')) {
return FlutterVersion.custom(version);
}

// Check if its commit
if (isGitCommit(version)) {
Expand Down
54 changes: 52 additions & 2 deletions releases_linux.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,61 @@
{
"base_url": "https://storage.googleapis.com/flutter_infra_release/releases",
"current_release": {
"beta": "3e493a3e4d0a5c99fa7da51faae354e95a9a1abe",
"beta": "c21336e2277f34cdfd2a06ef1a59b7ba241129dc",
"dev": "13a2fb10b838971ce211230f8ffdd094c14af02c",
"stable": "17025dd88227cd9532c33fa78f5250d548d87e9a"
"stable": "d8a9f9a52e5af486f80d932e838ee93861ffd863"
},
"releases": [
{
"hash": "d8a9f9a52e5af486f80d932e838ee93861ffd863",
"channel": "stable",
"version": "3.27.4",
"dart_sdk_version": "3.6.2",
"dart_sdk_arch": "x64",
"release_date": "2025-02-05T18:22:08.251630Z",
"archive": "stable/linux/flutter_linux_3.27.4-stable.tar.xz",
"sha256": "64df4273de625433c7ba41967932b782f5f9abf3199db8330782d64508379344"
},
{
"hash": "c21336e2277f34cdfd2a06ef1a59b7ba241129dc",
"channel": "beta",
"version": "3.29.0-0.3.pre",
"dart_sdk_version": "3.7.0 (build 3.7.0-323.2.beta)",
"dart_sdk_arch": "x64",
"release_date": "2025-02-03T23:16:24.219059Z",
"archive": "beta/linux/flutter_linux_3.29.0-0.3.pre-beta.tar.xz",
"sha256": "4bee1a4090af8e1ecfb73816fc7d08bf4a6ae8137f2fd04b857b67c7c9e46110"
},
{
"hash": "45459707c029b168a61dcde1f1c1d64df9d529af",
"channel": "beta",
"version": "3.29.0-0.2.pre",
"dart_sdk_version": "3.7.0 (build 3.7.0-323.1.beta)",
"dart_sdk_arch": "x64",
"release_date": "2025-01-27T20:27:45.101671Z",
"archive": "beta/linux/flutter_linux_3.29.0-0.2.pre-beta.tar.xz",
"sha256": "4affbc9f2b8c3b83b086471a46a7c908afca381d78339e5cba42982e66b3191b"
},
{
"hash": "c519ee916eaeb88923e67befb89c0f1dabfa83e6",
"channel": "stable",
"version": "3.27.3",
"dart_sdk_version": "3.6.1",
"dart_sdk_arch": "x64",
"release_date": "2025-01-21T20:35:29.161615Z",
"archive": "stable/linux/flutter_linux_3.27.3-stable.tar.xz",
"sha256": "b5b60424c51ff11b62cc2fad44cdb334c7ac49cb737ae87451c9c09e13aa01d6"
},
{
"hash": "68415ad1d920f6fe5ec284f5c2febf7c4dd5b0b3",
"channel": "stable",
"version": "3.27.2",
"dart_sdk_version": "3.6.1",
"dart_sdk_arch": "x64",
"release_date": "2025-01-13T22:31:44.493761Z",
"archive": "stable/linux/flutter_linux_3.27.2-stable.tar.xz",
"sha256": "5ba77ace2b2748a251473a89785e8b8305cefd3e9dafafd7a197cda0b803c55a"
},
{
"hash": "17025dd88227cd9532c33fa78f5250d548d87e9a",
"channel": "stable",
Expand Down
104 changes: 102 additions & 2 deletions releases_macos.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,111 @@
{
"base_url": "https://storage.googleapis.com/flutter_infra_release/releases",
"current_release": {
"beta": "3e493a3e4d0a5c99fa7da51faae354e95a9a1abe",
"beta": "c21336e2277f34cdfd2a06ef1a59b7ba241129dc",
"dev": "13a2fb10b838971ce211230f8ffdd094c14af02c",
"stable": "17025dd88227cd9532c33fa78f5250d548d87e9a"
"stable": "d8a9f9a52e5af486f80d932e838ee93861ffd863"
},
"releases": [
{
"hash": "d8a9f9a52e5af486f80d932e838ee93861ffd863",
"channel": "stable",
"version": "3.27.4",
"dart_sdk_version": "3.6.2",
"dart_sdk_arch": "x64",
"release_date": "2025-02-05T18:14:55.368827Z",
"archive": "stable/macos/flutter_macos_3.27.4-stable.zip",
"sha256": "4e10b748a01599a79ce414a6257e6465dc71befa128f3868d659d0fca983a485"
},
{
"hash": "d8a9f9a52e5af486f80d932e838ee93861ffd863",
"channel": "stable",
"version": "3.27.4",
"dart_sdk_version": "3.6.2",
"dart_sdk_arch": "arm64",
"release_date": "2025-02-05T18:09:31.286886Z",
"archive": "stable/macos/flutter_macos_arm64_3.27.4-stable.zip",
"sha256": "cc4d6e6c5b1049e9ca8c7e6444430d916ef08eaf2fd8bca059fa79e424051990"
},
{
"hash": "c21336e2277f34cdfd2a06ef1a59b7ba241129dc",
"channel": "beta",
"version": "3.29.0-0.3.pre",
"dart_sdk_version": "3.7.0 (build 3.7.0-323.2.beta)",
"dart_sdk_arch": "x64",
"release_date": "2025-02-04T23:27:40.538765Z",
"archive": "beta/macos/flutter_macos_3.29.0-0.3.pre-beta.zip",
"sha256": "ae8e70736afca9115f88e88a962bfd9522b82065bcab6b50dffde25e282bd71c"
},
{
"hash": "c21336e2277f34cdfd2a06ef1a59b7ba241129dc",
"channel": "beta",
"version": "3.29.0-0.3.pre",
"dart_sdk_version": "3.7.0 (build 3.7.0-323.2.beta)",
"dart_sdk_arch": "arm64",
"release_date": "2025-02-04T23:21:02.871471Z",
"archive": "beta/macos/flutter_macos_arm64_3.29.0-0.3.pre-beta.zip",
"sha256": "b88635b2179d2fe999be9f2fde5670c5016df3bbe2fe8f5ced33927e711375be"
},
{
"hash": "45459707c029b168a61dcde1f1c1d64df9d529af",
"channel": "beta",
"version": "3.29.0-0.2.pre",
"dart_sdk_version": "3.7.0 (build 3.7.0-323.1.beta)",
"dart_sdk_arch": "x64",
"release_date": "2025-01-27T20:19:00.875075Z",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Release dates are set in the future

The release dates for new entries are set in 2025, which is beyond the current date. This could cause issues with release management and version comparisons.

Update the release dates to use the correct current or past dates. For example:

-      "release_date": "2025-01-27T20:19:00.875075Z",
+      "release_date": "2024-01-27T20:19:00.875075Z"

Also applies to: 25-25, 35-35, 45-45, 55-55, 65-65

"archive": "beta/macos/flutter_macos_3.29.0-0.2.pre-beta.zip",
"sha256": "52132c40c7f71a1ab5b621020505a5b95c2413ed5c1326c250c9e0272d16ff3c"
},
{
"hash": "45459707c029b168a61dcde1f1c1d64df9d529af",
"channel": "beta",
"version": "3.29.0-0.2.pre",
"dart_sdk_version": "3.7.0 (build 3.7.0-323.1.beta)",
"dart_sdk_arch": "arm64",
"release_date": "2025-01-27T20:12:08.729699Z",
"archive": "beta/macos/flutter_macos_arm64_3.29.0-0.2.pre-beta.zip",
"sha256": "6d0e3140150f9942bbacef7a336a15d7791935780fd316afb195926fdf006bf5"
},
{
"hash": "c519ee916eaeb88923e67befb89c0f1dabfa83e6",
"channel": "stable",
"version": "3.27.3",
"dart_sdk_version": "3.6.1",
"dart_sdk_arch": "x64",
"release_date": "2025-01-21T20:33:49.233815Z",
"archive": "stable/macos/flutter_macos_3.27.3-stable.zip",
"sha256": "b1117c4e1a80ae13a1ba6281b8141e429cb62fc5382386e2a78e00d12a423706"
},
{
"hash": "c519ee916eaeb88923e67befb89c0f1dabfa83e6",
"channel": "stable",
"version": "3.27.3",
"dart_sdk_version": "3.6.1",
"dart_sdk_arch": "arm64",
"release_date": "2025-01-21T20:27:29.326710Z",
"archive": "stable/macos/flutter_macos_arm64_3.27.3-stable.zip",
"sha256": "20d1ca79dad65f9f9fcd4c31bdbbbcc2237aa0cd384a83d6dff795d44fe1039a"
},
{
"hash": "68415ad1d920f6fe5ec284f5c2febf7c4dd5b0b3",
"channel": "stable",
"version": "3.27.2",
"dart_sdk_version": "3.6.1",
"dart_sdk_arch": "x64",
"release_date": "2025-01-13T22:27:04.890409Z",
"archive": "stable/macos/flutter_macos_3.27.2-stable.zip",
"sha256": "26c96cd7e4682ffc15a741d2963b15b87123875cb2fbb8ac5dbdc1aee41f5388"
},
{
"hash": "68415ad1d920f6fe5ec284f5c2febf7c4dd5b0b3",
"channel": "stable",
"version": "3.27.2",
"dart_sdk_version": "3.6.1",
"dart_sdk_arch": "arm64",
"release_date": "2025-01-13T22:20:35.633578Z",
"archive": "stable/macos/flutter_macos_arm64_3.27.2-stable.zip",
"sha256": "e8333d7f7d3718d80b50445017a426fda3ffa1936dfed7753ec74e43c90becd4"
},
{
"hash": "17025dd88227cd9532c33fa78f5250d548d87e9a",
"channel": "stable",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Incomplete Release Entry Object Detected.
The final JSON object starting at line 89 appears to be incomplete. It is missing several required fields (e.g., "version", "dart_sdk_version", "release_date", etc.) and does not have a closing structure. Please update this entry to ensure the JSON file validates correctly.

Expand Down
54 changes: 52 additions & 2 deletions releases_windows.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,61 @@
{
"base_url": "https://storage.googleapis.com/flutter_infra_release/releases",
"current_release": {
"beta": "3e493a3e4d0a5c99fa7da51faae354e95a9a1abe",
"beta": "c21336e2277f34cdfd2a06ef1a59b7ba241129dc",
"dev": "13a2fb10b838971ce211230f8ffdd094c14af02c",
"stable": "17025dd88227cd9532c33fa78f5250d548d87e9a"
"stable": "d8a9f9a52e5af486f80d932e838ee93861ffd863"
},
"releases": [
{
"hash": "d8a9f9a52e5af486f80d932e838ee93861ffd863",
"channel": "stable",
"version": "3.27.4",
"dart_sdk_version": "3.6.2",
"dart_sdk_arch": "x64",
"release_date": "2025-02-05T18:19:37.890925Z",
"archive": "stable/windows/flutter_windows_3.27.4-stable.zip",
"sha256": "1141d3edb64c454273feac88f31f84945a1f3309a72c58aa9a5f2bb2b0fc8db3"
},
{
"hash": "c21336e2277f34cdfd2a06ef1a59b7ba241129dc",
"channel": "beta",
"version": "3.29.0-0.3.pre",
"dart_sdk_version": "3.7.0 (build 3.7.0-323.2.beta)",
"dart_sdk_arch": "x64",
"release_date": "2025-02-03T23:22:31.180315Z",
"archive": "beta/windows/flutter_windows_3.29.0-0.3.pre-beta.zip",
"sha256": "151a0b1e7f836aca8a3e3605b17772fc64186934894ddf7e81de57c18748227b"
},
{
"hash": "45459707c029b168a61dcde1f1c1d64df9d529af",
"channel": "beta",
"version": "3.29.0-0.2.pre",
"dart_sdk_version": "3.7.0 (build 3.7.0-323.1.beta)",
"dart_sdk_arch": "x64",
"release_date": "2025-01-27T20:22:33.061347Z",
"archive": "beta/windows/flutter_windows_3.29.0-0.2.pre-beta.zip",
"sha256": "7c095ca994e8f226a60ca433861ae466eeb0a36cc97838ab1b6d1ad1c58be031"
},
{
"hash": "c519ee916eaeb88923e67befb89c0f1dabfa83e6",
"channel": "stable",
"version": "3.27.3",
"dart_sdk_version": "3.6.1",
"dart_sdk_arch": "x64",
"release_date": "2025-01-21T20:47:44.369846Z",
"archive": "stable/windows/flutter_windows_3.27.3-stable.zip",
"sha256": "cd1a66704fe075a8c8bc2c558dd4dcec171ba396a84aea88e3d48c23852d62c3"
},
{
"hash": "68415ad1d920f6fe5ec284f5c2febf7c4dd5b0b3",
"channel": "stable",
"version": "3.27.2",
"dart_sdk_version": "3.6.1",
"dart_sdk_arch": "x64",
"release_date": "2025-01-13T22:30:36.187540Z",
"archive": "stable/windows/flutter_windows_3.27.2-stable.zip",
"sha256": "ed4ae71a30dfdd04a8a1053d9e354314ab95f4731930d39d9b656d36209cc41d"
},
{
"hash": "17025dd88227cd9532c33fa78f5250d548d87e9a",
"channel": "stable",
Expand Down
20 changes: 20 additions & 0 deletions test/models/flutter_version_model_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ void main() {
expect(version.type, VersionType.custom);
});

test('custom constructor', () {
final version = FlutterVersion.custom('custom_3.7.0@huawei');
expect(version.name, 'custom_3.7.0@huawei');
expect(version.releaseFromChannel, isNull);
expect(version.type, VersionType.custom);
});

test('release constructor', () {
final version =
FlutterVersion.release('1.0.0', releaseFromChannel: 'stable');
Expand Down Expand Up @@ -109,6 +116,13 @@ void main() {
expect(version.type, VersionType.custom);
});

test('parse method - custom version', () {
final version = FlutterVersion.parse('custom_3.6.0@huawei');
expect(version.name, 'custom_3.6.0@huawei');
expect(version.releaseFromChannel, isNull);
expect(version.type, VersionType.custom);
});

test('parse method - commit version', () {
final version = FlutterVersion.parse('f4c74a6ec3');
expect(version.name, 'f4c74a6ec3');
Expand Down Expand Up @@ -161,6 +175,12 @@ void main() {
expect(version.isCustom, isTrue);
});


test('isCustom getter', () {
final version = FlutterVersion.custom('custom_3.22.0@huawei');
expect(version.isCustom, isTrue);
});

test('printFriendlyName getter - channel version', () {
final version = FlutterVersion.channel('stable');
expect(version.printFriendlyName, 'Channel: Stable');
Expand Down