Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.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 颤振-抓取Id';单个选项卡的编号_Flutter_Woocommerce Rest Api - Fatal编程技术网

Flutter 颤振-抓取Id';单个选项卡的编号

Flutter 颤振-抓取Id';单个选项卡的编号,flutter,woocommerce-rest-api,Flutter,Woocommerce Rest Api,您好,我是Flitter的新开发人员,正在使用WooCommerceAPI开发移动应用程序。我已将各个类别传递到选项卡中,但我需要获取它们的单个id,以便传递到api以调用它们的产品。我得到的是标签上的所有id 这是ui代码 CategoryDetails({Key key, this.categoryId, this.categoryName}) : super(key: key); final String categoryName; final int cate

您好,我是Flitter的新开发人员,正在使用WooCommerceAPI开发移动应用程序。我已将各个类别传递到选项卡中,但我需要获取它们的单个id,以便传递到api以调用它们的产品。我得到的是标签上的所有id

这是ui代码

  CategoryDetails({Key key, this.categoryId, this.categoryName})
      : super(key: key);

  final String categoryName;
  final int categoryId;

  @override
  _CategoryDetailsState createState() => _CategoryDetailsState();
}

class _CategoryDetailsState extends State<CategoryDetails> {
  APIService apiService;

  @override
  void initState() {
    apiService = APIService();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return _brandsList();
  }

  Widget _brandsList() {
    return FutureBuilder(
      future: apiService.getbrands(this.widget.categoryId),
      builder:
          (BuildContext context, AsyncSnapshot<List<ProductCategory>> model) {
        if (model.hasData) {
          return _brandsTab(model.data);
        }
        return Center(
          child: CircularProgressIndicator(),
        );
      },
    );
  }

  Widget _brandsTab(brands) {
    return DefaultTabController(
      length: brands.length,
      child: Scaffold(
          appBar: AppBar(
            elevation: 1,
            centerTitle: true,
            bottomOpacity: 1.0,
            backgroundColor: Colors.white,
            iconTheme: IconThemeData(color: Colors.black),
            automaticallyImplyLeading: true,
            title: Text(
              //'Franko Trading',
              this.widget.categoryName,
              style: TextStyle(color: Colors.black),
            ),
            actions: <Widget>[
              IconButton(
                  icon: Icon(Icons.search),
                  onPressed: () {},
                  color: Colors.black),
              IconButton(
                  icon: Icon(Icons.shopping_cart),
                  onPressed: () {},
                  color: Colors.black),
            ],
            bottom: TabBar(
              labelPadding: EdgeInsets.all(15),
              indicatorSize: TabBarIndicatorSize.label,
              isScrollable: true,
              labelColor: Colors.black87,
              indicator: UnderlineTabIndicator(),
              labelStyle: TextStyle(
                  fontSize: 19,
                  fontWeight: FontWeight.bold),
              unselectedLabelColor: Colors.black45,
              unselectedLabelStyle: TextStyle(
                  fontSize: 18,
                  fontWeight: FontWeight.normal),
              tabs: List<Widget>.generate(
                  brands.length, (index) => Text(brands[index].categoryName)),
            ),
          ),
          body: TabBarView(
              children: List.generate(brands.length, (index) {
            return ListView.builder(
              itemCount: brands.length,
              itemBuilder: (context, index) {
                return Center(child: Text(brands[index].categoryId.toString()));
              },
            );
          })
              //Center(child: Text("Settings Tab")),
              )),
    );
  }

}
CategoryDetails({Key Key,this.categoryId,this.categoryName})
:super(key:key);
最终字符串类别名称;
最终国际分类;
@凌驾
_CategoryDetailsState createState()=>\u CategoryDetailsState();
}
类_categorydailssState扩展状态{
蜜蜂服务;
@凌驾
void initState(){
apiService=apiService();
super.initState();
}
@凌驾
小部件构建(构建上下文){
返回_brandsList();
}
Widget_brandsList(){
回归未来建设者(
未来:apiService.getbrands(this.widget.categoryId),
建设者:
(BuildContext上下文,异步快照模型){
if(model.hasData){
返回_brandsTab(model.data);
}
返回中心(
子对象:CircularProgressIndicator(),
);
},
);
}
Widget_brandsTab(品牌){
返回DefaultTabController(
长度:品牌。长度,
孩子:脚手架(
appBar:appBar(
立面图:1,
标题:对,
底部不透明度:1.0,
背景颜色:Colors.white,
iconTheme:IconThemeData(颜色:Colors.black),
自动嵌入:正确,
标题:正文(
//“弗兰科贸易”,
this.widget.categoryName,
样式:TextStyle(颜色:Colors.black),
),
行动:[
图标按钮(
图标:图标(Icons.search),
按下:(){},
颜色:颜色。黑色),
图标按钮(
图标:图标(图标。购物车),
按下:(){},
颜色:颜色。黑色),
],
底部:选项卡栏(
标签填充:边缘集。全部(15),
indicatorSize:TabBarIndicatorSize.label,
isScrollable:是的,
labelColor:Colors.black87,
指示符:下划线Tabindicator(),
标签样式:文本样式(
尺码:19,
fontWeight:fontWeight.bold),
未选择的标签颜色:Colors.black 45,
未选择的标签样式:TextStyle(
尺码:18,
fontWeight:fontWeight.正常),
选项卡:List.generate(
brands.length,(index)=>Text(brands[index].categoryName)),
),
),
正文:选项卡视图(
子项:列表.生成(品牌.长度,(索引){
返回ListView.builder(
itemCount:brands.length,
itemBuilder:(上下文,索引){
返回中心(子项:Text(品牌[index].categoryId.toString());
},
);
})
//居中(子项:文本(“设置选项卡”),
)),
);
}
}

选项卡按您放置的顺序堆叠。因此,第一个选项卡的索引始终为0。您可以使用该索引交叉引用类别ID列表

List<String> catIDList = ['A','B','C'];

选项卡按您放置的顺序堆叠。因此,第一个选项卡的索引始终为0。您可以使用该索引交叉引用类别ID列表

List<String> catIDList = ['A','B','C'];

这是退货
退货中心(子项:Text(品牌[index].categoryId.toString())
但它会抓取所有选项卡的所有ID这是return
返回中心(子项:Text(brands[index].categoryId.toString())但是它抓取了所有标签的所有ID,你能告诉我调用品牌类别的url吗?我在后台使用WooCommerceAPI。因此,这取决于您的应用程序。要从woocommerce api ulr
apiurl/products/categories
获取类别,并获取子类别
apiurl/products/categories/parent=categoryID
先生,请告诉我调用品牌类别的url?我使用woocommerce api作为后端。因此,这取决于您的应用程序。从woocommerce api ulr
apiurl/products/categories
获取类别,并获取子类别
apiurl/products/categories/parent=categoryID