Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,300 --> 00:00:08,480
We spent a lot of time on our text inputs, on these transactions and for the moment, I'm quite happy with
2
00:00:08,480 --> 00:00:09,850
the result.
3
00:00:10,160 --> 00:00:14,480
Now as a next step, I want to make sure that this text input area
4
00:00:14,570 --> 00:00:20,660
here however is not always visible but instead as we also planned it at the beginning of the section,
5
00:00:21,080 --> 00:00:27,200
it is shown when we press a button, a button that's added here in our action bar and a button here at
6
00:00:27,200 --> 00:00:27,780
the bottom,
7
00:00:27,800 --> 00:00:30,010
a so-called floating action button.
8
00:00:30,430 --> 00:00:32,490
And for that, we first of all need these buttons,
9
00:00:32,510 --> 00:00:37,270
so let's learn how to add buttons in the app bar or buttons on the overall page
10
00:00:37,270 --> 00:00:46,330
with the help of that floating action button feature. Let's start with the app bar. Here in main.dart,
11
00:00:46,780 --> 00:00:50,670
which is where I do render that app bar, on the app bar,
12
00:00:50,830 --> 00:00:55,570
you can add an actions argument and that takes a list of widgets.
13
00:00:55,600 --> 00:01:00,770
Now theoretically of course, you can add any widget in here, text or whatever you want.
14
00:01:00,820 --> 00:01:07,030
Typically however, you add buttons here though or most typically, you add icon buttons.
15
00:01:07,150 --> 00:01:08,550
We haven't used that before,
16
00:01:08,560 --> 00:01:15,480
we worked with a RaisedButton and we worked with the FlatButton but there also is an IconButton
17
00:01:15,850 --> 00:01:21,890
and the IconButton does what the names suggests, it renders a button that only holds an icon.
18
00:01:22,030 --> 00:01:27,050
For that, we need to set the icon argument here and the icon argument takes,
19
00:01:27,160 --> 00:01:28,260
let's have a look,
20
00:01:28,270 --> 00:01:36,100
it takes a widget but actually it wants an icon widget. Icon is another widget built into Flutter, so icon is
21
00:01:36,100 --> 00:01:41,040
coming from Flutter and it gives us a widget that in the end renders an icon
22
00:01:41,200 --> 00:01:43,060
and it takes one positional argument,
23
00:01:43,120 --> 00:01:44,530
the icon data,
24
00:01:44,530 --> 00:01:48,180
so basically some information on which icon to show
25
00:01:48,220 --> 00:01:52,880
and there we can use icons which is a class provided by Flutter
26
00:01:52,960 --> 00:01:57,440
that gives us access to all the typical material icons.
27
00:01:57,460 --> 00:02:02,030
So here, you can go through that list and conveniently here, you see a preview of the icon
28
00:02:02,050 --> 00:02:04,340
that's getting rendered
29
00:02:04,340 --> 00:02:08,200
and here I'll use the add icon which is simply a plus.
30
00:02:08,230 --> 00:02:12,940
Now on that icon here, you could also configure other things, like the color of the icon or the size
31
00:02:13,000 --> 00:02:16,330
but I'm happy with the default and on the IconButton,
32
00:02:16,330 --> 00:02:17,860
you can also configure other things,
33
00:02:17,860 --> 00:02:22,730
most importantly you need to provide onPressed, just as you do it on other buttons as well.
34
00:02:22,900 --> 00:02:27,490
For the moment I'll set it to an empty anonymous function so that the button isn't disabled but at the
35
00:02:27,490 --> 00:02:31,020
moment of course, it also won't do anything useful. Here
36
00:02:31,120 --> 00:02:36,180
now we see that button and you can of course remove the debug banner here with the help of the Dart
37
00:02:36,180 --> 00:02:36,960
dev tools
38
00:02:37,030 --> 00:02:42,760
as you learned it in the debugging section if it's annoying to you. I hope you can see the button here though,
39
00:02:42,940 --> 00:02:49,720
this is the button which when we press it should bring up a little modal, a bottom sheet here sliding
40
00:02:49,720 --> 00:02:54,750
in from the bottom which holds this text input area. And it's not just this button,
41
00:02:54,760 --> 00:03:00,550
I also want to have that floating action button. We add this also with the help of the scaffold, there
42
00:03:00,580 --> 00:03:03,110
besides app bar and body,
43
00:03:03,340 --> 00:03:04,510
you can also add
44
00:03:08,790 --> 00:03:15,700
the floating action button argument. By the way, you don't have to add that below the body,
45
00:03:15,700 --> 00:03:21,820
it doesn't matter in which order you provide these named arguments. Floating action button wants a widget
46
00:03:21,850 --> 00:03:22,960
as a child
47
00:03:23,050 --> 00:03:30,490
and typically that is a floating action button which is a button optimized to be used as a floating
48
00:03:30,490 --> 00:03:31,480
action button.
49
00:03:31,570 --> 00:03:32,910
You could use any button though
50
00:03:32,920 --> 00:03:35,180
but I will go with the floating action button
51
00:03:35,380 --> 00:03:42,030
and here I will also provide my icon, an icon widget by using icons add.
52
00:03:42,300 --> 00:03:46,750
So the icon widget here is a normal widget and therefore can be used as a child in the floating action
53
00:03:46,750 --> 00:03:47,370
button
54
00:03:47,560 --> 00:03:52,010
and then here, onPressed. For the moment, I'll not do anything.
55
00:03:52,100 --> 00:03:53,460
If we now go back,
56
00:03:53,690 --> 00:03:57,350
we have that floating action button here in the bottom right corner.
57
00:03:57,380 --> 00:04:02,060
You can also change the position of that floating action button here with another argument you pass to
58
00:04:02,060 --> 00:04:03,110
scaffold,
59
00:04:03,140 --> 00:04:09,800
you can add the floating action button location argument and set this to floating action button location.
60
00:04:09,830 --> 00:04:17,120
and then you have a couple of options like center float for example, if you save this, it now floats
61
00:04:17,270 --> 00:04:20,020
in the bottom center which is really nice.
62
00:04:20,030 --> 00:04:21,560
So now we have this button here as well,
63
00:04:21,560 --> 00:04:23,120
we have the button up here,
64
00:04:23,120 --> 00:04:28,340
let's next make sure that when we press these buttons, they bring up that sheet which in the end
65
00:04:28,340 --> 00:04:30,680
can hold that user input area here.
6623
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.