Flutter Live Recap: #AskFlutter Questions and Answers Part-2

In the previous article, I started to write the questions and answers at #AskFlutter section at Flutter Live. As the title states, we will continue writing them.

Can we design and develop apps for E-commerce businesses with Flutter?

The answer is, people are already doing it. Alibaba is using Flutter for their application. There is also a sample shopping application here. The material team built Shrine to show how you can implement material design within Flutter and then Flutter team took over the application and added some extra behavior with state management and scoped model.

Is there a way to embed native view UI? For example, can I put Apple pay in an application and have Flutter button to invoke Apple pay?

Sure. Google maps plugin that you saw in the event is under the hood using something called platform view. In platform view, there is an Android view and a UI kit view. These are the widgets manage the native UI and fit it into Flutter. Those are all available, you can go and try them out but, it has a cost because of the operations under the hood, therefore it’s suggested to not use a lot of them in one screen.

Is there any CI/CD options for Flutter applications?

Yes. Nevercode has a CI/CD system for Flutter applications called Codemagic. For Flutter samples and open source projects, the team uses Travis (It’s free and works great with Flutter). Also, the engineering team uses Cirrus, because they have advance testing and it fits their needs. Flutter tools run on Linux and command-line so it fits well into CI/CD systems.

How about Dart on the server side?

Dart is a general-purpose programming language. The team is focusing on mobile applications right now but, there are a lot of people (including Google) using Dart on the server side and as it goes broader, you will be seeing it on even more platforms.

What are the new widgets that are about to come out in the next Flutter update?

The easiest way to find this out is to go through GitHub. If you go to the main Flutter repository, you can take a look at the open issues and features. But there is also projects tab which the team uses. So you can see there what the team is working in real time. Also, if you don’t see the thing you want to see there, it is most likely that there is an issue for it, you can go ahead put a thumb on to it and comment your use case. If there isn’t an issue, you can create it.

What is the best way to achieve state management in a Flutter application (we are using scoped model but it feels like, it is not the right fit)?

For state management, there is no certain answer. It depends on the application, it depends on the team and their previous experiences. Scoped model is a good start. For many people, it gives what they need. It is easy to understand, it is less reactive than some would want for more reactive solutions people are using reactive extensions (RxDart), Redux.

It also depends on what they are missing as a feature. For example, the scoped model doesn’t work well with streams. It rebuilds the widgets in its own way rather than providing streams as BLoC would. You can still use it, but it will be a dirty solution to listen to streams and notify the listeners.

Do you think that in the future there might be different ways to manage states that we even don’t know?

Yes. During the research, it can be seen that there is always something new about state management. Some need some more work but since Flutter is still young and because of that there will be always new ways to handle states. In the end, state management is building your application. You can start by using State and Stateful widgets (which is not recommended but it can be useful especially if you have one widget to be handled) to more complex solutions. Coming to Flutter and reactive programming is a change in mindset. E.g. recreating the whole UI in Android is a big deal but, in Flutter it can be done once in a while.

When will the timeline application source code be available?

It will be available hopefully soon. It requires some changes to be nicer.

How does Flutter compare to React Native?

It’s not correct to compare them. They both are really good solutions and React Native did an amazing job bringing a web technology to mobile development. The team believes in Flutter but it is just another way to develop applications, there is no negative answer to this question, it’s just two positive approaches.

A column with unfixed height and 100+ list tiles is a problem, do you have any suggestions?

We don’t want to build any widgets that are not visible on the screen, that way we don’t waste any CPUs by building any widgets, painting them while they are not on the screen. To prevent this performance issue you can use ListView.Builder. This will get item number and build the element when it’s on the screen. It’s not recycling any widgets, it rebuilds the element when it is needed because Dart’s GC is working really efficient on that.

Can we build games with Flutter and how the performance will be?

You can’t build 3D games because Flutter doesn’t expose 3D graphics yet. You can do 2D games. One of the earliest Flutter demos was a 2D space shooting game. It’s not supported with a dedicated framework for it in Flutter. But, there are some frameworks in the community to do exactly that.

Performance is efficient because Flutter designed to render pixels on the screen and games do that as UI do that. It doesn’t make any big difference in the engine perspective.

How Flutter games work is not so much different than how Unity games work. All the pixels are driven by Flutter and update the part of the 2D scene when it changes.

When would you build a Flutter application vs a mobile-friendly website? What is harder in HTML, CSS, and Javascript that would be easier in Flutter? Why would you prefer one to the other?

It depends on who your target audience is. If you are a big company, you might want to do both. You have to have a scenario for people who didn’t download your application also, you have to have a mobile application for your users who would like to have a native mobile application experience. With Hummingbird, it’s aimed to find a solution to this scenario.

In the future are we going to have Android or Apple watch support?

It is not planned, but it is doable. Right now the main focus is on mobile and desktop is also a focus. Earlier there was a circular demo to prove that Flutter is not limited to cartesian coordinates. If the clock face is round, it can be used to develop that.

We all know that Flutter came from Chrome, How did the original team use their knowledge to develop Flutter and which features are inherited from Chrome?

From the code perspective, the team started from the Blink. After forking Blink until this day, a lot of things has changed (scripting engine, text layout etc.) there is only Skia (Graphics Engine) is left. It helped with preventing to make the same mistakes made before and used as an experience. The team also consists of a lot of people from different teams like Android to learn also from their experiences.

What feedback which is coming from the developers does the engineering team most value?

All feedback is great. You can file a bug and when you file a bug, the most useful things are to have reproducible test cases, having a piece code that can be downloaded and run on the machine is useful to track the problem.

Is there any chance of having Kotlin on Flutter?

If you are willing to give up from “Hot Reload” there is. That feature comes with Dart and it’s hard to get it with other languages. You can use platform channels to run your Kotlin code though. There is an article, explaining why Flutter uses Dart and it’s advantages.

Is Flutter going to replace Android?

No, it’s not going to replace Android. They are different things, Android is an operating system and Flutter is a software development kit. None of the people thinks that Flutter development will replace Android development because there are some things in Android which will be hard to do with cross-platform tools.

Background tasks in Flutter

A Flutter application built for Android is an Android application and the same goes for iOS. You can add a lot of platform-specific code and use platform channels to talk back and forth. There is an article about geofencing and schedule tasks according to the response from GPS events.

What are the tools that I can use to optimize my Flutter application (There is an that is developed took more space than expected)?

On Flutter website there is some documentation for performance and best practices. There are UI tools to show you why are you missing frame or why your UI is not performant. There is also memory tools to help people to have more sensitive memory usage (e.g. is it a leak or is it using a lot of resources). All of them are developed by the Flutter team to help you out with the performance. Some of them are available in the IntelliJ and Android Studio and some of them will come soon.

For performance, you can go to Flutter Performance tab. It’s active whenever an application is running. It can show you your frame rate while you interact with the application (performance overlay), also you can see the outline of your widgets with toggles. You can also see which widget is rebuilt with your interaction or build.

Can you give some information about Flutter observatory?

It is a web-based application to show you about your application’s performance. In Flutter concept biggest usage is their timeline view. Which gives you detailed information about events that your application going through. What frames are created, which methods are running. In particular, it can help you identify slow frames and the reason for it.

Which is better VSCode or IntelliJ/Android Studio?

It really is up to you. Best IDE is the one that you know and feel comfortable using. Even within team, there are differences, some people like IntelliJ some uses VSCode. Some features come to IntelliJ earlier, but it becomes part of VSCode really soon too. So at the end again, it is totally up to you.

How do you pronounce Fuchsia?

Fuchsia ( /ˈfjuːʃə/ or ˈfyo͞oSHə according to Google Translate) :)

Are there future plans on supporting mapping to native accessibility identifiers which are required by Appium?

In Flutter from the early times, the team had meetings to learn and talk about native accessibility tools and how to take advantage of them. There is an accessibility semantic tree in Flutter.

Is it possible to give negative margins? (Someone answered use Positioned in chat)

Positioned is like a stack used with rows. You are stacking up children one top of another. With Positioned, you can put the child to a position on the screen and make sure it looks like you expected.

What is the impact of Flutter on application size?

On Android, it’s over 4mb. Before it was 6mb and it is still a work in progress, they observe it through the CI process and check the chain in each build to see if they can do better.

Can you talk about AI and ML in Flutter?

There was a demo from the Flutter team on Flutter Live and DevRel team is working on to create an example for these scenarios. But if you would like to have something with TFLite, your way to go is to use platform channels. If you don’t see a plugin about something that can be useful to the others too, you can implement it and publish it.

Is there going to be something like CodePush from Microsoft?

CodePush is an open source technology from Microsoft to push a live code to an application that is already released. With react-native you can push live code through JSVM. In Flutter, during debug, you have VM and JIT but when you build for the release you are building a ARM binary static lib. So you are not using JIT at that point. It’s not supported yet, but it’s on people’s head.

Honorary Mention

During the Q&A section, there were also some guests from the community, talking about their experiences.

First one was Poojã Bhaumik and she talked about her journey to become a Flutter developer. Every word she said was super important, therefore I decided to put her article here about her experiences and if you want to go deeper in Flutter, she is definitely one of the people that you need to follow.

The second person was Simon Lightfoot. He talked about Flutter Community, Medium, Slack and GitHub and how do we use to maintain packages.

The last person was Hillel Coren. He talked about https://itsallwidgets.com/ and It’s all widgets podcast which can be found on the website.

I want to thank all of these people and all the community who makes this platform amazing. Without positive vibes, it’s always hard to be motivated but with these people, you learn and grow every day.

Keep fluttering and see you all soon!