mirror of
https://github.com/flutter/samples.git
synced 2026-05-29 10:29:29 +00:00
[linting_tool] Add lint rules list (#856)
This commit is contained in:
committed by
GitHub
parent
3b65403631
commit
6bac1b9694
44
experimental/linting_tool/lib/model/rules_store.dart
Normal file
44
experimental/linting_tool/lib/model/rules_store.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright 2021 The Flutter team. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:linting_tool/model/rule.dart';
|
||||
import 'package:linting_tool/repository/repository.dart';
|
||||
|
||||
class RuleStore extends ChangeNotifier {
|
||||
RuleStore() {
|
||||
fetchRules();
|
||||
}
|
||||
bool _isLoading = true;
|
||||
|
||||
bool get isLoading => _isLoading;
|
||||
|
||||
List<Rule> _rules = [];
|
||||
|
||||
List<Rule> get rules => _rules;
|
||||
|
||||
String? _error;
|
||||
|
||||
String? get error => _error;
|
||||
|
||||
Future<void> fetchRules() async {
|
||||
if (!_isLoading) _isLoading = true;
|
||||
notifyListeners();
|
||||
try {
|
||||
var rules = await Repository().getRulesList();
|
||||
_rules = rules;
|
||||
} on SocketException catch (e) {
|
||||
log(e.toString());
|
||||
_error = 'Check internet connection.';
|
||||
} on Exception catch (e) {
|
||||
log(e.toString());
|
||||
}
|
||||
_isLoading = false;
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user