Linked Questions
14 questions linked to/from How to use conditional statement within child attribute of a Flutter Widget (Center Widget)
0 votes
1 answer
714 views
Is there a way to display a widget conditionally [duplicate]
I am trying to make a Music Playing App. And in that app i want to implement search feature. This requires me to show list of 5 answers related to query only if the user is trying to search, else do ...
4 votes
3 answers
25k views
How to use conditional statements/ternary inside a flutter widget
I need to know is it possible to use ternary/if else inside flutter widgets. I'm trying to create a buttonCreator widget which will take few parameters, one of which will be the background. I need ...
2 votes
5 answers
13k views
if statement inside widget in flutter
How do I create a loop or if-statement inside a widget in flutter? It seems that you only can make a single line condition like: if(condition) but if you try to use brackets: if(condition){ } it ...
5 votes
2 answers
5k views
Flutter: how to pass arguments to a Widget using a variable?
Here's some pseudo code showing what I'm trying to achieve: Text txt(text, [subtitle = false]) { final params = subtitle ? { 'textAlign': TextAlign.center, 'style': ...
1 vote
2 answers
6k views
How can use if statement with Container widget in flutter
I want to use if statement with container widget like this code : if (int.parse(m_id) > int.parse(cm_id) || int.parse(d_id) > 4) { Container( width: 0.23 * size, ...
1 vote
2 answers
2k views
Flutter: How to write if-else statement to call drawer?
I am trying to make a drawer in the class DetailedPage only when the previous class was CameraPage. To achieve this, I create a variable String previousScreen = 'CAMERA' and passed the variable to the ...
1 vote
3 answers
2k views
How to show a container for 3 seconds
I have a container in which there are 2 fields. 1 is a percentage and the other is simple Text. What I need is I don't want to show the percentage container and when I click on the container it will ...
1 vote
4 answers
758 views
Can't I write braces in an if statement in List?
The following without braces worked fine: import 'package:flutter/material.dart'; void main() { runApp(const _MyApp()); } class _MyApp extends StatelessWidget { const _MyApp({super.key}); @...
0 votes
2 answers
2k views
Set the icon for switch button in Flutter [closed]
I wanted to set the "done" icon for switch when it is on, and "close" icon when it is off. Here is a sample image: I am looking for same toggle switch as shown in the image, in ...
0 votes
1 answer
700 views
Using conditional to select different set of widgets in Flutter
I am following Angela Yu's introductory course on Flutter and extending the Quizzler project for personal challenge. At the end of a quiz, I give the user a chance to start again (show the first ...
-2 votes
1 answer
459 views
is it possible to create the same screen for both user and admin but for admin with extra functions like CRUD in flutter?
I'm having hard time creating logic for this. I jave a flutter app in which i want to show same screen for both admin and user but for admin i want to add CRUD facilities. How can i achieve this in ...
0 votes
1 answer
334 views
if condition to run Widget at Container flutter
if condition when post.text == 1 i setup Widget named exteranews Widget exteranews(BuildContext context) { double siz11 = 15.0 * MediaQuery.of(context).size.width / 414.0; } how to use ...
0 votes
1 answer
393 views
How to use conditional statement within child attribute for Expanded Widget, Flutter
I want the Expanded widget to change dependent on 'Button 1', 'Button 2' or "Button 3' is pressed. The buttons is just text wrapped in a InkWell, I can change this, but it is only for purpose of ...
0 votes
2 answers
136 views
Is it safe to have a Widget class that returns a widget conditionally?
Quite often I only want to draw a Widget based on a condition. For example, I may be creating a component that displays a FadeIn.image but the image: may not be set in the CMS. In this case I want to ...