minor change

This commit is contained in:
Thibault Deckers 2020-12-10 10:42:02 +09:00
parent 6d9b6b4484
commit 6beb814ff8
4 changed files with 14 additions and 12 deletions

View file

@ -26,7 +26,10 @@ Aves is a gallery and metadata explorer app. It is built for Android, with Flutt
- gesture: double tap on image does not zoom on tapped area (cf [photo_view issue #82](https://github.com/renancaraujo/photo_view/issues/82))
- performance: image info page stutters the first time it loads a Google Maps view (cf [flutter issue #28493](https://github.com/flutter/flutter/issues/28493))
- performance: image decoding is slow
- SVG: unsupported `currentColor` (cf [flutter_svg issue #31](https://github.com/dnfield/flutter_svg/issues/31))
- SVG: unsupported out of order defs/references (cf [flutter_svg issue #102](https://github.com/dnfield/flutter_svg/issues/102))
- SVG: unsupported `<style>` (cf [flutter_svg issue #105](https://github.com/dnfield/flutter_svg/issues/105))
- SVG: limited support for `%`, `mm` or `pt` unit (cf [flutter_svg issue #110](https://github.com/dnfield/flutter_svg/issues/110))
## Test Devices

View file

@ -173,7 +173,7 @@ class _MetadataSectionSliverState extends State<MetadataSectionSliver> with Auto
child: InfoRowGroup(
dir.tags,
maxValueLength: Constants.infoGroupMaxValueLength,
linkHandlers: dirName == SvgMetadata.directory ? SvgMetadata.getLinkHandlers(dir.tags) : null,
linkHandlers: dirName == SvgMetadata.metadataDirectory ? SvgMetadata.getLinkHandlers(dir.tags) : null,
),
),
],

View file

@ -12,7 +12,8 @@ import 'package:flutter/material.dart';
import 'package:xml/xml.dart';
class SvgMetadata {
static const directory = 'SVG';
static const docDirectory = 'Document';
static const metadataDirectory = 'Metadata';
static const _attributes = ['x', 'y', 'width', 'height', 'preserveAspectRatio', 'viewBox'];
static const _textElements = ['title', 'desc'];
@ -20,21 +21,24 @@ class SvgMetadata {
static Future<Map<String, Map<String, String>>> getAllMetadata(ImageEntry entry) async {
try {
final result = <String, String>{};
final data = await ImageFileService.getImage(entry.uri, entry.mimeType, 0, false);
final document = XmlDocument.parse(utf8.decode(data));
final root = document.rootElement;
final metadata = root.getElement(_metadataElement);
result.addEntries([
final docDir = Map.fromEntries([
...root.attributes.where((a) => _attributes.contains(a.name.qualified)).map((a) => MapEntry(_formatKey(a.name.qualified), a.value)),
..._textElements.map((name) => MapEntry(_formatKey(name), root.getElement(name)?.text)).where((kv) => kv.value != null),
]);
final metadata = root.getElement(_metadataElement);
final metadataDir = Map.fromEntries([
if (metadata != null) MapEntry('Metadata', metadata.toXmlString(pretty: true)),
]);
return {
directory: result,
if (docDir.isNotEmpty) docDirectory: docDir,
if (metadataDir.isNotEmpty) metadataDirectory: metadataDir,
};
} catch (exception, stack) {
debugPrint('failed to parse XML from SVG with exception=$exception\n$stack');

View file

@ -9,11 +9,6 @@ version: 1.2.8+34
# - does not support TIFF with JPEG compression (issue #184)
# - TIFF tile decoding is not public (issue #258)
# dnfield/flutter_svg (as of v0.19.1):
# - `Could not parse "currentColor" as a color`: https://github.com/dnfield/flutter_svg/issues/31
# - `The <style> element is not implemented in this library.`: https://github.com/dnfield/flutter_svg/issues/105
# - inconsistent % unit support: https://github.com/dnfield/flutter_svg/issues/110
# video_player (as of v0.10.8+2, backed by ExoPlayer):
# - does not support content URIs (by default, but trivial by fork)
# - does not support AVI/XVID, AC3