1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 13:58:47 +00:00

[linting_tool] Add lint rules list (#856)

This commit is contained in:
Abdullah Deshmukh
2021-07-21 16:59:28 +05:30
committed by GitHub
parent 3b65403631
commit 6bac1b9694
13 changed files with 711 additions and 19 deletions

View File

@@ -3,13 +3,70 @@
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:linting_tool/model/rules_store.dart';
import 'package:linting_tool/layout/adaptive.dart';
import 'package:linting_tool/widgets/lint_expansion_tile.dart';
import 'package:provider/provider.dart';
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
// TODO(abd99): Implement HomePage, showing a list of supported lint rules.
return const Text('Home');
return Consumer<RuleStore>(
builder: (context, rulesStore, child) {
if (rulesStore.isLoading) {
return const CircularProgressIndicator.adaptive();
}
if (!rulesStore.isLoading) {
if (rulesStore.rules.isNotEmpty) {
final isDesktop = isDisplayLarge(context);
final isTablet = isDisplayMedium(context);
final startPadding = isTablet
? 60.0
: isDesktop
? 120.0
: 4.0;
final endPadding = isTablet
? 60.0
: isDesktop
? 120.0
: 4.0;
return ListView.separated(
padding: EdgeInsetsDirectional.only(
start: startPadding,
end: endPadding,
top: isDesktop ? 28 : 0,
bottom: isDesktop ? kToolbarHeight : 0,
),
itemCount: rulesStore.rules.length,
cacheExtent: 5,
itemBuilder: (context, index) {
return LintExpansionTile(
rule: rulesStore.rules[index],
);
},
separatorBuilder: (context, index) => const SizedBox(height: 4),
);
}
}
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(rulesStore.error ?? 'Failed to load rules.'),
const SizedBox(
height: 16.0,
),
IconButton(
onPressed: () => rulesStore.fetchRules(),
icon: const Icon(Icons.refresh),
),
],
);
},
);
}
}