I like Google flutter

Source: Internet
Author: User



On Google I/O ' 17, atrial flutter  Google introduced us to flutter--a new open source library for creating mobile apps.



As you can imagine, flutter is able to help create a cross-platform mobile application solution with a beautiful UI interface. Flutter's interface design is similar to a Web application,heart flutter value so you can find a sense of familiarity like using html/css from flutter.



Google says:


flutter will help you to develop an aesthetically pleasing mobile app more quickly and easily.


Sounds good, but the first thing to say is, what do I do with other cross-platform solutions,  such as? Xamarin,phonegap,ionic, react Native and so on is not very recognized. As we all know, these solutions have pros and cons and are hard to choose. Although I'm not sure if flutter will be different from them, flutter kicks I'm looking forward to it.





Why do you use flutter?


You may be curious and then ask yourself a question:a flutter


What is the innovation of flutter? How does it work? What's the difference between Native and React?


I'm not going to discuss technical issues here because others are doing better. If you are interested in the details of flutter's work, I suggest you read this article: What is the revolutionary innovation of flutter? You can also review the summary of the flutter concept in the "the Magic of Flutter" demo.



Briefly, Flutter is a mobile SDK that allows us to create a hybrid mobile app (so you can write a code that can run this app on both Android and IOS). You write code in Dart, which is a language developed by Google, from file and if you've used Java before, it will feel very familiar. You no longer need to build the layout tree with an XML file, but like this:


 import  ' Package:flutter/material.dart '; class helloflutter extends statelesswidget  {   @override   widget build (buildcontext context)  {     return new materialapp (      title:  "Helloflutter",       home: new scaffold (         Appbar: new appbar (          title: new  Text ("Helloflutter"),        ),         body: new container (          child:  new raisedbutton (onpressed: _handleonpressed),         ) (,      ),    );   }} 


As you can see, the layout is built from nested components (widgets). The core part is Materialapp(This is the entire application), then we have Scaffold (which is the main layout structure), and then inside we have AppBar (like Android toolbar) and some containers as the main body. Internally,  we'll place the layout widgets-text, buttons, and so on.





#1 Thermal Overload


OK, let's get started!



We start with a basic application. We have three buttons, each of which can change the color of the text:






Now we're going to use one of the coolest features--hot reload. It allows your Web page to be rebuilt immediately. Look at the effect:






Review what we have done specifically? We changed some of the code (the text on the button) when we clicked on "Hot Reload" (at the top of the IntelliJ IDE) and we were able to see the results in a short period of time. Isn't it cool?



Hot reload is not just fast but smart--if you have some data already displayed (for example, the text color in this example), you can change the UI using hot reload while the app is running: The content is still the same.





#2 Full set of Widgets (Material Design)


Another advantage of flutter is that we have a very rich catalog of built-in UI components. There are two sets of widgets inside ——? Material Design (for Android) and Cupertino (for IOS). You can choose and easily implement everything you want. For example, if you want to create a new floating action button, you can do the following:






Even better, you can implement any widget on each platform. And if you've implemented some Material Design or Cupertino widgets, it's the same on every Android and IOS device. You don't have to worry about what will look different on many devices.





#3 everything is a widget.


As you can see in the previous GIF, creating a UI is simple. This is thanks to Flutter's core principle-everything is a widget. Your App class is a widget (Materialapp) and your overall layout structure is also a widget (Scaffold), everything is a widget (AppBar, Drawer, SnackBar). Want to center the view? It's good to use Center (cmd/ctrl+enter)!






With Fluter, creating a UI is as easy as composing a layout with many different widgets.



Flutter also has another core principle, combining precedence over inheritance. This means that if you want to create some new widgets (widgets), you can use several widgets to make up the new widget instead of extending the existing widget class.






#4 Android/ios the theme of differentiation



In general, we want our Android app to be different from the IOS app, not only in color, but also in the size and style of widgets. In flutter, you can use themes to achieve this goal:






As you can see, we have set different colors and heights for the toolbar (AppBar). We are using the Theme.of (Context). Platform parameter to fit the current platform (Android/ios):


import  ' Package:flutter/material.dart '; class helloflutter extends statelesswidget {    @override   widget build (buildcontext context)  {     Return new materialapp (        title:  "Helloflutter",         theme: new themedata (             primaryColor:                 theme.of (context) .platform == targetplatform.ios                      ? Colors.grey[100]                     : colors.blue),         Home: new scaffolD (          appbar: new appbar (             elevation:                 theme.of (context) .platform ==  targetplatform.ios                     ? 0.0                     : 4.0,             title: new text (                "Helloflutter",             ),          ),           body: new  Center (Child: new text ("hello flutter!")),        ));   }}




#5 very, very, very many resources


Although flutter is still in the alpha version, the Flutter development community is very large and highly participatory. Because of this flutter there is a lot of support for resources (class library form, like the Gradle dependency pack in Android). We have a wide variety of class libraries such as open source graphics, HTTP requests, content sharing, storage parameters, access sensors, deployment Firebase, and more. Of course, each resource pack supports Android and IOS. Flutter Library List-flutter Awesome





How to get started?


If you like flutter and want to try it yourself, the best way is to open Google Codelabs:


    • In this site, you'll learn the basics of creating layouts: building beautiful UIs with flutter

    • If you want to try something more, you can try Flutter's Firebase


I like Google flutter


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.