Al intentar mostrar una imagen con extensión svg me he encontrado con el siguiente error:



@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("BIENVENID@ a DevCodeLight"),
Container(
width: 200.0,
height: 200.0,
child: Image.asset('lib/images/android/splahs_android.svg')),
],
),
),
);
}
Lo solucioné agregando el paquete de flutter_svg

El el archivo pubspec.yaml hay que añadir la ruta para la imagen que se quiere mostrar como se observa a continuación:

En el proyecto, añadimos dentro de lib, una carpeta que se llame images, dentro de esta, otra que se llame android que debe contener la imagen con extensión svg

Para visualizar la imagen dentro de una vista en dart, añadiremos el siguiente código dentro del Widget correspondiente

@override
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
body: Center(
child:Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("BIENVENID@ a DevCodeLight"),
Container(
width: 200.0,
height: 200.0,
child:SvgPicture.asset('lib/images/android/splahs_android.svg')
),
],
),
),
);
}
Y el resultado es el siguiente:

Espero que os sirva de ayuda
Que tengáis un feliz día
