Facing conflicts while using Column widget in Row.
Hi, I am implementing below mentioned design in flutter but something went wrong mentioned in below image.
I don’t want to use any external package for learning purpose. Thanks for your help in advance.
Expectations:-
Expected
Reality:-
Messed up layout
below are the code snippet, which I am using now.
upload_screen.dart
import 'package:flutter/material.dart';
class StepProgressBar extends StatelessWidget {
const StepProgressBar({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const Row(
// mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
StepWithPlaceHolder(label: "1", title: "Choose File"),
Expanded(child: Divider(thickness: 7,height: 5,)),
StepWithPlaceHolder(label: "2", title: "Finish")
]);
}
}
class StepWithPlaceHolder extends StatelessWidget {
final String label;
final String title;
const StepWithPlaceHolder(
{Key? key, required this.label, required this.title})
: super(key: key);
@override
Widget build(BuildContext context) {
return Column(
children: [
Container(
width: 55,
height: 55,
decoration: BoxDecoration(
border: Border.all(width: 2, style: BorderStyle.none),
shape: BoxShape.circle,
color: Colors.red,
),
child: Center(
child: Text(
label,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 22,
color: Colors.white),
),
),
),
Text(
title,
style: const TextStyle(
fontWeight: FontWeight.w800,
fontSize: 20,
color: Colors.black,
),
),
],
);
}
}
}
2
Answers
Wrap your
Row
widget withSizedBox
with the needed height.OUTPUT:
Note: Or wrap With a
Container
instead ofSizedBox
if you want to add some margin around it.I have tried to make it dynamic so you will just need to change list in order to manage your views and here is code
Code is not much optimized but you can refer it