简体   繁体   English

比较 dart/flutter 中的 svg 文件

[英]Compare svg files in dart/flutter

I have two svg files from network.我有两个来自网络的 svg 文件。 They are similar in content but with different filenames.它们的内容相似,但文件名不同。 Is there a way, in dart or flutter, I could compare these files content?有没有办法,在 dart 或 flutter 中,我可以比较这些文件的内容?

I want to do something like:我想做类似的事情:

if(fileOne.svg == fileTwo.svg){//do something here with similar files}

Welcome to SOF.欢迎来到 SOF。

You can compare two files from assets by reading them as bytes:您可以通过将资产读取为字节来比较两个文件:

import 'package:flutter/services.dart' show rootBundle;


ByteData bytes1 = await rootBundle.load('assets/fileOne.svg');
ByteData bytes2 = await rootBundle.load('assets/fileTwo.svg');

Then compare bytes1 and bytes2然后比较bytes1bytes2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM