xxxxxxxxxx
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
class MySvgIcon extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SvgPicture.asset(
'assets/icons/my_icon.svg',
// You can provide additional properties for customization
width: 24,
height: 24,
color: Colors.red,
// ...
);
}
}
xxxxxxxxxx
dependencies:
flutter_svg: ^0.18.0
flutter pub get
import 'package:flutter_svg/flutter_svg.dart';
SvgPicture.asset("images/doughnut.svg")
xxxxxxxxxx
flutter pub add flutter_svg
import 'package:flutter_svg/flutter_svg.dart';
SvgPicture.asset("images/doughnut.svg")
xxxxxxxxxx
new SvgPicture.asset(
'assets/images/candle.svg',
height: 20.0,
width: 20.0,
allowDrawingOutsideViewBox: true,
),
xxxxxxxxxx
final String assetName = 'assets/image.svg';
final Widget svg = SvgPicture.asset(
assetName,
semanticsLabel: 'Acme Logo'
);
xxxxxxxxxx
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
class SvgToIconExample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('SVG to Icon'),
),
body: Center(
child: Icon(
Icons.person, // Replace with your desired icon
size: 48.0,
color: Colors.blue,
),
),
);
}
}