Flutter 1.0 was officially released at the Flutter Live event. This release marked Flutter’s transition to a stable framework, allowing developers to build production-quality applications. Key features included hot reload, a rich set of pre-designed widgets, and support for iOS and Android.
Author: saqibkhan
-
Beta Release (2018)
Flutter entered its beta phase in early 2018, with significant improvements in performance, tooling, and documentation. This phase saw an increase in community engagement and contributions.
-
Alpha Release (2017)
In early 2017, Flutter was made available as an alpha release. This marked the first time developers could start building applications with Flutter and provided initial feedback on its capabilities.
-
Custom Exception Handling
This example shows how to create and handle custom exceptions.
class InsufficientFundsException implements Exception { final String message; InsufficientFundsException(this.message); @override String toString() => 'InsufficientFundsException: $message'; } class BankAccount { double balance; BankAccount(this.balance); void withdraw(double amount) {
} } void main() { var account = BankAccount(100); try {if (amount > balance) { throw InsufficientFundsException('Cannot withdraw \$${amount.toStringAsFixed(2)} with balance of \$${balance.toStringAsFixed(2)}'); } balance -= amount; print('Withdrawn: \$${amount.toStringAsFixed(2)}. New balance: \$${balance.toStringAsFixed(2)}');
} catch (e) {account.withdraw(50); account.withdraw(60);
} }print(e); -
Futures and Streams
This example demonstrates the use of
FuturesandStreamsfor asynchronous programming.import 'dart:async'; void main() { // Using a Future print('Fetching data...'); fetchData().then((data) {
}); // Using a Stream var numberStream = generateNumbers(); numberStream.listen((number) {print('Data received: $data');
}); } Future<String> fetchData() async { await Future.delayed(Duration(seconds: 2)); return 'Sample Data'; } Stream<int> generateNumbers() async* { for (var i = 1; i <= 5; i++) {print('Received number: $number');
} }await Future.delayed(Duration(seconds: 1)); yield i; -
Using Mixins
This example illustrates how to use mixins to share behavior between classes.
mixin Logger { void log(String message) {
} } class User with Logger { String name; User(this.name); void sayHello() {print('LOG: $message');
} } class Admin with Logger { String adminName; Admin(this.adminName); void performAdminTask() {log('User $name says hello!');
} } void main() { var user = User('Alice'); user.sayHello(); var admin = Admin('Bob'); admin.performAdminTask(); }log('Admin $adminName is performing an admin task.'); -
Early Development (2016)
Flutter’s early development focused on providing a framework that allowed for expressive UI and smooth animations. Google started to refine the toolkit, emphasizing its ability to render UI at 60 frames per second.
-
File I/O Operations
This example demonstrates how to read from and write to files in Dart.
import 'dart:io'; void main() async { // Writing to a file var file = File('example.txt'); await file.writeAsString('Hello, Dart!\nThis is a file I/O example.\n'); print('File written: ${file.path}'); // Reading from the file String contents = await file.readAsString(); print('File contents:\n$contents'); // Appending to the file await file.writeAsString('Appending new content.\n', mode: FileMode.append); contents = await file.readAsString(); print('Updated file contents:\n$contents'); } -
Working with Collections
This example shows how to manipulate collections and use higher-order functions.
void main() { List<int> numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; // Filtering even numbers var evenNumbers = numbers.where((number) => number.isEven).toList(); print('Even Numbers: $evenNumbers'); // Squaring the numbers var squaredNumbers = numbers.map((number) => number * number).toList(); print('Squared Numbers: $squaredNumbers'); // Summing all numbers var sum = numbers.reduce((a, b) => a + b); print('Sum of Numbers: $sum'); // Finding the maximum number var maxNumber = numbers.reduce((a, b) => a > b ? a : b); print('Maximum Number: $maxNumber'); } -
Initial Announcement (2015)
Flutter was first announced at the Dart Developer Summit in November 2015. Initially known as “Sky,” it was designed to enable high-performance applications on both iOS and Android.