BestCharlemagne
BestCharlemagne

Reputation: 101

Make a Column force Container to be same size as other widgets Flutter

A DartPad example is here: https://dartpad.dev/cf6ab1d34f5b1022aa48ea8ced193de5.

I am trying to make a fraction display, but I cannot get the container that is the fraction bar to not expand to the entire screen. This is the code I have right now:

Center(
   child: Column(
       children: <Widget>[
          Text("100"),
          Container(
              height: 2,
              color: Colors.black,
          ),
          Text("300"),
       ],
    ),
 )

Upvotes: 1

Views: 1160

Answers (1)

Pavel
Pavel

Reputation: 5876

Use IntrinsicWidth:

IntrinsicWidth(
  child: Column(
    children: [
      Text("100"),
      Container(
        height: 2,
        color: Colors.black,
      ),
      Text("300"),
    ],
  ),
)

Upvotes: 3

Related Questions