Build Android + iOS Apps with One Codebase
Flutter is a UI framework by Google used to build cross-platform mobile apps using a single codebase.
Flutter uses Dart language
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("Hello Flutter")),
body: Center(child: Text("Welcome")),
),
);
}
}
Everything in Flutter is a Widget Examples: - Text - Button - Container - Column - Row
ElevatedButton(
onPressed: () {
print("Clicked");
},
child: Text("Click Me"),
)
State means changing UI dynamically
Example:
setState(() {
counter++;
});
Column → vertical layout Row → horizontal layout Container → box styling
Navigator.push( context, MaterialPageRoute(builder: (context) => SecondPage()), );
Use http package: - Fetch data from backend - Show JSON in UI