Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to insert Listview.Builder in Listview.Builder item

Parent Code


how to insert my listviewBuilder in listViewBuilder item
this is my parent code

 Expanded(
            child: Container(
              padding: EdgeInsets.only(top: 10.0),
              decoration: Ui.getBoxDecoration(),
              child: ListView.separated(
                itemBuilder: (context, index) {
                  var _comment =
                      controller.commentWithDetailDtoList.elementAt(index);
                  return TimelineCommentItemWidget(comment: _comment);
                },
                separatorBuilder: (context, index) => SizedBox(height: 10.0),
                itemCount: controller.commentWithDetailDtoList.length,
              ),
            ),
          )

Child Code


and this is my child code

 Visibility(
      child: ListView.separated(
        itemBuilder: (context, index) {
          var reply = comment.replies.elementAt(index);
          return TimelineCommentRepliesItemWidget(comment: reply);
        },
        separatorBuilder: (context, index) => SizedBox(height: 10.0),
        itemCount: comment.replies.length,
      ),
    ),

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Here is the code.

Please check this out.

import 'package:flutter/material.dart';

const Color darkBlue = Color.fromARGB(255, 18, 32, 47);

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.dark().copyWith(
        scaffoldBackgroundColor: darkBlue,
      ),
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Center(
          child: MyWidget(),
        ),
      ),
    );
  }
}

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ListView.separated(itemBuilder : (BuildContext context , int i) {
         return   _innerWidget();
                
    } , itemCount : 2 , shrinkWrap: true,separatorBuilder: (context, index) => SizedBox(height: 10.0), );
  }
}

Widget  _innerWidget(){
  return  ListView.builder(itemBuilder : (BuildContext context , int i) {
  
        return Text('hello');
 
    }, itemCount: 2,shrinkWrap: true, physics: NeverScrollableScrollPhysics(),);
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading