string_obfuscation 0.1.3 copy "string_obfuscation: ^0.1.3" to clipboard
string_obfuscation: ^0.1.3 copied to clipboard

A build_runner generator that obfuscates Dart string literals at build time.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:string_obfuscation/string_obfuscation.dart';

part 'main.gen.dart';

@ClassEncrypt(encryptKey: 'example-key')
abstract class AppStrings {
  @StringEncrypt(value: 'String obfuscation')
  String get appTitle;

  @StringEncrypt(value: 'Generated strings are ready to use.')
  String get welcomeMessage;

  String get startButton;
}

@ClassJsonGenerator(encryptKey: 'example-key')
class User {
  final String name;
  final int? age;

  const User({required this.name, this.age});

  factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);

  Map<String, dynamic> toJson() => _$UserToJson(this);
}

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    print(User(name: 'name').toJson());
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text(appStrings.appTitle),
        ),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Text(appStrings.welcomeMessage),
              const SizedBox(height: 16),
              ElevatedButton(
                onPressed: () {},
                child: Text(appStrings.startButton),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
150
points
22
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A build_runner generator that obfuscates Dart string literals at build time.

Repository (GitHub)
View/report issues

Topics

#code-generation #obfuscation

License

MIT (license)

Dependencies

analyzer, build, source_gen

More

Packages that depend on string_obfuscation