Home > Back-end >  Futter: What is the type of SvgPicture?
Futter: What is the type of SvgPicture?

Time:07-17

class CustomProfile extends StatelessWidget {
  final String title;
  final **....** svgPic;

  const CustomProfile({
    required this.title,
    required this.svgPic,

And then how can I call it? column ([children: Svg..?..(svgPic)]),

CodePudding user response:

You can use SvgPicture

class CustomProfile extends StatelessWidget {
  final String title;
  final SvgPicture svgPic;
  const CustomProfile({
    Key? key,
    required this.title,
    required this.svgPic,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        svgPic,
      ],
    );
  }
}

And use like

CustomProfile(
  title: "title",
  svgPic: SvgPicture.asset(""),
)

Also, you can provide path instead of widget, for this use String

class CustomProfile extends StatelessWidget {
  final String title;
  final String path;
  const CustomProfile({
    Key? key,
    required this.title,
    required this.path,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        SvgPicture.asset(path),
      ],
    );
  }
}

And use it like

CustomProfile(
  title: "",
  path: "",
)
  • Related