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
12 changes: 11 additions & 1 deletion releases_linux.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
{
"base_url": "https://storage.googleapis.com/flutter_infra_release/releases",
"current_release": {
"beta": "c21336e2277f34cdfd2a06ef1a59b7ba241129dc",
"beta": "360a12c8481dccbfcab0a2a6704445e08454ef9e",
"dev": "13a2fb10b838971ce211230f8ffdd094c14af02c",
"stable": "35c388afb57ef061d06a39b537336c87e0e3d1b1"
},
"releases": [
{
"hash": "360a12c8481dccbfcab0a2a6704445e08454ef9e",
"channel": "beta",
"version": "3.30.0-0.1.pre",
"dart_sdk_version": "3.8.0 (build 3.8.0-70.0.dev)",
"dart_sdk_arch": "x64",
"release_date": "2025-02-19T19:16:37.803049Z",
"archive": "beta/linux/flutter_linux_3.30.0-0.1.pre-beta.tar.xz",
"sha256": "517c6ac2219f497a02f66f8b6025e35edc0bd0ad5bd4cc31820c2a88584ed530"
},
{
"hash": "35c388afb57ef061d06a39b537336c87e0e3d1b1",
"channel": "stable",
Expand Down
22 changes: 21 additions & 1 deletion releases_macos.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
{
"base_url": "https://storage.googleapis.com/flutter_infra_release/releases",
"current_release": {
"beta": "c21336e2277f34cdfd2a06ef1a59b7ba241129dc",
"beta": "360a12c8481dccbfcab0a2a6704445e08454ef9e",
"dev": "13a2fb10b838971ce211230f8ffdd094c14af02c",
"stable": "35c388afb57ef061d06a39b537336c87e0e3d1b1"
},
"releases": [
{
"hash": "360a12c8481dccbfcab0a2a6704445e08454ef9e",
"channel": "beta",
"version": "3.30.0-0.1.pre",
"dart_sdk_version": "3.8.0 (build 3.8.0-70.0.dev)",
"dart_sdk_arch": "arm64",
"release_date": "2025-02-19T19:50:31.635799Z",
"archive": "beta/macos/flutter_macos_arm64_3.30.0-0.1.pre-beta.zip",
"sha256": "0476925a316e5a4630b5d953b8fb14d233194cb6e0e5214eab7389e358d5d676"
},
{
"hash": "360a12c8481dccbfcab0a2a6704445e08454ef9e",
"channel": "beta",
"version": "3.30.0-0.1.pre",
"dart_sdk_version": "3.8.0 (build 3.8.0-70.0.dev)",
"dart_sdk_arch": "x64",
"release_date": "2025-02-19T19:11:16.183257Z",
"archive": "beta/macos/flutter_macos_3.30.0-0.1.pre-beta.zip",
"sha256": "0672f4d700cf7f2b40fb28198505e09d5844479f6ce501756186544316db477c"
},
{
"hash": "35c388afb57ef061d06a39b537336c87e0e3d1b1",
"channel": "stable",
Expand Down
12 changes: 11 additions & 1 deletion releases_windows.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
{
"base_url": "https://storage.googleapis.com/flutter_infra_release/releases",
"current_release": {
"beta": "c21336e2277f34cdfd2a06ef1a59b7ba241129dc",
"beta": "360a12c8481dccbfcab0a2a6704445e08454ef9e",
"dev": "13a2fb10b838971ce211230f8ffdd094c14af02c",
"stable": "35c388afb57ef061d06a39b537336c87e0e3d1b1"
},
"releases": [
{
"hash": "360a12c8481dccbfcab0a2a6704445e08454ef9e",
"channel": "beta",
"version": "3.30.0-0.1.pre",
"dart_sdk_version": "3.8.0 (build 3.8.0-70.0.dev)",
"dart_sdk_arch": "x64",
"release_date": "2025-02-19T19:31:32.712796Z",
"archive": "beta/windows/flutter_windows_3.30.0-0.1.pre-beta.zip",
"sha256": "685242519777de165c47f86da593b64801d16e61c572b77f69cc21b7055793fd"
},
{
"hash": "35c388afb57ef061d06a39b537336c87e0e3d1b1",
"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