最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

flutter - In FlutterFlow, how do I pass a Widget Builder into a Custom Code Widget and modify its parameters or state? - Stack O

programmeradmin3浏览0评论

In FlutterFlow, in my custom code Widget I want to pass in a Component (ExhibitCellStatic) as a Widget Builder and use it as an overlay. However, I want to modify its data before including it in my custom code Widget's build() method. I have a "title" parameter specified in the custom code Widget's Widget Builder params:

It seems that when instantiating the Widget Builder (ExhibitCellStatic) in the custom code, it's ignoring any parameters...

class CustomComp extends StatefulWidget {
  const CustomComp({
    super.key,
    this.width,
    this.height,
    required this.exhibitCellWidget,

    final double? width;
    final double? height;
    final Widget Function(String? title) exhibitCellWidget;
  });

  @override
  State<CustomComp> createState() => _CustomCompState();
}

class _CustomCompState extends State<CustomComp> {
  @override
  Widget build(BuildContext context) {
    return widget.exhibitCellWidget("Hello Title") // shows "Title From FF Layout"
  }
}

...instead, it seems to only use what was passed in from where it was specified in the FF layout editor:

Is there any other way to modify the data being displayed in the Widget Builder from within the parent custom code? I thought maybe I could modify the Widget Builder's state variables but having trouble connecting the dots there. Something like:

var exhibitCell = widget.exhibitCellWidget("Ignored Title");
exhibitCell.setState((){
  this.title = "Hello World!";
});

Ideally the widget parameters would just be overridden in the custom code. Is this not supported?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论