{"id":334,"date":"2018-07-09T15:54:34","date_gmt":"2018-07-09T13:54:34","guid":{"rendered":"https:\/\/billigeplaetze.com\/?p=334"},"modified":"2024-08-14T13:36:31","modified_gmt":"2024-08-14T11:36:31","slug":"my-date-with-dart-and-flutter","status":"publish","type":"post","link":"https:\/\/craftcoders.app\/my-date-with-dart-and-flutter\/","title":{"rendered":"My date with Dart and Flutter"},"content":{"rendered":"

Motivation<\/h2>\n

…Hey, guys! It’s time for another blog post from me. This time I want to write about my experiences with Flutter and Dart. Every software developer is regularly confronted with new concepts, frameworks or languages, so am I. I learned to program with Android 2.0. Yes, I’m getting old… Meanwhile, I am not so active in the Android world anymore. But since we code Android apps on hackathons every now and then, I don’t get out of practice. Nevertheless, I am a little spoiled by the development of UWP apps. Also, the time on hackathons is very limited, which is why one does not like to deal with boilerplate code. Let’s be honest… Android (Java) is full of it! Therefore, alternatives are needed. Okay, so it would be obvious to try Xamarin now, but where would be the fun? I have no plans this weekend and Google seems to have created a real alternative with Flutter and Dart! Sounds like a hot date ? I’ve never worked with Dart or Flutter before, but at some point, you have to start. So this post will be about my experiences and not a tutorial.<\/p>\n

So what are the advantages of Flutter?<\/h3>\n

Google promises not only that you can develop apps very fast, but also that they run on iOS like Android. In addition, Dart and Flutter are focused on developing reactive apps. I’ve never written apps in a reactive manner before, but at least the theoretical foundations were covered at our university. *Yes, Dannymausi I’m talking about the hipster teacher \ud83d\ude09 *<\/p>\n

And what do I want to program?<\/h3>\n

I’ve been thinking for a long time what I can achieve in less than two days (hitting the gym and watching Netflix is still important!). I don’t know the language or the framework…. But yolo , after all, Google promises that you are significantly<\/strong> faster in developing. So here’s the idea: We’ve finished the first rotation of our blog posts. We came up with the idea that once every member of us has written a blog post we select the best and the winner gets a little something. Basically, this means we have to make a voting every 5 to 6 weeks. There is one catch: Since Danny is from Russia we have to very be very cautious about our voting system. We had so many different voting systems… I can’t even count them! We even voted about how to vote… Time to time we vote with two or three voting shares. Sometimes we have several voting rounds. Since we always discuss and try to optimize our voting systems, it’s time for an App. The app should allow you to vote for one of the five possible authors (including yourself). After you have voted, the application navigates to a second page where you can see the election results. You can not vote again. However, a new election can be started, this must be propagated to all clients.<\/p>\n

Getting Started<\/h2>\n

So now I have two days to try out a new language and a new framework….. What the hell am I doing to myself ?? So that it won’t be too unpleasant, I decided to chill on YouTube first. Fortunately, the Google IO 18 wasn’t so long ago and there are interesting talks about Flutter. Here are the ones I looked at:<\/p>\n

    \n
  1. Build reactive mobile apps with Flutter<\/a><\/li>\n
  2. Total mobile development made fun with Flutter and Firebase <\/a><\/li>\n<\/ol>\n

    So what should you take out of these videos? On the one hand Flutter is about widgets – everything is a widget. A screen is a widget tree. One distinguishes between Stateless and Statefull widgets. But we will use the BLOC pattern from “Build reactive mobile apps with Flutter” for our app.
    \nOn the other hand, Firebase seems to offer itself perfectly as a backend. As this blog post is not a tutorial, I recommend to watch the videos. Our task is to create a Firebase database. And to create a client according to the BLOC pattern.<\/p>\n

    Implementation<\/h2>\n

    The Backend alias Firebase<\/h3>\n

    So this is the easy Part. Since I have already written such a long motivation, how about a gif?<\/p>\n

    \"\"

    How to create the Backend \ud83d\ude09<\/p><\/div>\n

    The Voting Screen<\/h3>\n

    To keep the code manageable I decided to write all widgets in the main.dart file. In a real project you would surely divide them into different files but for experimenting, I think it’s better to keep everything at one place. Since time is limited, I thought we’d keep the layout simple. Here is my design:<\/p>\n

    \"\"<\/p>\n

    Lets Check:<\/p>\n