Quick help with variables in custom widget

Troubleshooting

Hi,

just wanted to understand how to use a variable in a widget.

This is my code of the widget, where i want to add the parameter srcURL in the widget.

I already tried something like "widget.srcURL" or "$srcURL" but it seems like not to work since the compiler is giving me always errors, how i can make the "src:" as a variabe from the parameter "srcURL"?

class Viewer extends StatefulWidget {
  const Viewer({
    super.key,
    this.width,
    this.height,
    required this.srcURL,
  });

  final double? width;
  final double? height;
  final String srcURL;

  @override
  State<Viewer> createState() => _ViewerState();
}

class _ViewerState extends State<Viewer> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Header')),
        body: const ModelViewer(
          backgroundColor: Color.fromARGB(0xFF, 0xEE, 0xEE, 0xEE),
          src: widget.srcURL,
          alt: 'Homer Cool',
          ar: true,
          autoRotate: true,
          iosSrc: 'SOMEURLHERE',
          disableZoom: true,
        ),
      ),
    );
  }
}

Updated. Guess i am coming closer to the result.

What have you tried so far?

Described above

Did you check FlutterFlow's Documentation for this topic?
No
1
1 reply