Reputation: 619
I have a bunch of byte arrays that I have to save in my flutter application.
At the moment I convert those byte arrays to base64, and saving them as a single line string.
Is there any better way to save bytes using shared preferences lib/some other lib?
Upvotes: 1
Views: 682
Reputation: 5831
base64 encode is good start, but it will produce very long string.
How about adding additional process by compress those bytes first using gzip, and then save it on local storage using SharedPreference
or Hive
import 'dart:convert';
...
final gZipBytes = gzip.encode(bytesArray);
localStorage.save(key, base64.encode(gZipBytes));
Upvotes: 1