Menu
Theme
Bachelor of Science in Computer Science
Course Content

Android/Flutter

Mobile Application Development

Module 3: Android vs. Flutter - Choosing Your Mobile Dev Superpower!

Habari class! Welcome back to Mobile Application Development. Look around you. On the bus, in a cafe, even at the family gathering—smartphones are everywhere in Kenya. And what makes these phones powerful? Apps! From M-PESA managing our money to Glovo bringing us food, apps run our modern lives. Today, we're going to answer a big question for any aspiring developer: How are these apps made? Specifically, we'll look at the two main roads you can take: the Native Android route and the Flutter route. Are you ready? Twende Kazi!


The Big Question: What's the Difference? The Matatu vs. The Shuttle Analogy

Imagine you want to start a transport business in Nairobi. You have two choices:

  • The Matatu (Native Android): You can buy a matatu that is perfectly designed for a specific route, let's say from the CBD to Ngong. It knows all the potholes, the best shortcuts, and the passengers love it because it’s fast and efficient on that one route. This is Native Android development. You build an app specifically and perfectly for the Android operating system. It's fast, powerful, and uses all of Android's features perfectly.
  • The Shuttle (Flutter): Or, you could buy a modern, comfortable shuttle. This shuttle is versatile. It can run the CBD to Ngong route, but it can also easily do the CBD to Thika route or even go to Westlands. You manage one vehicle for many routes. This is Flutter. You write your code once, and it can run on both Android and iOS (Apple) phones. It's efficient and saves you time and money, but it might not be as perfectly customized for each "route" as the dedicated matatu.

Image Suggestion: An energetic, colorful digital art illustration. On the left, a souped-up Kenyan matatu with "Native Android" painted on its side, speeding down a road labeled "Android Highway." On the right, a sleek, modern shuttle bus with "Flutter" on its side, at an intersection with signs pointing to "Android Highway" and "iOS Boulevard." The style should be vibrant and optimistic.


Deep Dive 1: Native Android Development (The Matatu)

When you build natively, you are speaking the "mother tongue" of the device. For Android, that means using languages that the Android Operating System (OS) understands best. This gives you the most power and performance.

  • Languages: Primarily Kotlin (the modern, preferred language) and Java (the older, but still very powerful, language).
  • Pros:
    • Maximum Performance: Your app is as fast and responsive as it can be.
    • Full Access: You can use every single feature of the phone's hardware and Android OS immediately.
    • Latest Features: When Google releases a new Android version, you can use its new features on day one.
  • Cons:
    • Android Only: The code you write cannot be used to create an app for iPhones. You have to start from scratch for that.
    • Slower Development: Building two separate apps (one for Android, one for iOS) takes more time and money.

Here’s a simple "Hello, Nairobi!" in Kotlin, the language you would use for modern native Android development:


// In your MainActivity.kt file

// Import necessary libraries
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        // Find the TextView in our layout
        val welcomeTextView: TextView = findViewById(R.id.welcome_text)

        // Set its text
        welcomeTextView.text = "Hello, Nairobi!"
    }
}

This is how your app talks directly to the Android OS.


     ASCII Diagram: Native Communication
     +-----------------+
     |   Your App      | (Written in Kotlin/Java)
     +-----------------+
             |
             |  (Direct Communication)
             v
     +-----------------+
     |  Android OS     | (Manages everything)
     +-----------------+
             |
             v
     +-----------------+
     | Phone Hardware  | (Camera, GPS, etc.)
     +-----------------+

Deep Dive 2: Flutter - The Cross-Platform Champion (The Shuttle)

Flutter, created by Google, is a different approach. The goal is to build beautiful apps for multiple platforms from a single codebase. You write the code once, and Flutter handles the job of making it work on both Android and iOS.

  • Language: Dart (also created by Google). It's easy to learn, especially if you have some programming background.
  • Pros:
    • One Codebase, Two Apps: Huge savings in time and money! You write once, deploy everywhere.
    • Fast Development: Features like "Hot Reload" let you see changes to your code in real-time, which is incredibly fast.
    • Beautiful UI: Flutter gives you a lot of control to create stunning, custom user interfaces.
  • Cons:
    • Slight Performance Overhead: It can be a tiny bit slower than a true native app, but for most apps, users will never notice.
    • Larger App Size: Flutter apps can be a bit bigger in size because they bundle the Flutter engine with them.
    • Delayed Access to New Features: You might have to wait for the Flutter community to add support for the very latest Android/iOS features.

Here’s how you'd write "Hello, Kenya!" in Flutter using Dart. Notice how it's all about building with 'Widgets'.


// In your main.dart file

// Import the material design library from Flutter
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('My First Flutter App'),
        ),
        body: Center(
          child: Text(
            'Hello, Kenya!',
            style: TextStyle(fontSize: 24),
          ),
        ),
      ),
    );
  }
}

Flutter acts like a manager between your code and the device.


      ASCII Diagram: Flutter's Approach
      +------------------------+
      |  Your Single Codebase  | (Written in Dart)
      +------------------------+
                  |
                  v
      +------------------------+
      |      Flutter Engine    | (The "Manager")
      +------------------------+
            /            \
           /              \
          v                v
+-----------------+   +-----------------+
| Android Platform|   |   iOS Platform  |
+-----------------+   +-----------------+

Let's Talk Performance & A Little Math

When designing a UI, you often need to divide the screen space. Let's say we have a phone screen that is 800 pixels high. We want to give a top banner 20% of the screen and the rest to a scrollable list.


// Formula: PixelHeight = TotalHeight * Percentage

// 1. Calculate the banner height
Total Screen Height = 800px
Banner Percentage = 20% (or 0.20)

Banner Height = 800 * 0.20
Banner Height = 160 pixels

// 2. Calculate the remaining list height
List Percentage = 100% - 20% = 80% (or 0.80)

List Height = 800 * 0.80
List Height = 640 pixels

// Or simply:
List Height = Total Screen Height - Banner Height
List Height = 800 - 160 = 640 pixels

Both Native Android and Flutter have powerful tools to handle these kinds of layout calculations for you, but understanding the simple math behind it is key!


A Real-World Kenyan Scenario

Meet Wanjiku, a brilliant entrepreneur from Kiambu. She wants to create an app called "Shamba Fresh" that connects farmers directly with consumers in Nairobi. Her budget is small, and she's the only developer. She wants her app to be available to everyone, whether they use a Tecno (Android) or an iPhone.

Her Challenge: Should she spend a year learning Kotlin to build the Android app first, and then maybe find money later to hire an iOS developer? Or should she choose another path?

The Solution: For Wanjiku, Flutter is a fantastic choice. She can learn one language (Dart) and one framework (Flutter) and build an app that works beautifully on both Android and iOS. This saves her a huge amount of time and money, allowing her to launch "Shamba Fresh" to all her potential customers much faster. This is the power of cross-platform development!

Image Suggestion: A young, determined Kenyan woman (Wanjiku) sitting at a desk in a co-working space in Nairobi. On her laptop screen is a colorful app interface showing fresh vegetables. She is smiling, with code visible on the screen. The style should be modern, clean, and inspiring.


So, Which Path Should You Choose?

There is no single "best" answer! The right choice depends on the project. Think of it like a fundi (craftsman) choosing the right tool for the job.

  • Choose Native Android if:
    • Your app needs the absolute highest performance (e.g., a high-speed 3D game).
    • You need to use a brand new, very specific Android feature the moment it is released.
    • You are building a complex app that deeply integrates with the Android OS.
  • Choose Flutter if:
    • You need to target both Android and iOS users.
    • You have a limited budget and/or a small development team.
    • You want to build and iterate on your app very quickly.
    • Your app's UI is very important and you want it to look the same on all devices. (Most startups and business apps fall here!)

Conclusion & Your Turn!

Today, we've seen the two main roads for Android development: the dedicated, powerful "Matatu" of Native Android and the versatile, efficient "Shuttle" of Flutter. Both can get you to your destination, but they offer different advantages.

Your "Homework": Before our next class, I want you to open your phone. Find three popular Kenyan apps (e.g., M-PESA, Jumia, Little, KCB App, etc.). Based on their look, feel, and what you've learned today, try to guess if they are built natively or with a cross-platform tool like Flutter. Be prepared to explain why you think so! Sawa?

Great work today, everyone. The journey to becoming a mobile developer is exciting, and you've just taken a very important step. Keep that curiosity burning!

Pro Tip

Take your own short notes while going through the topics.

Previous PHP/Laravel
KenyaEdu
Add KenyaEdu to Home Screen
For offline access and faster experience