mirror of
https://github.com/flutter/samples.git
synced 2026-04-01 17:23:18 +00:00
[linting_tool] Implement exporting profiles (#869)
This commit is contained in:
committed by
GitHub
parent
a46327ef80
commit
9986fe2f2c
@@ -5,6 +5,7 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:linting_tool/model/rule.dart';
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
||||
class APIProvider {
|
||||
final _baseURL = 'https://dart-lang.github.io/linter';
|
||||
@@ -12,7 +13,7 @@ class APIProvider {
|
||||
APIProvider(this.httpClient);
|
||||
|
||||
Future<List<Rule>> getRulesList() async {
|
||||
http.Response response =
|
||||
final response =
|
||||
await httpClient.get(Uri.parse('$_baseURL//lints/machine/rules.json'));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
@@ -26,4 +27,14 @@ class APIProvider {
|
||||
throw Exception('Failed to load rules');
|
||||
}
|
||||
}
|
||||
|
||||
Future<YamlMap> getTemplateFile() async {
|
||||
final response = await httpClient.get(Uri.parse(
|
||||
'https://raw.githubusercontent.com/flutter/flutter/master/packages/flutter_tools/templates/app_shared/analysis_options.yaml.tmpl'));
|
||||
if (response.statusCode == 200) {
|
||||
return loadYaml(response.body) as YamlMap;
|
||||
} else {
|
||||
throw Exception('Failed to load template file');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import 'package:linting_tool/model/rule.dart';
|
||||
import 'package:linting_tool/repository/api_provider.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
||||
class Repository {
|
||||
late final APIProvider _apiProvider;
|
||||
@@ -14,4 +15,6 @@ class Repository {
|
||||
}
|
||||
|
||||
Future<List<Rule>> getRulesList() => _apiProvider.getRulesList();
|
||||
|
||||
Future<YamlMap> getTemplateFile() => _apiProvider.getTemplateFile();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user