Here we will see dart ternary operator along with flutter usage. Dart ternary operator looks like below
?:
Now this may look like confusing. There are two parts of it. The first part is ? and the other part is : and they are used separately.
Next thing we need to know that, we use dart ternary operator used for else if statement replacement. First let’s take a look at this
Here we will see that the second print statement will get print. And we know the above code is very simple.
Now we can replace this else if statement using ternary operator(?:). Let’s see how we dot.
See the position of the ternary operator.