Typeface.fromJson constructor

Typeface.fromJson(
  1. Map<String, dynamic> data
)

Retrieve Typeface instance form data. If data is not valid, Typeface.redmond is returned.

const typeface = Typeface.fromJson(data)

Implementation

factory Typeface.fromJson(Map<String, dynamic> data) {
  //```codec
  const t = TextThemeCodec();
  //```
  return Typeface(
    background: t.decode(data['background']) ?? redmond.background,
    foreground: t.decode(data['foreground']) ?? redmond.foreground,
    //...surface
    primary: t.decode(data['primary']) ?? redmond.primary,
    secondary: t.decode(data['secondary']) ?? redmond.secondary,
    ascent: t.decode(data['ascent']) ?? redmond.ascent,
    //...on surface
    onPrimary: t.decode(data['onPrimary']) ?? redmond._primary,
    onSecondary: t.decode(data['onSecondary']) ?? redmond._secondary,
    onAscent: t.decode(data['onAscent']) ?? redmond._ascent,
    //...extras
    success: t.decode(data['success']) ?? redmond.success,
    error: t.decode(data['error']) ?? redmond.error,
    warning: t.decode(data['warning']) ?? redmond.error,
  );
}