to_string_helper 1.0.3-beta copy "to_string_helper: ^1.0.3-beta" to clipboard
to_string_helper: ^1.0.3-beta copied to clipboard

discontinued
outdated

Flexibly configure output of toString method (with or without code generation).

example/example.md

Simple example (without code generator) #

  • pubspec.yaml

    dependencies:
      to_string_helper:
    
  • bike.dart

    import 'package:to_string_helper/to_string_helper.dart';
      
    class Bike {
      final hasEngine = false;
      final wheels = 2;
      
      @override
      String toString() {
        return ToStringHelper(this)
          .add('wheels', wheels) // named value
          .addValue(hasEngine) // unnamed value
          .toString();
      }
    }
    

Simple example (with code generator) #

  • Require package to_string_helper_generator

  • pubspec.yaml

    dependencies:
      to_string_helper:
    
    dev_dependencies:
      build_runner:
      to_string_helper_generator:
    
  • bike.dart

    import 'package:to_string_helper/to_string_helper.dart';
    
    part 'bike.g.dart';
    
    @ToString()
    class Bike {
      final hasEngine = false;
    
      @ToStringField(exclude: true)
      final wheels = 2;
      
      @override
      String toString() {
        // Name of the generated method is in format _$<className>ToString()
        return _$bikeToString(this);
      }
    }
    
1
likes
0
pub points
0%
popularity

Publisher

verified publisherzenonine.com

Flexibly configure output of toString method (with or without code generation).

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on to_string_helper