Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,130 --> 00:00:06,670
Now let's start with the ternary expression and therefore here, you first of all have your condition.
2
00:00:07,260 --> 00:00:10,780
The condition here could be without the if keyword,
3
00:00:10,780 --> 00:00:13,060
that's how you'll write a ternary expression.
4
00:00:13,060 --> 00:00:15,610
So the condition here can be the same condition as up there,
5
00:00:18,950 --> 00:00:26,170
is the question index smaller than the question length? If this is the case, then you add a question mark,
6
00:00:26,210 --> 00:00:30,690
this will then mark the border to the code which should run if this is true.
7
00:00:30,710 --> 00:00:33,340
So the thing after the question mark is used
8
00:00:33,350 --> 00:00:39,590
if this condition is true and then you need to add a colon after the code block that should be used
9
00:00:39,590 --> 00:00:40,530
if this is true
10
00:00:40,730 --> 00:00:46,790
and this part after the question mark must only be one expression, here since it's a lot of lines, it
11
00:00:46,790 --> 00:00:50,490
looks like it's more than one expression but in the end, it's only the column here,
12
00:00:50,540 --> 00:00:50,970
right?
13
00:00:50,990 --> 00:00:54,530
It's only the column, all the other stuff is in the column.
14
00:00:54,650 --> 00:00:56,300
So only the column here is created
15
00:00:56,330 --> 00:01:00,040
if that is true and therefore after the column down there, we add a colon
16
00:01:00,110 --> 00:01:03,300
and now we have the so-called else block.
17
00:01:03,320 --> 00:01:06,310
We didn't have an else block up there but we could add it here as well,
18
00:01:06,320 --> 00:01:14,180
you can add else here and then you can define code that should run if the condition is not met,
19
00:01:14,180 --> 00:01:21,690
so if this here, if this returns false, then you will go into the else block. By the way in if statements
20
00:01:21,690 --> 00:01:22,580
like this here,
21
00:01:22,650 --> 00:01:28,380
you can also have else if statements where you could add other conditions which are checked if the first
22
00:01:28,380 --> 00:01:34,790
condition is not met but let's ignore that for now. For the ternary expression here down in our body,
23
00:01:35,250 --> 00:01:38,430
we don't have else if but we do have our main code,
24
00:01:38,430 --> 00:01:41,900
if the condition is met and then after the colon, we have our else block
25
00:01:41,970 --> 00:01:48,750
and now that could be a center widget which is another widget baked into Flutter that centers all
26
00:01:48,750 --> 00:01:51,990
the content horizontally and vertically on the page.
27
00:01:52,140 --> 00:01:55,290
It takes a child and that is then the widget which should be centered
28
00:01:55,350 --> 00:02:02,010
and this could simply be some text like you did it and let's add a trailing comma here, reformat everything
29
00:02:02,010 --> 00:02:08,470
and now we have a ternary expression. If we now reload this application and we go back,
30
00:02:08,680 --> 00:02:13,720
now I can select my answers but after the third button click, we don't get the error but we get
31
00:02:13,780 --> 00:02:14,500
you did it
32
00:02:14,500 --> 00:02:18,280
and that's of course way nicer and already a better user experience.
3430
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.