Conditional statements for widgets can be used in different ways as per requirement.
eg.
Center(
child: condition ? Widget1(): Widget2()
)
eg.
Column(
children: [
if (condition)...[
// Your widget1 here
] else if (condition)...[
// Your widget2 here
] else...[
// Your widget3 here
],
],
),
eg.
Container(
child: LayoutBuilder(builder: (context, constraints) {
if (condition) {
return Text("Y is greater than or equal to 10");
} else {
return Text("Y is less than 10");
}
})
)
Work with our skilled Flutter developers to accelerate your project and boost its performance.
Hire Flutter Developers