loading...
Cover image for A month of Flutter: create the app

A month of Flutter: create the app

abraham profile image Abraham Williams Originally published at bendyworks.com ・2 min read

Originally published on bendyworks.com.

The start of any Flutter project involves installing the Flutter SDK and choosing an editor. I'll be using the Linux flavor of the SDK and Android Studio with the Flutter and Dart plugins installed.

Follow the linked instructions to install the Flutter SDK and set up the Android Emulator or iOS Simulator.

Once you have the SDKs installed run flutter doctor to make sure everything is installed correctly. "Connected device" might fail if you don't currently have the emulator running.

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.11.11, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[✓] Android Studio (version 3.2)
[✓] Connected device (1 available)

• No issues found!

Now create the base app itself. flutter create <name> is a handy command to do this.

$ flutter create birb
Creating project birb...
  # truncated...
  birb/.metadata (created)
  birb/.gitignore (created)
  birb/README.md (created)
Running "flutter packages get" in birb...                    1.2s
Wrote 64 files.

All done!
[✓] Flutter is fully installed. (Channel beta, v0.11.11, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices is fully installed. (Android SDK 28.0.3)
[✓] Android Studio is fully installed. (version 3.2)
[✓] Connected device is fully installed. (1 available)

In order to run your application, type:

  $ cd birb
  $ flutter run

Your application code is in birb/lib/main.dart.

One change I'll make here is renaming the birb directory to app. In the future I plan on having the project as a monorepo and include Firebase Functions code in a sibling directory.

Make sure that flutter test passes.

$ flutter test
00:03 +1: All tests passed!

If you haven't already, set up a virtual device to run the app in. Alternatively you could connect a real device.

Android Studio Virtual Device Configuration

Run the generated app in the Android Emulator (or iOS Simulator) to make sure the app works. For this series I'll be using a Pixel 2 profile with the Play Store. The running app should look something like this:

Screenshot of sample app running in Android Emulator

Tomorrow I'll work on configuring continuous integration to make sure tests are always passing.

Code changes

Posted on by:

abraham profile

Abraham Williams

@abraham

• Conference speaker slides.today • He/him

Discussion

pic
Editor guide
 

Hey @abraham ,

I'm having trouble getting started with flutter. I run flutter create foo, no issue.

I then go into foo and run flutter run, which gets the error listed below.

I would appreciate your help if possible and whenever you can.

flutter run
Launching lib/main.dart on Nexus 5 in debug mode...
Initializing gradle...                                       1.0s
Resolving dependencies...
* Error running Gradle:
ProcessException: Process "/Users/stargator/Workspace/foo/android/gradlew" exited abnormally:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:3.2.1.
     Required by:
         project :
      > Could not resolve com.android.tools.build:gradle:3.2.1.
         > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
            > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
               > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
  Command: /Users/stargator/Workspace/foo/android/gradlew app:properties


Please review your Gradle project setup in the android/ folder.
 

What happens when you run flutter doctor?

 
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.13.1 17B48, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.0)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.2)
[✓] Android Studio (version 3.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2018.3)
[✓] Connected device (1 available)
 

By the way, running on an emulator seems to work fine from the command line.

I'll have to try again (now that I am at home and not on my work's network) and see if I can run it on my Android device.

Gave it a try, seems like it has to do with my work's network blocking the dependencies for gradle

Interesting. I'd recommend opening an issue with the Flutter team. That's something that flutter doctor should probably test for.

 

Thanks for the introduction. Do you have any experience comparing Android studio and VS Code for Flutter?

I am a game developer with little experience with non-games. I am considering starting Flutter for my future non-game projects (getting out of my comfort zone for the first time). I'm considering VS Code for its light-weight, convenience and familiarity to me. But I wonder if Android studio worths switching and learning a new tool?

Curious because I'm a C# game developer working on Visual Studio 2017. VS 2017 supports C# so nicely that I can't think of any other IDE workflow for C#. Is it similar for Flutter, or doesn't matter much?

 

I used Visual Studio Code with Flutter and It's works fine. I developed two apps, amazing.

 

Thank you. 2 apps is very promising.

 

I've been an Atom user for the last several years with only a little VS Code experience. I know a lot of Atom users switched to Code so I suspect they are fairly similar.

Android Studio feels a lot heavier to use then Atom. Almost all the keyboard shortcuts I'm used to are different so I find that difficult. I think that the integration with flutter and the Android Emulator are not as good for Code.

 

Thanks for the insight. I am pretty used to working on a plugged device from game dev, I'll probably keep going like that. Anyway, Android Studio looks huge and scary to me:)

It's got a lot of buttons and knobs but you can usually ignore most of it.

 

Really nice introduction my friend. Flutter is one of my target frameworks to master in 2019. If you guys don't know yet - there is a Google Event 4/12 - developers.google.com/events/flutt... - probably worth seeing as they might announce some great features.

 

Yep! I'm looking forward to it and will be at the local Google Developer Group viewing party.

 

Hey @abraham ,

My computer cant handle the stress over running Android Emulator that is prepackaged with Android Studio. After googling, i found this GenyMotion android emulator that is lightweight. Have you tried using this as an external emulator?

 

I have not. It looks interesting though so I've put it on my list of things to explore.

 

I think that Flutter is the future of Mobile apps.

  • It's easy to learn.
  • From scratch you have components ready to use with Material Design and Cupertino.
  • The concept of components like React or Angular (Flutter called Widget) is awesome.
  • Easy to change the state of a widget

Great work Google!

 

Yep, Flutter is pretty great so far. It's still pretty early stages to so I'm interested how it'll evolve.

 

At the top of this post there is some unintuitive UI to switch to the other posts in the series.

dev.to post series UI

You can also look at the bottom of canonical page and that will automatically update with a list of all posts.

 

Hey, just looking to learn Flutter soon. Thanks for this. Am so00 tempted to start a similar series besides you but will take 2 weeks to play with Dart first.

Your series will serve both as an inspiration and guide for my own series. Thanks.

 

I think a similar series on learning Dart over two weeks would be very interesting too.

Ya, I like the feature but that could use some user testing.

Hey, we'll take this all into consideration for updating the UI on our side. Thanks for bringing this up Ankush.