Maybe you're now bored with the Counter app.

Photo by Artur Shamsutdinov on Unsplash

Maybe you're now bored with the Counter app.

Flutter code samples.

Ngonidzashe Mangudya's photo
Ngonidzashe Mangudya
ยทMar 13, 2023ยท

2 min read

Table of contents

  • Let's get cooking

You undoubtedly already know that reading through code can teach you a lot, and perhaps, like me, you had to read through the code for the default counter starter app in order to understand how the framework functions (just the basics of it).

You basically get the same starter app produced for you each time you run flutter create โ€”org co.modestnerd my_cool_app, but perhaps you want a different one so you can learn by reading, is that right (yeah I knew we are very much alike)?

You needn't worry, though, because Flutter has you covered and they go above and beyond to make sure you may build alternative starter apps based on your preferences.

Let's get cooking

The are multiple samples provided that you can use to have your app ready when you run flutter create and what you would just need to do is specify the sample you want - easy right?

You should thus pull those samples so you can choose among the ones specified because, like me, you might not be familiar with any of the offered samples.

Pulling samples

flutter create --list-samples=samples.json

Running the above command should do the trick (easy-peasy) and this will save the available samples list in a JSON file (samples.json) and you can just pick from the list. The contents in the JSON may look like this:

        "id": "cupertino.CupertinoActivityIndicator.1",
        "element": "CupertinoActivityIndicator",
        "sourcePath": "lib/src/cupertino/activity_indicator.dart",
        "sourceLine": 33,
        "channel": "stable",
        "serial": "1",
        "package": "flutter",
        "library": "cupertino",
        "copyright": null,
        "description": "This example shows how [CupertinoActivityIndicator] can be customized.",
        "file": "cupertino.CupertinoActivityIndicator.1.dart"

Creating your sample app

What you need to create an app using the sample ones provided is the id e.g. from the one in the above list we can take cupertino.CupertinoActivityIndicator.1.

flutter create --sample=cupertino.CupertinoActivityIndicator.1 my_cool_app

This will create the Flutter application with the name my_cool_app but this time around you're sure not to get the default counter app.

Well hopefully you may find this to be useful - just like I did โœŒ๐Ÿฟ.

Did you find this article valuable?

Support Ngonidzashe Mangudya by becoming a sponsor. Any amount is appreciated!

Learn more about Hashnode Sponsors
Share this