By using the Center widget with a Column and setting the mainAxisAlignment property to MainAxisAlignment.center, all child widgets of the column will appear in the center of the screen.
import 'package:flutter/material.dart';
import 'dart:math';
import 'package:untitled2/flutter_example.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.deepPurple,
),
useMaterial3: true,
),
home: const HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Hello World',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
),
)
],
),
),
);
}
}
Work with our skilled Flutter developers to accelerate your project and boost its performance.
Hire Flutter Developers