1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 22:09:06 +00:00

[linting_tool] Implement exporting profiles (#869)

This commit is contained in:
Abdullah Deshmukh
2021-08-10 09:05:59 +05:30
committed by GitHub
parent a46327ef80
commit 9986fe2f2c
16 changed files with 224 additions and 10 deletions

View File

@@ -45,7 +45,7 @@ class SavedLintsPage extends StatelessWidget {
),
itemCount: profilesStore.savedProfiles.length,
cacheExtent: 5,
itemBuilder: (context, index) {
itemBuilder: (itemBuilderContext, index) {
var profile = profilesStore.savedProfiles[index];
return ListTile(
title: Text(
@@ -74,10 +74,21 @@ class SavedLintsPage extends StatelessWidget {
),
PopupMenuButton<String>(
icon: const Icon(Icons.more_vert),
onSelected: (value) {
onSelected: (value) async {
switch (value) {
case 'Export file':
// TODO(abd99): Implement exporting files.
// TODO(abd99): Add option to select formatting style.
var saved = await profilesStore
.exportProfileFile(profile);
if (!saved) {
_showSnackBar(
context,
profilesStore.error ?? 'Failed to save file.',
);
}
break;
case 'Delete':
profilesStore.deleteProfile(profile);
@@ -123,4 +134,12 @@ class SavedLintsPage extends StatelessWidget {
},
);
}
void _showSnackBar(BuildContext context, String data) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(data),
),
);
}
}