Question #62EasyFlutter Basics

Flutter difference between native development vs flutter ?

#flutter#native

Answer

Overview

Native development builds apps using platform-specific languages and tools. Flutter builds cross-platform apps from a single codebase using Dart.


Native Development

Android (Kotlin/Java)

kotlin
// Android - MainActivity.kt
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val button = findViewById<Button>(R.id.button)
        button.setOnClickListener {
            Toast.makeText(this, "Hello from Android", Toast.LENGTH_SHORT).show()
        }
    }
}

iOS (Swift/Objective-C)

swift
// iOS - ViewController.swift
class ViewController: UIViewController {
    @IBOutlet weak var button: UIButton!

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    @IBAction func buttonTapped(_ sender: UIButton) {
        let alert = UIAlertController(title: "Hello", message: "Hello from iOS", preferredStyle: .alert)
        present(alert, animated: true)
    }
}

Flutter Development

dart
// Flutter - main.dart (Works on both Android and iOS)
class MyApp extends StatelessWidget {
  
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('Flutter App')),
        body: Center(
          child: ElevatedButton(
            onPressed: () {
              ScaffoldMessenger.of(context).showSnackBar(
                SnackBar(content: Text('Hello from Flutter')),
              );
            },
            child: Text('Press Me'),
          ),
        ),
      ),
    );
  }
}

Detailed Comparison

AspectNative DevelopmentFlutter
LanguagesKotlin/Java (Android), Swift/Obj-C (iOS)Dart (both platforms)
CodebaseSeparate for each platformSingle codebase
Development time2x (build twice)1x (build once)
Team sizeLarger (Android + iOS devs)Smaller (Flutter devs)
UI renderingPlatform widgets (native)Custom rendering engine (Skia)
PerformanceMaximum (100%)Near-native (95-98%)
Hot reloadLimited/none✅ Instant (<1 second)
Learning curveSteeper (2 platforms)Moderate (1 framework)
Access to platform APIsDirect (100%)Via platform channels
App sizeSmallerLarger (includes engine)
UI consistencyDifferent per platformConsistent across platforms
CommunityVery large (separate)Large (unified)

Code Comparison Examples

Example 1: Button with Click Handler

Android (Kotlin):

kotlin
val button = findViewById<Button>(R.id.button)
button.setOnClickListener {
    Log.d("MyApp", "Button clicked")
}

iOS (Swift):

swift
@IBAction func buttonTapped(_ sender: UIButton) {
    print("Button clicked")
}

Flutter (Dart):

dart
ElevatedButton(
  onPressed: () {
    print('Button clicked');
  },
  child: Text('Click Me'),
)

Example 2: List View

Android (Kotlin):

kotlin
// XML layout
<androidx.recyclerview.widget.RecyclerView
    android:id="@+id/recyclerView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

// Kotlin code
val recyclerView = findViewById<RecyclerView>(R.id.recyclerView)
recyclerView.adapter = MyAdapter(items)
recyclerView.layoutManager = LinearLayoutManager(this)

iOS (Swift):

swift
// Swift with UITableView
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return items.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
    cell.textLabel?.text = items[indexPath.row]
    return cell
}

Flutter (Dart):

dart
ListView.builder(
  itemCount: items.length,
  itemBuilder: (context, index) {
    return ListTile(
      title: Text(items[index]),
    );
  },
)

Example 3: Network Request

Android (Kotlin):

kotlin
// Using Retrofit
interface ApiService {
    @GET("users")
    suspend fun getUsers(): List<User>
}

// In ViewModel
viewModelScope.launch {
    try {
        val users = apiService.getUsers()
        _users.value = users
    } catch (e: Exception) {
        _error.value = e.message
    }
}

iOS (Swift):

swift
// Using URLSession
let url = URL(string: "https://api.example.com/users")!
URLSession.shared.dataTask(with: url) { data, response, error in
    if let data = data {
        let users = try? JSONDecoder().decode([User].self, from: data)
        DispatchQueue.main.async {
            self.users = users
        }
    }
}.resume()

Flutter (Dart):

dart
// Using http package
Future<List<User>> fetchUsers() async {
  final response = await http.get(Uri.parse('https://api.example.com/users'));

  if (response.statusCode == 200) {
    return (jsonDecode(response.body) as List)
        .map((json) => User.fromJson(json))
        .toList();
  } else {
    throw Exception('Failed to load users');
  }
}

Advantages of Native Development

✅ Pros

  • Maximum performance - Direct access to platform APIs
  • Full platform features - Immediate access to new OS features
  • Native look and feel - Platform-specific UI guidelines
  • Smaller app size - No additional runtime/engine
  • Mature ecosystem - Large community, extensive libraries
  • Platform optimizations - Optimized for each platform

❌ Cons

  • Separate codebases - Maintain two apps (2x work)
  • Higher cost - Need Android + iOS developers
  • Slower development - Build features twice
  • No code sharing - Business logic duplicated
  • Different UI - Inconsistent experience across platforms

Advantages of Flutter

✅ Pros

  • Single codebase - Write once, run anywhere
  • Faster development - Build both apps simultaneously
  • Lower cost - One team, one codebase
  • Hot reload - See changes instantly
  • Consistent UI - Same look on all platforms
  • Easier testing - Test once instead of twice
  • Rich widgets - Beautiful pre-built UI components

❌ Cons

  • Larger app size - Includes Flutter engine (~4-5MB)
  • Less mature - Newer than native (released 2017)
  • Platform channel complexity - Need bridges for native features
  • Learning Dart - New language to learn
  • Slight performance overhead - 95-98% native performance

When to Choose Native Development

Choose native when:

  • Building platform-specific apps (no cross-platform need)
  • Maximum performance is critical (heavy gaming, AR/VR)
  • Need bleeding-edge platform features immediately
  • Already have separate Android/iOS teams
  • App relies heavily on platform-specific APIs
  • Very complex animations or custom rendering

Examples:

  • High-performance games (Call of Duty Mobile)
  • AR apps (IKEA Place)
  • Platform-specific utilities (iOS Shortcuts)
  • Apps with heavy native integrations

When to Choose Flutter

Choose Flutter when:

  • Building for multiple platforms (Android, iOS, Web)
  • Want faster development and lower cost
  • Need consistent UI across platforms
  • Building MVP or startup app
  • Team knows Dart or wants single codebase
  • Not heavily dependent on platform-specific features

Examples:

  • E-commerce apps (Alibaba)
  • Social media (Google Ads)
  • Productivity apps (Google Pay)
  • Fintech apps (Nubank)

Real-World Examples

Native Apps

AppPlatformReason
InstagramNative (separate)Performance, platform features
UberNative (separate)Maps, location, complex UI
WhatsAppNative (separate)Performance, background services

Flutter Apps

AppReason
Google AdsCross-platform, fast development
AlibabaConsistent UI, large catalog
NubankFast iteration, unified experience
BMWCross-platform, modern UI

Development Time Comparison

Native (Separate Codebases)

text
Android development:  4 weeks
iOS development:      4 weeks
Total:                8 weeks

Flutter (Single Codebase)

text
Flutter development:  4-5 weeks
Total:                4-5 weeks

Time saved: ~40-50%


Cost Comparison

Native

text
Android Developer:     $100K/year
iOS Developer:         $100K/year
Total:                 $200K/year

Flutter

text
Flutter Developer:     $110K/year
Total:                 $110K/year

Cost saved: ~45%


Hybrid Approach

Some companies use both:

text
Flutter:   80% of features (UI, business logic)
Native:    20% of features (complex platform integrations)

Example:

  • Main app in Flutter
  • Camera/AR features in native (via platform channels)

Performance Benchmark

TaskNativeFlutter
Simple list scrolling60 FPS60 FPS
Complex animations60 FPS58-60 FPS
Startup time100%95%
Heavy computation100%98%

Key Takeaways

Native: Maximum performance and platform integration, but 2x development cost.

Flutter: 95% native performance, 50% faster development, consistent UI.

Choose based on: Project requirements, budget, timeline, and team expertise.


Resources