Dart to język programowania stworzony przez Google, zoptymalizowany pod kątem budowy interfejsów użytkownika. Jest silnie typowany, kompilowany do natywnego kodu maszynowego (AOT) oraz do JavaScript. Dart jest fundamentem frameworka Flutter.
Dart łączy prostotę składni zbliżoną do Java/TypeScript z nowoczesnymi feature'ami: null safety, async/await, mixins, extension methods i pattern matching.
void main() {
var name = 'Assadante';
print('Witaj w $name!');
// Null safety
String? nullable;
print(nullable?.length ?? 0);
}
class User {
final String name;
final String email;
final int age;
const User({
required this.name,
required this.email,
required this.age,
});
String get displayName => '$name ($age)';
bool get isAdult => age >= 18;
}
import 'package:http/http.dart' as http;
import 'dart:convert';
Future<List<User>> fetchUsers() async {
final response = await http.get(
Uri.parse('https://api.example.com/users'),
);
if (response.statusCode == 200) {
final List data = jsonDecode(response.body);
return data.map((json) => User.fromJson(json)).toList();
}
throw Exception('Błąd pobierania danych');
}
class ProfileCard extends StatelessWidget {
final User user;
const ProfileCard({required this.user});
@override
Widget build(BuildContext context) {
return Card(
child: ListTile(
leading: CircleAvatar(
child: Text(user.name[0]),
),
title: Text(user.displayName),
subtitle: Text(user.email),
trailing: Icon(
user.isAdult ? Icons.check_circle : Icons.warning,
color: user.isAdult ? Colors.green : Colors.orange,
),
),
);
}
}
Natywna wydajność na iOS i Android z jednego codebase. Skia rendering engine.
Flutter Web kompiluje do JS/Wasm. Idealne do dashboardów i paneli admin.
Windows, macOS, Linux — natywne aplikacje desktopowe z jednego kodu.
Zmiany w kodzie widoczne natychmiast. Najszybszy dev loop w branży.
60/120 FPS animacje. Rive, Lottie, custom painters. Pixel-perfect UI.
FlutterFire — oficjalne pluginy do Auth, Firestore, Storage, Functions, Analytics.
Idealny gdy: budujesz aplikację mobilną na iOS i Android, chcesz szybki time-to-market, potrzebujesz pięknego UI z custom animacjami, planujesz też wersję web/desktop.
Nie najlepszy gdy: potrzebujesz tylko strony www (lepiej Next.js), budujesz heavy-compute backend (lepiej Go/Python), potrzebujesz natywnych API specyficznych dla jednej platformy.