Saltar al contenido principal

API desaprobada eliminada después de la v2.2

Después de llegar al final de su vida útil, las siguientes API desaprobadas fueron eliminadas de Flutter.

Resumen

#

De acuerdo con la política de desaprobación de Flutter, se han eliminado las API desaprobadas que llegaron al final de su vida útil después del lanzamiento estable 2.2.

Todas las API afectadas se han recopilado en esta fuente principal para ayudar en la migración. También está disponible una hoja de referencia rápida.

Cambios

#

Esta sección enumera las desaprobaciones, clasificadas por la clase afectada.

hasFloatingPlaceholder de InputDecoration y InputDecorationTheme

#

Compatible con Flutter Fix: sí

hasFloatingPlaceholder fue desaprobada en la v1.13.2. Usa floatingLabelBehavior en su lugar. Donde useFloatingPlaceholder era true, reemplázalo con FloatingLabelBehavior.auto. Donde useFloatingPlaceholder era false, reemplázalo con FloatingLabelBehavior.never. Este cambio permite especificar más comportamientos más allá de la opción binaria original, agregando FloatingLabelBehavior.always como una opción adicional.

Migration guide

Código antes de la migración:

dart
// InputDecoration
// Base constructor
InputDecoration(hasFloatingPlaceholder: true);
InputDecoration(hasFloatingPlaceholder: false);

// collapsed constructor
InputDecoration.collapsed(hasFloatingPlaceholder: true);
InputDecoration.collapsed(hasFloatingPlaceholder: false);

// Field access
inputDecoration.hasFloatingPlaceholder;

// InputDecorationTheme
// Base constructor
InputDecorationTheme(hasFloatingPlaceholder: true);
InputDecorationTheme(hasFloatingPlaceholder: false);

// Field access
inputDecorationTheme.hasFloatingPlaceholder;

// copyWith
inputDecorationTheme.copyWith(hasFloatingPlaceholder: false);
inputDecorationTheme.copyWith(hasFloatingPlaceholder: true);

Código después de la migración:

dart
// InputDecoration
// Base constructor
InputDecoration(floatingLabelBehavior: FloatingLabelBehavior.auto);
InputDecoration(floatingLabelBehavior: FloatingLabelBehavior.never);

// collapsed constructor
InputDecoration.collapsed(floatingLabelBehavior: FloatingLabelBehavior.auto);
InputDecoration.collapsed(floatingLabelBehavior: FloatingLabelBehavior.never);

// Field access
inputDecoration.floatingLabelBehavior;

// InputDecorationTheme
// Base constructor
InputDecorationTheme(floatingLabelBehavior: FloatingLabelBehavior.auto);
InputDecorationTheme(floatingLabelBehavior: FloatingLabelBehavior.never);

// Field access
inputDecorationTheme.floatingLabelBehavior;

// copyWith
inputDecorationTheme.copyWith(floatingLabelBehavior: FloatingLabelBehavior.never);
inputDecorationTheme.copyWith(floatingLabelBehavior: FloatingLabelBehavior.auto);

References

Documentación de la API:

Issues relevantes:

PRs relevantes:


TextTheme

#

Compatible con Flutter Fix: sí

Varias propiedades de TextStyle de TextTheme quedaron obsoletas en la v1.13.8. Están listadas en la siguiente tabla junto con el reemplazo correspondiente en la nueva API.

DesaprobaciónNueva API
display4headline1
display3headline2
display2headline3
display1headline4
headlineheadline5
titleheadline6
subheadsubtitle1
body2bodyText1
body1bodyText2
subtitlesubtitle2

Migration guide

Código antes de la migración:

dart
// TextTheme
// Base constructor
TextTheme(
  display4: displayStyle4,
  display3: displayStyle3,
  display2: displayStyle2,
  display1: displayStyle1,
  headline: headlineStyle,
  title: titleStyle,
  subhead: subheadStyle,
  body2: body2Style,
  body1: body1Style,
  caption: captionStyle,
  button: buttonStyle,
  subtitle: subtitleStyle,
  overline: overlineStyle,
);

// copyWith
TextTheme.copyWith(
  display4: displayStyle4,
  display3: displayStyle3,
  display2: displayStyle2,
  display1: displayStyle1,
  headline: headlineStyle,
  title: titleStyle,
  subhead: subheadStyle,
  body2: body2Style,
  body1: body1Style,
  caption: captionStyle,
  button: buttonStyle,
  subtitle: subtitleStyle,
  overline: overlineStyle,
);

// Getters
TextStyle style;
style = textTheme.display4;
style = textTheme.display3;
style = textTheme.display2;
style = textTheme.display1;
style = textTheme.headline;
style = textTheme.title;
style = textTheme.subhead;
style = textTheme.body2;
style = textTheme.body1;
style = textTheme.caption;
style = textTheme.button;
style = textTheme.subtitle;
style = textTheme.overline;

Código después de la migración:

dart
// TextTheme
// Base constructor
TextTheme(
  headline1: displayStyle4,
  headline2: displayStyle3,
  headline3: displayStyle2,
  headline4: displayStyle1,
  headline5: headlineStyle,
  headline6: titleStyle,
  subtitle1: subheadStyle,
  bodyText1: body2Style,
  bodyText2: body1Style,
  caption: captionStyle,
  button: buttonStyle,
  subtitle2: subtitleStyle,
  overline: overlineStyle,
);

TextTheme.copyWith(
  headline1: displayStyle4,
  headline2: displayStyle3,
  headline3: displayStyle2,
  headline4: displayStyle1,
  headline5: headlineStyle,
  headline6: titleStyle,
  subtitle1: subheadStyle,
  bodyText1: body2Style,
  bodyText2: body1Style,
  caption: captionStyle,
  button: buttonStyle,
  subtitle2: subtitleStyle,
  overline: overlineStyle,
);

TextStyle style;
style = textTheme.headline1;
style = textTheme.headline2;
style = textTheme.headline3;
style = textTheme.headline4;
style = textTheme.headline5;
style = textTheme.headline6;
style = textTheme.subtitle1;
style = textTheme.bodyText1;
style = textTheme.bodyText2;
style = textTheme.caption;
style = textTheme.button;
style = textTheme.subtitle2;
style = textTheme.overline;

References

Documento de diseño:

Documentación de la API:

Issues relevantes:

PRs relevantes:


Typography predeterminada

#

Compatible con Flutter Fix: no

La Typography predeterminada fue desaprobada en la v1.13.8. El valor predeterminado anterior devolvía los estilos de texto de la especificación Material Design de 2014. Esto ahora dará como resultado que los TextStyles reflejen la especificación Material Design de 2018. Para el primero, usa el constructor material2014.

Migration guide

Código antes de la migración:

dart
// Formerly returned 2014 TextStyle spec
Typography();

Código después de la migración:

dart
// Use 2018 TextStyle spec, either by default or explicitly.
Typography();
Typography.material2018();

// Use 2014 spec from former API
Typography.material2014();

References

Documento de diseño:

Documentación de la API:

Issues relevantes:

PRs relevantes:


Timeline

#

En versión estable: 2.5