-
Notifications
You must be signed in to change notification settings - Fork 5
Assets
Efra Espada edited this page Apr 26, 2021
·
9 revisions
Stringcare can obfuscate your assets files. Include any asset file you need:
root
|
|_ assets
| |_ # obfuscated assets files
|
|_ assets_base
| |_ voyager.jpeg
|
|_ assets_test
|_ # test revealed assets files
stringcare:
assets_path: "assets" # obfuscated langs path
assets_base_path: "assets_base" # original langs path
assets_reveal_test_path: "assets_test" # test reveal langs path (only needed for testing)
flutter:
assets:
- assets/voyager.jpegRun this command to generate the obfuscated assets files:
flutter pub run stringcare:obfuscate Once the obfuscated assets files are generated, you can test the reveal:
flutter pub run stringcare:revealSample revealing image assets:
Uint8List image;
@override
void initState() {
super.initState();
initImageState();
}
Future<void> initImageState() async {
rootBundle.load('assets/voyager.jpeg').then((value) {
var list = value.buffer.asUint8List();
var revealed = Stringcare.revealData(list);
if (!mounted) return;
setState(() {
image = revealed;
});
});
}Load the image when Uint8List is ready:
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
padding: EdgeInsets.all(15),
child: Column(
children: [
if (image != null)
Image(
width: 400,
height: 400,
image: MemoryImage(image),
fit: BoxFit.fitHeight),
],
),
),
);
}