While React Native was making waves in the cross-platform space, Google launched Flutter—a completely different solution. It doesn’t rely on native components but uses its own rendering engine to draw UI.
What is Flutter?#
Flutter is a cross-platform UI framework released by Google in 2017, with version 1.0 released in 2018. Its core characteristic is: Using Dart language, achieving native-level performance through a self-developed rendering engine.
Understanding Through Analogy#
| Aspect | React Native | Flutter |
|---|---|---|
| Rendering | Calls native components | Self-developed rendering engine |
| Language | JavaScript/TypeScript | Dart |
| Performance | Depends on native | Close to native |
| Controls | Native controls | Self-drawn controls |
| Like | Translator | Painter |
React Native is the “translator”—translating JavaScript into native components. Flutter is the “painter”—drawing UI itself, no translation needed.
Core Features#
1. Self-Developed Rendering Engine: Skia#
Flutter uses the Skia graphics library to draw UI itself, meaning:
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('Flutter Demo')),
body: Center(
child: Text('Hello Flutter!'),
),
),
);
}
}All UI is drawn by Flutter itself, not relying on iOS’s UIKit or Android’s View system.
2. Widget: Everything is a Component#
In Flutter, all UI is a Widget:
// Basic Widget
Text('Hello') // Text
Icon(Icons.star) // Icon
Image.network('url') // Image
ElevatedButton(onPressed: () {}, child: Text('Click')) // Button
// Layout Widget
Column(children: [...]) // Vertical arrangement
Row(children: [...]) // Horizontal arrangement
Stack(children: [...]) // Stacking
Container() // Container
// Complex Widget
ListView.builder(
itemCount: 100,
itemBuilder: (context, index) => ListTile(title: Text('Item $index')),
)3. Hot Reload: Excellent Developer Experience#
Flutter’s Hot Reload is very powerful:
- UI updates instantly after saving code
- State is preserved
- Perfect for UI development
4. Declarative UI: Similar to React#
Flutter uses a declarative UI paradigm:
class Counter extends StatefulWidget {
@override
_CounterState createState() => _CounterState();
}
class _CounterState extends State<Counter> {
int _count = 0;
void _increment() {
setState(() {
_count++;
});
}
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Count: $_count'),
ElevatedButton(
onPressed: _increment,
child: Text('Increment'),
),
],
);
}
}5. Rich Component Library#
Flutter provides rich Material Design and Cupertino components:
// Material Design components
Scaffold(
appBar: AppBar(title: Text('Title')),
drawer: Drawer(child: ...),
floatingActionButton: FloatingActionButton(...),
)
// iOS-style components
CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(...),
)6. State Management: Multiple Solutions#
Flutter has multiple state management solutions:
| Solution | Best For | Complexity |
|---|---|---|
| setState | Simple pages | Low |
| Provider | Small to medium apps | Medium |
| Riverpod | Medium to large apps | Medium |
| Bloc | Complex apps | High |
| GetX | Rapid development | Low |
// Provider example
class CounterModel extends ChangeNotifier {
int _count = 0;
int get count => _count;
void increment() {
_count++;
notifyListeners();
}
}
// Usage
Consumer<CounterModel>(
builder: (context, model, child) {
return Text('${model.count}');
},
)Why is Flutter So Popular?#
1. True Cross-Platform#
One codebase, runs on:
- iOS
- Android
- Web
- Windows
- macOS
- Linux
2. Near-Native Performance#
Because it uses a self-developed rendering engine, not relying on native components:
- Runs smoothly at 60fps
- No JavaScript bridge overhead
- Compiles directly to native code
3. Beautiful UI#
Flutter’s Material Design implementation is excellent:
- Rich animations
- Smooth transitions
- Highly customizable
4. High Development Efficiency#
- Fast hot reload
- Single language (Dart)
- Rich component library
Use Cases#
| Scenario | Suitability | Notes |
|---|---|---|
| Cross-platform apps | ⭐⭐⭐⭐⭐ | Core use case |
| Rapid prototyping | ⭐⭐⭐⭐⭐ | High development efficiency |
| MVP products | ⭐⭐⭐⭐⭐ | Fast validation |
| Complex animations | ⭐⭐⭐⭐⭐ | Self-developed rendering engine |
| Enterprise apps | ⭐⭐⭐⭐ | Gradually maturing |
| Games | ⭐⭐⭐ | Has dedicated game engines |
Learning Path#
Beginner (2 weeks)#
- Master Dart basics
- Understand Flutter Widget system
- Learn common layouts
- Master state management basics
Intermediate (2-3 weeks)#
- Deep dive into layout principles
- Master Provider/Riverpod
- Learn network requests
- Master animations
Advanced (continuous learning)#
- Platform Channels
- Performance optimization
- Packaging and publishing
- Deep dive into rendering principles
Flutter vs Other Frameworks#
| Feature | Flutter | React Native | SwiftUI | Kotlin Multiplatform |
|---|---|---|---|---|
| Language | Dart | JS/TS | Swift | Kotlin |
| Rendering | Self-developed engine | Native components | Native | Native |
| Performance | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
| Cross-platform | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | Apple only | ⭐⭐⭐⭐ |
| UI consistency | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐ |
Simply put:
- Flutter: Best UI consistency, most comprehensive cross-platform
- React Native: Frontend developer-friendly
- SwiftUI: Native iOS experience
- Kotlin Multiplatform: Shared business logic
Dart Language Basics#
// Variables
var name = 'Tom';
String name = 'Tom';
int age = 25;
double height = 1.75;
bool isStudent = true;
// Function
int add(int a, int b) => a + b;
// Class
class Person {
String name;
int age;
Person(this.name, this.age);
void greet() => print('Hello, I am $name');
}
// Async
Future<String> fetchData() async {
await Future.delayed(Duration(seconds: 1));
return 'Data';
}Common Commands#
# Install Flutter
git clone https://github.com/flutter/flutter.git
# Create project
flutter create my_app
# Run
flutter run
# Build APK
flutter build apk
# Build iOS
flutter build ios
# Build Web
flutter build webSummary#
Flutter provides a completely new approach to cross-platform development:
- Self-developed rendering engine—Near-native performance
- Widget system—Everything is a component
- Dart language—Concise and efficient
- Hot reload—Excellent developer experience
- True cross-platform—One codebase, multiple platforms
If you need to develop cross-platform apps, especially with high UI consistency requirements, Flutter is the best choice.
Next up: Flutter “draws its own UI,” while React Native “calls native components.” As the most familiar cross-platform solution for frontend developers, what charm does React Native have? Let’s dive into this in the final article.
