Modern App Development with Dart and Flutter 2
eBook - ePub

Modern App Development with Dart and Flutter 2

A Comprehensive Introduction to Flutter

  1. 249 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Modern App Development with Dart and Flutter 2

A Comprehensive Introduction to Flutter

About this book

The book introduces the programming language Dart, the language used for Flutter programming. It then explains the basics of app programming with Flutter in version 2. Using practical examples such as a games app, a chat app and a drawing app, important aspects such as the handling of media files or the connection of cloud services are explained. The programming of mobile as well as desktop applications is discussed.

New important features of Dart 2.12 and Flutter 2 are described:

- Null safety

- Desktop Applications

Targeted readers are people with some background in programming, such as students or developers.

The sample projects from the book are available for download on the following GitHub repository: https://github.com/meillermedia
Over time, more branches may be added. However, the default branches are those that correspond to the state in the book.

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Modern App Development with Dart and Flutter 2 by Dieter Meiller in PDF and/or ePUB format, as well as other popular books in Computer Science & Information Management. We have over one million books available in our catalogue for you to explore.

1 Introduction

This book deals with a specific innovative technology for the efficient development of apps for mobile devices. Consequently, it is possible to realize native apps crossplatform in only one programming language. Various practical examples introduce a new technology called ā€œFlutter.ā€ The main part of this book is the description of a more complex app, a 2D game called ā€œChicken Maze.ā€ The goal of the game is to navigate a chicken through several levels, where it earns points and fights enemies.
When Steve Jobs presented the iPhone at the beginning of 2007, it was a turning point in the digital world. He also demonstrated a new type of software that can be run on the new device, the so-called apps, which is an abbreviation for ā€œApplications.ā€ The abbreviation was probably intended to suggest that these are smaller programs. The first apps were smaller gadgets, for example, the beer-drinker app: You could put the phone to your mouth and tilt it, a beer level that could be seen on the display slowly decreased, and in the end, you heard a burping sound. The amazing thing was that the beer level always remained horizontal, as the program could determine the angle of the device using a built-in sensor. The app is available from the App Store, Apple’s cloud-based software sales platform, revolutionary for its time and exclusive to Apple’s mobile devices.
People stood in line at Apple stores to buy an iPhone and expected new apps. Developers also started rushing for the new device; it was a kind of new gold rush. In 2008 the first competing mobile phone with an Android operating system was launched. The operating system was mainly developed by Google. Google gave the manufacturers of mobile devices a ready-made system software. A store, the Google Play-Store, was also integrated there. For a short time, there were other competing systems such as Windows Mobile or webOS, but these were unable to establish themselves and eventually disappeared. What remained are iOS and Android, so today’s development tools concentrate exclusively on these two. The gold rush is long gone, and meanwhile, you have to do a lot of work as a developer to have commercial success by developing apps.

1.1 Cross-Platform Development

Apps are often developed twice and individually ported to the respective platform. Native Apps1for the iOS environment, i.e., for Apple mobile devices, are programmed using the programming languages Objective-C or Swift and Apple’s frameworks. Android apps, on the other hand, are usually based on the Java platform with the programming languages Java or Kotlin. If you want to work with the in-house technology of competing companies, you have to laboriously translate the code into the other languages by hand. The need for a cross-platform solution, therefore soon came up and various technologies were developed. Basically, we can distinguish between two approaches: On the one hand, there are frameworks that work with web technologies. However, this should not be confused with web apps. These are merely web pages that adapt as well as possible to the mobile device. For app development, there is the procedure of embedding web pages into the app and presenting them via a browser component that fills the entire screen. Your own code is programmed in JavaScript. Via an API, you can talk to native components, which can then address the specific hardware of the device. This approach has two disadvantages: You can only use features that are available on both platforms. Furthermore, the performance is limited because, in the end, you are dealing with a browser application. The advantage is that web developers can also attempt app programming. Well-known frameworks of this kind are React Native from Facebook and Apache Cordova (formerly PhoneGap from Adobe).
The other approach is the following: You program with platform-unspecific languages and frameworks, which are then cross-compiled into the desired environment and therefore have a better performance. A well-known representative of this technology is Xamarin from Microsoft. There, programming is done with C#. The Flutter framework with the programming language Dart also belongs to this category.

1.2 Motivation

The hype about Flutter started in 2018 when it became known that Google was working on a new operating system called Fuchsia, and there was the rumor that this new operating system should replace Android. Meanwhile, Google denied this and announced that the new operating system would be used on new types of devices in the future. Fuchsia is open source and freely available, it can be tested and installed [35]. Flutter is used for the user interface programming. The book does not discuss Fuchsia itself, but you can use the knowledge taught in the book to develop applications for Fuchsia. The graphical user interface is displayed with a render engine called Skia, which is used in Flutter. The framework was in the alpha and beta phase after the first release and allowed the programming of native apps for iOS and Android systems. In addition, Google recommended that you should better realize your apps with Flutter, as it realizes the Google material design. The interest in Flutter was then awakened in the author, who was planning a course for media computer scientists on app programming at that time.

1.3 Target Group

This book targets app developers who are interested in developing new cross-platform apps. These can be professional programmers or students of courses in computer science or media-related studies.
All such persons should have some basic knowledge of programming. The book does not provide a basic introduction to programming. It does not discuss the meaning of variables, loops and control structures. Although the syntax of these structures in the Dart language is also explained, the meaning of the constructs should be clear. The reader should also have some knowledge of object-oriented programming. Ideally, readers should also have already dealt with program libraries and the command line. Knowledge of Java, C#, JavaScript or C++ as first the programming language would be ideal.

1.4 Structure and Aim of the Book

The book points out the pitfalls that you inevitably run into when you take on the adventure of learning a new programming language and a new framework. The book is divided into two parts: a fundamental section and a practical section. The first part explains the most important constructs of the Dart language. This is followed by an introduction to app programming with Flutter. Simple examples are shown there. In the second section, which is the practical part, more sophisticated examples follow, starting with a messenger app that demonstrates how the app connects to the cloud. A more complex application follows, a 2D game called ā€œChicken Maze,ā€ where a chicken is the game character. The game is not too complex, but is more than a demo app. It contains features that professional applications need. The code of the examples is explained in detail and specific programming techniques of Flutter and Dart are described.

Notes

1
These are apps programmed and optimized specifically for a platform

Part I: Foundations

2 Foundations of Dart

Dieter Meiller
In the following, the language Dart is briefly introduced and a complete introduction to the programming language given. However, the basics of programming are not taught here. Basic skills in imperative and object-oriented programming are expected. The chapter tries to teach special features of the language in comparison to other languages and basics, which are important to understand how to use the Flutter-Framework. It deals with Dart in version 2.12
The extended Backus Naur Form (BNF), a meta syntax, is used to explain parts of the syntax. However, this does not provide a completely correct description of the Dart language, as it would be necessary for compilers or standards. Some non-terminals are also not further resolved. It should be clear what is meant by <condition> (a boolean expression), for example.

2.1 The Dart Language

Dart is a programming language developed by Google. In addition to Dart, Google developed many other programming languages, including Groovy. This language is compatible with Java and generates code for the Java Virtual Machine. The language Go was released at the same time as Dart. Go is a hardware-oriented language that can be used for system development, similar to C and C++. Go is supposed to be a modern version of these languages and compiles faster.
Dart, in contrast, was designed as a language for application development. Originally, Dart was developed as a language for the web browser Chrome. The reputation of Dart was controversial in the developer community due to its direct competition with JavaScript and ran contrary to efforts to standardize and interoperate web browsers. It was feared that there would be a new browser war like the one in the 2000s when Microsoft introduced Visual Basic as the browser language in competition with JavaScript, the Netscape language of the time. Therefore, the acceptance of the Dart language was rather low, and it became quiet around Dart.
In early 2018 Google announced a new framework for the development of apps, namely Flutter (see chapter 4). The development in Flutter should be done exclusively in Dart. At the start of Flutter, Dart was also modernized and is now available in version 2. In the process of this development, Dart changed from an extension of Ja...

Table of contents

  1. Title Page
  2. Copyright
  3. Contents
  4. Thanks
  5. Preface
  6. 1 Introduction
  7. Part I: Foundations
  8. Part II: Practice
  9. List of Figures
  10. Index