Skip to content
Efra Espada edited this page May 3, 2021 · 9 revisions

Stringcare can obfuscate your assets files. Include any asset file you need:

Project Configuration

root
  |
  |_ assets
  |    |_ # obfuscated assets files
  |    
  |_ assets_base
  |    |_ voyager.jpeg
  |
  |_ assets_test
       |_ # test revealed assets files

stringcare:
  assets:
    obfuscated: "assets"     # obfuscated assets path
    original: "assets_base"  # original assets path
    test: "assets_test"      # test reveal assets path (only needed for testing)
  resources:
    class_name: "R"           # R class for accessing resources
    class_dir: "lib"          # R class directory

flutter:
  assets:
    - assets/voyager.jpeg

Run 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:reveal

Simple Usage

Sample revealing any asset file:

Uint8List data = await Stringcare.revealAsset(R.assets.images_voyager_jpeg);

With extensions:

var data = await R.assets.images_voyager_jpeg.revealAsset();

Assets Images Usage

Sample using the asset image widget:

@override
Widget build(BuildContext context) {
  return Scaffold(
    body: ScImageAsset(
       name: R.assets.images_voyager_jpeg,
       height: 400,
       width: 400,
    ),
  );
}

Sample using the asset image provider:

@override
Widget build(BuildContext context) {
  return Scaffold(
    body: Container(
      decoration: BoxDecoration(
        image: DecorationImage(
          fit: BoxFit.none,
          image: ScAssetImageProvider(R.assets.images_voyager_jpeg),
          repeat: ImageRepeat.repeat
        )
      ),
      child: Text("Voyager")
    )
  );
}

Svg Assets Images Usage

This widget works with flutter_svg package. It is like calling SvgPicture.memory() but first revealing the asset.

@override
Widget build(BuildContext context) {
  return Scaffold(
    body: ScSvg(R.assets.images_coding_svg)
  );
}