xxxxxxxxxx
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
class SvgImageScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('SVG Image'),
),
body: Center(
child: SvgPicture.asset(
'assets/images/sample.svg', // Replace with your SVG image path
height: 200,
width: 200,
),
),
);
}
}
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
import 'package:flutter_svg/flutter_svg.dart';
// ...
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('SVG Image Example'),
),
body: Center(
child: SvgPicture.asset(
'assets/images/example.svg', // Replace with your SVG image file path
height: 200, // Adjust the height as needed
width: 200, // Adjust the width as needed
),
),
);
}
xxxxxxxxxx
final String assetName = 'assets/image.svg';
final Widget svg = SvgPicture.asset(
assetName,
semanticsLabel: 'Acme Logo'
);
xxxxxxxxxx
// ImageProvider does not support SvgPicture.asset()
// the following code will throw an error because flutter_svg package is not compatible with image provider
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: SvgPicture.asset(''),
),
),
),
// instead, you can use flutter_svg_provider package. It suppports image provider
xxxxxxxxxx
return AutoTabsRouter.pageView(
routes: const [
MainRoute(),
MaintenanceRoute(),
PaymentsRoute(),
],
builder: (context, child, _) {
return Scaffold(
appBar: AppBar(
title: Text(context.topRoute.name),
leading: const AutoLeadingButton(),
),
body: child,
bottomNavigationBar: BottomNavigationBar(
currentIndex: currentIndex,
onTap: (index) =>
context.read<MenuCubit>().setTab(MenuTabs.values[index]),
items: const [
BottomNavigationBarItem(
label: 'Main',
icon: Icon(Icons.home),
),
BottomNavigationBarItem(
label: 'Maintenance',
icon: Icon(Icons.work),
),
BottomNavigationBarItem(
label: 'Payment',
icon: Icon(Icons.payment),
),
],
),
);
},
);