1
1
import 'dart:io' ;
2
2
3
- import 'package:fvm/src/utils/logger.dart' ;
4
-
5
3
import '../../../exceptions.dart' ;
6
4
import '../../utils/http.dart' ;
5
+ import '../../utils/logger.dart' ;
7
6
import 'models/flutter_releases.model.dart' ;
8
7
8
+ final _envVars = Platform .environment;
9
9
const _storageDefaultBase = 'https://storage.googleapis.com' ;
10
10
11
11
/// Returns Google's storage url for releases
12
12
String get storageUrl {
13
- final envVars = Platform .environment;
14
-
15
13
/// Uses environment variable if configured.
16
- return envVars ['FLUTTER_STORAGE_BASE_URL' ] ?? _storageDefaultBase;
14
+ return _envVars ['FLUTTER_STORAGE_BASE_URL' ] ?? _storageDefaultBase;
17
15
}
18
16
19
17
/// Gets platform specific release URL for a [platform]
20
18
/// Defaults to the platform's OS.
21
19
/// returns [url] for the list of the platform releases.
22
- String getReleasesUrl ({String ? platform}) {
20
+ String getGoogleReleaseUrl ({String ? platform}) {
23
21
platform ?? = Platform .operatingSystem;
24
22
return '$storageUrl /flutter_infra_release/releases/releases_$platform .json' ;
25
23
}
26
24
27
- String _getBackupReleaseUrl ({String ? platform}) {
25
+ /// Returns a CDN cached version of the releaes per platform
26
+ String getReleasesUrl ({String ? platform}) {
28
27
platform ?? = Platform .operatingSystem;
29
- return 'https://raw.githubusercontent.com/leoafarias/flutter_flat_data/main/releases_$platform .json' ;
28
+ return _envVars['FLUTTER_RELEASES_URL' ] ??
29
+ 'https://raw.githubusercontent.com/leoafarias/fvm/main/releases_$platform .json' ;
30
30
}
31
31
32
32
FlutterReleases ? _cacheReleasesRes;
@@ -47,12 +47,12 @@ Future<FlutterReleases> fetchFlutterReleases({bool cache = true}) async {
47
47
logger.trace (err.toString ());
48
48
49
49
try {
50
- final response = await fetch (_getBackupReleaseUrl ());
50
+ final response = await fetch (getGoogleReleaseUrl ());
51
51
_cacheReleasesRes = FlutterReleases .fromJson (response);
52
52
return Future .value (_cacheReleasesRes);
53
53
} on Exception {
54
54
throw FvmInternalError (
55
- 'Failed to retrieve the Flutter SDK from: ${getReleasesUrl ()}\n '
55
+ 'Failed to retrieve the Flutter SDK from: ${getGoogleReleaseUrl ()}\n '
56
56
'Fvm will use the value set on '
57
57
'env FLUTTER_STORAGE_BASE_URL to check versions\n '
58
58
'if you are located in China, please see this page: https://flutter.dev/community/china' ,
0 commit comments