Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 如何将数据从TabBarView父级传递到选项卡?_Flutter_Dart - Fatal编程技术网

Flutter 如何将数据从TabBarView父级传递到选项卡?

Flutter 如何将数据从TabBarView父级传递到选项卡?,flutter,dart,Flutter,Dart,我有三个选项卡,它们将从TabView(控制选项卡的小部件)接收字符串 我的代码如下所示: body: TabBarView( children: [ FloatingActionButtonWidget(), videosListForTab(), // <-- want to send string to imagesListForTab(), // <-- want

我有三个选项卡,它们将从TabView(控制选项卡的小部件)接收字符串

我的代码如下所示:

body: TabBarView(
            children: [
              FloatingActionButtonWidget(),
              videosListForTab(), // <-- want to send string to 
              imagesListForTab(),  // <-- want to send string to 
              Icon(Icons.label),
            ],
          )
body:TabBarView(
儿童:[
FloatingActionButtonWidget(),

videosListForTab(),//尝试将您的函数(我猜它是一个函数)更改为

List videosListForTab(字符串值){…}
列表imagesListForTab(字符串值){…}

更改选项卡小部件构造函数以接收参数。 例如:

class VideosListForTab extends StatelessWidget {

  final String value;

  // This way, when instantiating the Widget, you have to pass the String
  VideosListForTab(this.value);

  @override
  Widget build(BuildContext context) {
    // return your Widget here
    return Container();
  }
}
您可以通过以下方式创建小部件:

body: TabBarView(
        children: [
          FloatingActionButtonWidget(),
          videosListForTab("parameter as you want"), // <-- want to send string to 
          imagesListForTab(),  // <-- want to send string to 
          Icon(Icons.label),
        ],
      )
body: TabBarView(
        children: [
          FloatingActionButtonWidget(),
          videosListForTab(
              value: "parameter as you want"
          ), // <-- want to send string to 
          imagesListForTab(),  // <-- want to send string to 
          Icon(Icons.label),
        ],
      )
您可以通过以下方式创建小部件:

body: TabBarView(
        children: [
          FloatingActionButtonWidget(),
          videosListForTab("parameter as you want"), // <-- want to send string to 
          imagesListForTab(),  // <-- want to send string to 
          Icon(Icons.label),
        ],
      )
body: TabBarView(
        children: [
          FloatingActionButtonWidget(),
          videosListForTab(
              value: "parameter as you want"
          ), // <-- want to send string to 
          imagesListForTab(),  // <-- want to send string to 
          Icon(Icons.label),
        ],
      )
body:TabBarView(
儿童:[
FloatingActionButtonWidget(),
录像带(
值:“根据需要设置参数”

),//我会试试,然后回来告诉你它是否有效。它非常有效……谢谢你不客气。请接受我的正确答案。谢谢。