< Return to Video

#rC3 - Flutter - Introduction into performant cross-platform development

  • 0:00 - 0:18
    wikipaka intro music
  • 0:18 - 0:26
    Hello and welcome to this first talk.
    Today I'm going to give... into cross
  • 0:26 - 0:33
    platform development using Flutter. What
    is Flutter? Flutter is a cross platform
  • 0:33 - 0:48
    development kit. Here. Fancy logo you can
    see over there. OK, we will talk about how
  • 0:48 - 0:55
    to install Flutter. We will talk about the
    special features of Flutter, hence,
  • 0:55 - 1:02
    widgets, which will have a look on their
    plugins. We will have a look on two
  • 1:02 - 1:08
    different kinds of these widgets, stateful
    and stateless widgets. And at the end, we
  • 1:08 - 1:16
    will talk about the main feature,
    Flutter's part of the code, so you do not
  • 1:16 - 1:26
    have seperate style files or seperate
    layout files. OK, how would you install
  • 1:26 - 1:32
    Flutter? Well, if you are used to Git,
    it's actually quite easy. You simply clone
  • 1:32 - 1:40
    their git repository, update the path and
    you have the flutter tool installed. That
  • 1:40 - 1:48
    installs two things: The library Flutter
    and the programming language Dart, Dart the
  • 1:48 - 1:54
    programing language you use with Flutter.
    Of course you could use Dart without
  • 1:54 - 2:00
    Flutter, but Dart is usually used with
    Flutter and Flutter only works with Dart.
  • 2:03 - 2:10
    OK. Well, if you are not interested in
    cloning git repositories, if you are not
  • 2:10 - 2:18
    that used to command prompts, you could
    easily install Flutter using the plugin of
  • 2:19 - 2:25
    your development environment. For example,
    Visual Studio Code or Android studio so
  • 2:25 - 2:32
    intellij, they offer very user friendly
    plugins with a quick installation guide
  • 2:32 - 2:41
    for Flutter, automating all these
    steps. OK, what is Flutter like? If we
  • 2:41 - 2:45
    have a look on Flutter, we talk about
    different things. We have the framework
  • 2:45 - 2:52
    within Dart, we have the engine and we
    have platform specific code. Flutter
  • 2:52 - 2:57
    consists of something called the "Flutter
    tool". That's not listed in the graphic
  • 2:57 - 3:03
    you can see there. That's what you use to
    create an application. For example, if you
  • 3:03 - 3:10
    type "flutter create mynewapplication" in
    the command prompt, that's the Flutter
  • 3:10 - 3:18
    tool you use. But as soon as you've done an
    application, you have this... it works the
  • 3:18 - 3:24
    way the graphic presents it: You have this
    framework consisting of everything you can
  • 3:24 - 3:33
    see and everything you can do. You have
    buttons, for example "Material" buttons,
  • 3:33 - 3:36
    these are the two main theme styles, so
  • 3:36 - 3:45
    "Material" is the Android and Chrome OS
    one and "Cupertino" is the iOS-style user
  • 3:45 - 3:53
    interface. The framework takes also care
    of the rendering animations, interactions
  • 3:53 - 3:58
    with users. So gestures, if you tap a
    button or if you move around something on
  • 3:58 - 4:09
    the UI, that's something the framework
    takes care of. And under the framework,
  • 4:09 - 4:17
    there's the engine. The engine operates
    everything which is not specific to your
  • 4:17 - 4:24
    application, so the general stuff of
    Flutter. It takes care of the interaction
  • 4:24 - 4:29
    with the Dart virtual machine. It takes
    care of platform channels. For example, if
  • 4:29 - 4:38
    you want to access native code, takes care
    of accessibility, it interacts with the
  • 4:38 - 4:47
    operating system and so on. And beside of
    those two, there's still the embedder. The
  • 4:47 - 4:55
    embedder is, what is, yeah, typic for one
    kind of device, for example, or for one
  • 4:55 - 5:02
    platform, for example, for Android. The
    embedder takes care of threads of process
  • 5:02 - 5:08
    management, takes care of the event loop
    of the operating system, and it takes care
  • 5:08 - 5:16
    of interaction with native plugins. And
    most importantly, it's responsible for
  • 5:16 - 5:20
    packing the application. For example, if
    you have raw Dart code, no device would be
  • 5:20 - 5:28
    able to execute it. So the embedder is
    responsible for hacking this code into an
  • 5:31 - 5:41
    executable on Windows, into a JavaScript
    file on the Web or into an APK file on
  • 5:41 - 5:52
    Android. OK, well, now I already
    introduced these widgets, I talked about
  • 5:52 - 6:00
    Material and Cupertino widgets, but what
    is a widget? Yeah, a widget is pretty much
  • 6:00 - 6:08
    everything you can see in a flutter app. A
    widget is any user interface element,
  • 6:09 - 6:13
    sometimes allowing interaction, sometimes
    not. But everything you can see in an
  • 6:13 - 6:22
    application is called widget. You can
    imagine a widget like, for example, HTML
  • 6:22 - 6:31
    elements. You simply put them into each
    other and create a document tree. But
  • 6:31 - 6:40
    unlike if you use HTML, you do not have
    HTML for the layout, CSS for the style and
  • 6:40 - 6:46
    JavaScript for the interaction. If you
    have Flutter, these widgets provide all
  • 6:46 - 6:57
    these three parts. So the widget performs
    the layout, the widget offers style and
  • 6:57 - 7:03
    offers interaction with the user. Hence you
    do not have any separation between style
  • 7:03 - 7:11
    and content of the application. That's a
    very good feature for development and
  • 7:11 - 7:20
    makes many things such as refactoring
    code. But there are different types of
  • 7:20 - 7:26
    Stateless widgets without any kind of
    feedback they can provide. They are once
  • 7:26 - 7:32
    rendered and afterwards they are present.
    Or if the parenting widget decides, well,
  • 7:32 - 7:38
    I no longer want to show this, for
    example, text, that is just being removed
  • 7:38 - 7:44
    without any interaction of this widget.
    Another point are stateful widgets, they
  • 7:44 - 7:54
    allow interaction. So for example, if you
    have a text as a stateful widget, it can
  • 7:56 - 8:02
    tell - it is able to tell the application
    after a couple of seconds: OK, now I want
  • 8:02 - 8:10
    to change my own color or I want to change
    my font size, so it has an own event loop
  • 8:10 - 8:18
    and can decide based on things happening
    inside this widget. That's usually a bit,
  • 8:18 - 8:25
    yeah... not these low level widgets like
    text, but all these high level widgets
  • 8:25 - 8:35
    like list views consisting of several
    children and so on, menus, they consist of
  • 8:35 - 8:41
    a menu button and drop down menu and
    whatever, or even the whole page of an
  • 8:41 - 8:49
    application. All these are widgets,
    stateful widgets. OK, time to provide some
  • 8:49 - 8:56
    code samples. That was a bit of
    introduction into the architecture. Let's
  • 8:56 - 9:04
    have a look on code. Well,
    congratulations. That's a simple Flutter
  • 9:04 - 9:10
    program. If you write it and you provide a
    declaration of homepage, you should be
  • 9:10 - 9:16
    able to run an application on your mobile
    phone. Yeah. What does it? It executes the
  • 9:16 - 9:23
    main function, calling a method call,
    calling a function called runApp, which
  • 9:23 - 9:29
    runs a Material app. So following the
    Material design you know from Android or
  • 9:29 - 9:40
    Chrome OS. OK, but of course, we need to
    implement homepage. Well, let's have a
  • 9:40 - 9:50
    look at a bit more difficult widget.
  • 9:50 - 10:27
    silence
  • 10:27 - 10:33
    ...tell the widget everything it needs to
    know for building, in our case, we simply
  • 10:33 - 10:41
    return a list type, consisting of an icon
    and an outline button. The outline button
  • 10:41 - 10:49
    can do anything. It can share a text. So you
    would see your share prompt on your mobile
  • 10:49 - 10:57
    phone or on the web it would download the
    text. OK. But why is it stateless and not
  • 10:57 - 11:06
    stateful? Simply because it cannot
    interact with itself, the widget is unable
  • 11:06 - 11:14
    to change one of its variables, the widget
    cannot set a timer, it simply could not...
  • 11:14 - 11:20
    if you would tell the widget, well, wait
    five seconds and do whatever, it would not
  • 11:20 - 11:27
    change the appearance of the widget,
    because it is once built and afterwards,
  • 11:27 - 11:35
    it has no more... it no longer has the
    ability to change its appearance or
  • 11:35 - 11:41
    behavior. Only the parenting widget - so,
    for example, the list we put this
  • 11:41 - 11:47
    scoredetail inside - it could trigger a
    rebuild of this widget, but not the widget
  • 11:47 - 11:59
    itself. To clarify this point, we'll have
    a look at a stateful widget. It is a bit
  • 11:59 - 12:03
    shorter, because the stateful widget
    consists of two classes, state class,
  • 12:03 - 12:10
    that's what you can see over there. And,
    well, the actual declaration that it is a
  • 12:10 - 12:19
    widget. But the state is much more
    interesting if we look at it. OK, you
  • 12:19 - 12:26
    first see there are... we first
    initialized some variables. Afterwards, we
  • 12:26 - 12:30
    have a method called initState. That's
    something which is being triggered the
  • 12:30 - 12:37
    first time the widget is built, afterwards
    we declare another method. And at
  • 12:37 - 12:45
    the end we have our build-method. Yeah,
    what does or what's the difference from
  • 12:45 - 12:52
    this build-method to the build-method we
    had in our stateless widget... I hope you
  • 12:52 - 12:59
    can see my pointer, yeah. We have here, we
    have an if statement here, a short if
  • 12:59 - 13:06
    statement. So the build method checks
    whether a variable called testLoaded -
  • 13:06 - 13:16
    that's being declared at the top here -
    whether it is false or true. And it
  • 13:16 - 13:24
    correspondingly reacts. So if it's true,
    a list view is being displayed and
  • 13:24 - 13:33
    otherwhise a progressindicator is being
    shown. OK, but well, that's something we
  • 13:33 - 13:39
    could still implement in a stateless
    widget, but there's another big difference
  • 13:39 - 13:45
    here. We have something which changes
    something as soon as something happens.
  • 13:45 - 13:52
    Well make some things. It's an expansion
    tile, so a list tile which can be
  • 13:52 - 13:59
    expanded. It's a builtin widget of
    Flutter. And as soon as it is being
  • 13:59 - 14:05
    opened, it's... a local method is
    triggered: Here we have this loadScore
  • 14:05 - 14:13
    method and that is being triggered. We do
    not know what it does, but I can tell you,
  • 14:13 - 14:20
    it will load some data from wheresoever
    and it will change this variable. So
  • 14:20 - 14:28
    afterwards, after this method is being
    triggered, the test data here will be
  • 14:28 - 14:33
    something different. It will no longer show
    the progress, but it will show this inside
  • 14:33 - 14:39
    a single widget without any communication,
    without any external stuff, without any
  • 14:39 - 14:47
    JavaScript, getElementById or something
    like that. The widget simply decides on
  • 14:47 - 14:58
    its own behavior. That's very comfortable,
    believe me. OK, now we already talked a
  • 14:58 - 15:05
    bit on JavaScript, it's somehow different.
    Well, Flutter is often being compared to
  • 15:05 - 15:13
    JavaScript using React native and
    Electron. So what's the difference?
  • 15:13 - 15:16
    Well, let's first look on
  • 15:16 - 15:24
    JavaScript. You write an application in
    JavaScript, you actually have JavaScript
  • 15:24 - 15:30
    and JavaScript is a Web language. Hence,
    you need a web view or something similar
  • 15:30 - 15:40
    to render anything of your app. That means
    it consumes an immense amount of memory
  • 15:40 - 15:46
    and CPU power because, well, if you ever
    used chromium or Firefox on the low-end
  • 15:46 - 15:54
    device, you know that JavaScript can be,
    well, quite painful. Well, there are
  • 15:54 - 16:00
    highend mobile devices. But if you develop
    an app, you should always keep in mind
  • 16:00 - 16:06
    that there are mobile devices with much
    less power and less than two gigabyte of
  • 16:06 - 16:17
    RAM. OK. And if you have Flutter in
    opposite, you create a native app and you
  • 16:17 - 16:24
    have native code which is being executed
    beside the Dart virtual machine with
  • 16:24 - 16:30
    almost the same look and feel, you know,
    from your platform. If you have JavaScript
  • 16:30 - 16:36
    and opposite, you usually have a fancy
    design you made, which is actually good
  • 16:36 - 16:41
    for web development. But it's usually not
    exactly the design packed from a mobile
  • 16:41 - 16:46
    device. There are very strict guidelines.
    If you ask Apple or if you ever published
  • 16:46 - 16:52
    an app to the App Store, you know, there
    are very strict guidelines at Apple. And
  • 16:52 - 16:58
    at Google there are guidelines as well,
    but they're not that strict. But if you
  • 16:58 - 17:04
    use Flutter, you automatically obey
    these guidelines and produce apps with a
  • 17:04 - 17:12
    native look and feel. And another
    advantage of Flutter, it's more an
  • 17:12 - 17:19
    advantage in comparison to native native
    apps, you have the same data and the same
  • 17:19 - 17:28
    code on the same on all your platforms.
    Yeah, because if you write native
  • 17:28 - 17:30
    applications, well, you have two code
    bases and the applications behaves
  • 17:30 - 17:35
    differently on all platforms. And if you
    have Flutter, you have one code base for
  • 17:35 - 17:39
    all your platforms and obviously it
    behaves the same way on all platforms.
  • 17:39 - 17:48
    That's much easier for your users if she
    should ever change their device. Yeah, and
  • 17:48 - 17:54
    the major point I already mentioned at the
    first point, there is almost no loss of
  • 17:54 - 18:04
    performance. Yeah. So Flutter is actually
    a very good framework for creating apps for
  • 18:04 - 18:12
    Android, IOS, desktops such as Windows,
    Mac OS or Linux, Free BSD is unfortunately
  • 18:12 - 18:23
    not supported - or even webpages. OK.
    Yeah. And at that point, I want to thank
  • 18:23 - 18:31
    you for your the attention of this talk.
    Feel free to attend my next talk on
  • 18:31 - 18:36
    Flutter. Tomorrow I will give an advanced
    view on cross-platform development using
  • 18:36 - 18:43
    Flutter. We will focus on animations and
    the way Flutter works under the hood. Now
  • 18:43 - 18:54
    there should be an online Q&A. Thank you
    for your attention!
  • 19:00 - 19:05
    Herald: Hello, this was the lecture by the
    one with the braid about Flutter and we
  • 19:05 - 19:11
    are now switching to a small Q&A session
    here. There has been exactly one question
  • 19:11 - 19:19
    in the IRC. You can ask questions by the
    hashtag rC3Wikipaka and in the rC3Wikipaka
  • 19:19 - 19:24
    IRC channel on hackint. There's been one
    question, which is: What is the main
  • 19:24 - 19:30
    feature of Flutter, which lets me decide
    for it instead of, for example, react
  • 19:30 - 19:35
    native? Could you answer that question?
  • 19:35 - 20:01
    (incomprehensible)
  • 20:01 - 20:06
    Herald: The one with the braid, we've got
    problems with your sound. We can't receive
  • 20:06 - 20:15
    you via ninja, only via our backchannel.
  • 20:15 - 20:25
    (incomprehensible)
  • 20:25 - 20:28
    Herald: And now they're gone.
  • 20:28 - 20:28
    The one with the braid: Can you hear me
    again?
  • 20:28 - 20:29
    Herald: Here we are again.
  • 20:29 - 20:33
    Herald: Yeah, we can hear you now.
    The one with the braid: OK, perfect.
  • 20:33 - 20:38
    Well, the question was, what could
    convince someone to use Flutter? I would
  • 20:38 - 20:44
    say the main advantage, the principal
    advantage of Flutter is the performance
  • 20:44 - 20:51
    and the native-like applications you get.
    If you use Flutter, you get native design
  • 20:51 - 20:57
    of the operating system you run on and you
    have no lack of performance. That's the
  • 20:57 - 21:05
    main difference to JavaScript, for
    example. So you act native.
  • 21:05 - 21:09
    Herald: Would you consider yourself to be
    a flutter fan or aficionado?
  • 21:09 - 21:13
    The one with the braid: Oh, yeah, I'm a
    huge fan of Flutter.
  • 21:13 - 21:18
    Herald: OK, we can tell that. You do have
    other talks about Flutter in the coming
  • 21:18 - 21:21
    days, don't you?
    The one with the braid: Yes, tomorrow at
  • 21:22 - 21:29
    12 o'clock, there is a second talk on
    Flutter - advanced cross-platform
  • 21:29 - 21:36
    development using Flutter. We will focus
    on Animations and on the way the engine,
  • 21:36 - 21:43
    so the underlying engine of Flutter works.
    Herald: Alright, there's been another
  • 21:43 - 21:48
    question in the meantime here, again by
    hanswurst10. React native also gives you
  • 21:48 - 21:50
    native components and design, etc. Isn't
    that true?
  • 21:50 - 21:55
    The one with the braid: Yeah, it's true.
    But well, I would call the Flutter
  • 21:55 - 22:02
    components more native. They are built 100
    percent according to the style-guidelines
  • 22:02 - 22:09
    of the operating systems. If you use
    Material patterns, they are 100 percent
  • 22:10 - 22:17
    Material. So as you know them from your
    Android phone, for example. And I noticed
  • 22:17 - 22:23
    in react native, you sometimes have
    issues... not issues, but some components
  • 22:23 - 22:31
    do not properly look exactly the way they
    should look, and they often do not look
  • 22:31 - 22:38
    the way the users expect them to look.
    Herald: Alright, thanks for the answers to
  • 22:38 - 22:43
    the questions, there have been some more
    detailed questions as a follow up on the
  • 22:43 - 22:50
    IRC, but I've posted in the IRC a link
    where you can all join into for a little
  • 22:50 - 22:54
    BigBlueButton session, where you can go
    into more detail exchange. The one with
  • 22:54 - 22:58
    the braid, thank you so much for your
    input. This has been the first broadcast
  • 22:58 - 23:04
    of the day and of RC3, and we will
    continue to follow up with a little break
  • 23:04 - 23:09
    and continue our program at Sixteen
    Hundred Central European Time. Thank you.
  • 23:09 - 23:14
    The one with the braid: OK, see you.
    Herald: Bye bye.
  • 23:14 - 23:18
    wikipaka outro music
  • 23:18 - 23:24
    Subtitles created by c3subtitles.de
    in the year 2021. Join, and help us!
Title:
#rC3 - Flutter - Introduction into performant cross-platform development
Description:

more » « less
Video Language:
English
Duration:
23:24

English subtitles

Revisions