mirror of
https://github.com/flutter/samples.git
synced 2025-11-09 06:18:49 +00:00
Some linting_tool updates and cleanup (#1279)
This commit is contained in:
@@ -8,8 +8,10 @@ import 'package:linting_tool/model/rule.dart';
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
||||
class APIProvider {
|
||||
final _baseURL = 'https://dart-lang.github.io/linter';
|
||||
static const String _baseURL = 'https://dart-lang.github.io/linter';
|
||||
|
||||
final http.Client httpClient;
|
||||
|
||||
APIProvider(this.httpClient);
|
||||
|
||||
Future<List<Rule>> getRulesList() async {
|
||||
@@ -17,11 +19,10 @@ class APIProvider {
|
||||
await httpClient.get(Uri.parse('$_baseURL//lints/machine/rules.json'));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
List<Rule> rulesList = [];
|
||||
final data = json.decode(response.body) as List;
|
||||
for (var item in data) {
|
||||
rulesList.add(Rule.fromJson(item as Map<String, dynamic>));
|
||||
}
|
||||
final rulesList = [
|
||||
for (final item in data) Rule.fromJson(item as Map<String, dynamic>)
|
||||
];
|
||||
return rulesList;
|
||||
} else {
|
||||
throw Exception('Failed to load rules');
|
||||
|
||||
Reference in New Issue
Block a user