Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,290 --> 00:00:08,100
There is an important value built into Dart which we hadn't had a look at yet.
2
00:00:08,200 --> 00:00:14,310
We had a look at string values between the quotes, at integers, doubles and so on
3
00:00:14,320 --> 00:00:18,350
but what we hadn't had a look at yet is the null value.
4
00:00:18,350 --> 00:00:26,920
Null simply is a value built into Dart which you can use if you might generally expect another type of
5
00:00:26,920 --> 00:00:27,500
value,
6
00:00:27,520 --> 00:00:31,840
let's say you have a username and that is Max
7
00:00:31,840 --> 00:00:38,410
but then something in your application happens and you want to reset that to an uninitialized state
8
00:00:38,430 --> 00:00:42,490
so to say and in such cases, you can set this to null.
9
00:00:42,490 --> 00:00:48,040
This does not violate the rule or the inference of username being a string,
10
00:00:48,040 --> 00:00:54,970
so just to prove this, if I would assign a number here, then actually here I would get an error because
11
00:00:54,970 --> 00:00:58,540
a number is of course not a string, an integer is not a string.
12
00:00:58,630 --> 00:01:03,070
Null is assignable here even though it's of course not wrapped between quotes,
13
00:01:03,070 --> 00:01:05,540
null can basically be assigned to any type,
14
00:01:05,560 --> 00:01:11,560
so no matter if you normally expect a string, integer, double, whatever it is, null can always be assigned
15
00:01:11,560 --> 00:01:18,130
and you often assign it to reset a variable, to reset the value in a variable, to indicate that you have no
16
00:01:18,130 --> 00:01:20,900
value yet, anything like that.
17
00:01:20,920 --> 00:01:24,400
You can also use it in boolean comparisons.
18
00:01:24,520 --> 00:01:30,600
So if you have an if check and you want to find out if username is set, you could check if username
19
00:01:30,820 --> 00:01:38,140
is not equal to null for example. That would be something where you would also use null because right
20
00:01:38,170 --> 00:01:44,650
now if I don't assign a value, this would for example be null, the default uninitialized state is that
21
00:01:44,650 --> 00:01:45,330
this is null
22
00:01:45,550 --> 00:01:47,740
so then such a check here could be useful.
23
00:01:48,250 --> 00:01:54,130
So using null to reset values or in checks to make sure that you have a value and you're not in an uninitialized
24
00:01:54,200 --> 00:02:00,520
state can be very important and Dart will use it throughout this course and therefore null is a value you should
25
00:02:00,520 --> 00:02:01,090
be aware of.
2724
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.