带Bloc Builder的抽屉内的动态扩展磁贴项目

时间:2019-05-03 09:19:11

标签: flutter flutter-layout bloc

我想在抽屉中创建一个动态Expansiontile,其中Expansion子项将来自blocbuilder,但我不知道我尝试了很多方法,但似乎不起作用。 我尝试的代码:

ExpansionTile(
           title: Text("Normal Odds"),
           initiallyExpanded: false,
           children: <Widget>[
             BlocBuilder(
               bloc: _drawtypeBloc,
               builder: (BuildContext context, DrawtypeState state) {
                 if (state is Loading) {
                   print("Loading");
                   return ListTile(
                     title: Text("data"),
                   );
                 }
                 if (state is Loaded) {
                   return ListView.builder(
                     itemCount: state.types.norm.length,
                     itemBuilder: (BuildContext context, int index) {
                       return ListTile(
                         title: Text(state.types.norm[index]),

                       );
                     },
                   );
                 }
               },
             ),
           ]),

我也尝试过这种方法:https://stackoverflow.com/a/54879823/4702878

这是我想要的静态示例:

 ExpansionTile(
            title: Text("Low Odds"),
            children: <Widget>[
              ListTile(
                title: Text("ELITE 3"),
                leading: Icon(Icons.arrow_right),
              ),
              ListTile(
                leading: Icon(Icons.arrow_right),
                title: Text("DOUBLE 1"),
              ),
              ListTile(
                title: Text("DOUBLE OR NOTHING"),
                leading: Icon(Icons.arrow_right),
              )
            ],
          ),

0 个答案:

没有答案