0
  Widget build(BuildContext context) {
    return ListView.builder(
        scrollDirection: Axis.horizontal,
        shrinkWrap: false,
        physics: const BouncingScrollPhysics(),
        itemBuilder: (context, int i) {
          return Center(
            child: Card(
              child: GestureDetector(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  mainAxisAlignment: MainAxisAlignment.start,
                  mainAxisSize: MainAxisSize.min,
                  children: const [
                    SizedBox(
                      height: 15,
                      width: 100,
                      child: ClipRRect(
                          //borderRadius: BorderRadius.only(topRight: 10,topLeft: 10),
                          child: Text("admistraction")),
                    ),
                    Divider(
                      thickness: 2,
                      color: Colors.lightBlue,
                    ),
                    Padding(
                        padding: EdgeInsets.only(left: 15.0, right: 5),
                        child: Text(
                          "Start Learning",
                        )),
                  ],
                ),
              ),
            ),
          );
        },
        itemCount: 5);
  }

Divider horizontal line is not visible in list view. I tried to wrap a divider in row or column I also wrap it in Container but its not working its working fine with vertical but in horizontal its not visisbale

4 Answers 4

1

Wrap your divider with SizedBox and give height and width

          SizedBox(
                  height: 15,
                  width: 100,
                  child: Divider(
                    thickness: 2,
                    color: Colors.lightBlue,
                  ),
                ),

enter image description here

Sign up to request clarification or add additional context in comments.

4 Comments

not working in horizontal list view
Please add your current and expected output image
It's working, I have added output image, please check
is not working in listview.builder
0

Try to Add Height to Divider it will work. Just adding a small sample for reference.

The usage will be:

HorizontalOrLine(height: 10,label: "OR")

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class HorizontalOrLine extends StatelessWidget {
  const HorizontalOrLine({
    this.label,
    this.height,
  });

  final String label;
  final double height;

  @override
  Widget build(BuildContext context) {

    return Row(children: <Widget>[
      Expanded(
        child: new Container(
            margin: const EdgeInsets.only(left: 10.0, right: 15.0),
            child: Divider(
              color: Colors.black,
              height: height,
            )),
      ),

      Text(label),

      Expanded(
        child: new Container(
            margin: const EdgeInsets.only(left: 15.0, right: 10.0),
            child: Divider(
              color: Colors.black,
              height: height,
            )),
      ),
    ]);
  }
}

Comments

0

If you are using Column then you should wrap with IntrinsicHeight and for Row required IntrinsicWidth to show divider.

In your case you are using Column you should use IntrinsicHeight.

Try this code:

                IntrinsicHeight( <---------------- just add this widget
                child:Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  mainAxisAlignment: MainAxisAlignment.start,
                  mainAxisSize: MainAxisSize.min,
                  children: const [
                    SizedBox(
                      height: 15,
                      width: 100,
                      child: ClipRRect(
                          //borderRadius: BorderRadius.only(topRight: 10,topLeft: 10),
                          child: Text("admistraction")),
                    ),
                    SizedBox(
                     height: 50,
                     width:50
                    child: Divider(
                      thickness: 2,
                      color: Colors.lightBlue,
                    )),
                    Padding(
                        padding: EdgeInsets.only(left: 15.0, right: 5),
                        child: Text(
                          "Start Learning",
                        )),
                  ],
                )),

3 Comments

Still not working .
Add sizedBox to abover DIvider. see I have edited changes in answer.
after wrapping with sizedBox it create space but divider line is not visible
0
    SizedBox(
            width: 100,
            child: Divider(
            thickness: 2,
            color: Colors.lightBlue,
            ),
          ),

Try adding width to your divider like this

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.