Skip to content
pubscout

interpolation

2.1.2, released 5 years ago by marganam.com

A Dart package to handle dynamic String and Json interpolation.

WASM-ready
$ flutter pub add interpolation
Source repository

What it does

It provides methods to evaluate and interpolate dynamic strings using variable maps and nested object paths. It also allows traversing and fully resolving JSON-like objects containing interpolation templates.

AI-written summary of version 2.1.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to dynamically interpolate strings with map data at runtime.
  • You need to resolve nested string templates inside JSON or Map structures.

Skip it when

  • You only need standard Dart compile-time string interpolation.
  • You require complex logic evaluation within string templates.

Strengths

  • Supports nested object path resolution using dot notation.
  • Can traverse and resolve entire JSON structures safely without altering the original object.
  • Zero dependencies.

Weaknesses

  • Limited to basic map lookups for interpolation keys.
  • No documentation on complex expression evaluation.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0
import 'package:interpolation/interpolation.dart';

void main() {
  var interpolation = Interpolation();
  var str = "Hi, my name is '{name}'. I'm {age}.";
  print(interpolation.eval(str, {'name': 'David', 'age': 29}));
}

Alternatives

Packages that do the same job and could replace interpolation.

  • deep_pick

    Type-safe API for manual JSON parsing with useful error messages.

  • validators2

    String validation and sanitization for Dart.

  • json_schema

    Validate JSON data against JSON Schema drafts in Dart.

  • stringr

    Comprehensive string manipulation library supporting Latin, non-Latin, and grapheme clusters.