diff options
author | davidpkj <davidpenkow1@gmail.com> | 2023-03-11 17:54:46 +0100 |
---|---|---|
committer | davidpkj <davidpenkow1@gmail.com> | 2023-03-11 17:54:46 +0100 |
commit | 0570147b3104eb329207ff374541d9d6797fe427 (patch) | |
tree | 41da77cffc72c8a8e9329c9dde0bff3a4c7f9ecc /lib/views/file_info.dart | |
parent | c9acbf458ff90d37be76fa32aeb1a2591d87144f (diff) |
Updated code to dart analysis recommendations
Diffstat (limited to 'lib/views/file_info.dart')
-rw-r--r-- | lib/views/file_info.dart | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/lib/views/file_info.dart b/lib/views/file_info.dart deleted file mode 100644 index 28c45f9..0000000 --- a/lib/views/file_info.dart +++ /dev/null @@ -1,103 +0,0 @@ -import 'dart:io'; - -import 'package:flutter/material.dart'; - -import 'package:kulinar_app/constants.dart'; -import 'package:kulinar_app/util/file_handler.dart'; -import 'package:kulinar_app/widgets/error_widgets.dart'; - -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; - -class FileInfo extends StatefulWidget { - const FileInfo({Key? key, required this.filePath}) : super(key: key); - - final String filePath; - - @override - FileInfoState createState() => FileInfoState(); -} - -class FileInfoState extends State<FileInfo> { - @override - Widget build(BuildContext context) { - final File _file = File(widget.filePath.split(":")[1]); - - return Scaffold( - appBar: AppBar(title: Text(AppLocalizations.of(context)!.category9)), - body: FutureBuilder( - future: FileHandler.deserializeFileInformation(_file), - builder: (BuildContext context, AsyncSnapshot<Map<String, String>> snapshot) { - if (snapshot.connectionState != ConnectionState.done) return const CircularProgressIndicator(); - if (snapshot.hasError || !snapshot.hasData) return const UnknownError(); - - return _buildFileInfoTable(_getSortedSnapshotData(snapshot), _file); - }, - ), - ); - } - - String _localizeInfoField(BuildContext context, String field) { - switch (field) { - case "type": - return AppLocalizations.of(context)!.infoField1; - case "version": - return AppLocalizations.of(context)!.infoField2; - case "size": - return AppLocalizations.of(context)!.infoField3; - case "entries": - return AppLocalizations.of(context)!.infoField4; - default: - return AppLocalizations.of(context)!.unknown; - } - } - - List<TableRow> _getSortedSnapshotData(AsyncSnapshot<Map<String, String>> snapshot) { - List<TableRow> _children = []; - - snapshot.data!.forEach((key, value) { - _children.add( - TableRow( - children: [ - Padding( - padding: const EdgeInsets.only(right: 4.0), - child: Text(_localizeInfoField(context, key), style: cTableKeyStyle, textAlign: TextAlign.right), - ), - Padding( - padding: const EdgeInsets.only(left: 4.0), - child: Text(value, style: cTableValueStyle), - ), - ], - ), - ); - }); - - return _children; - } - - Widget _buildFileInfoTable(List<TableRow> children, File file) { - return Padding( - padding: const EdgeInsets.only(top: 16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Table( - columnWidths: const <int, TableColumnWidth>{ - 0: FlexColumnWidth(), - 1: FlexColumnWidth(), - }, - children: children, - ), - Padding( - padding: const EdgeInsets.all(16.0), - child: ElevatedButton( - child: Text(AppLocalizations.of(context)!.option312, style: cOptionTextStyle.copyWith(color: cIconColor)), - onPressed: () { - FileHandler.deserializeFile(context, file); - }, - ), - ), - ], - ), - ); - } -} |