I don’t know what I’m doing wrong, all my pages have the same model, but this one doesn’t want to center !
Do you have any idea where the problem come from ?
import 'package:flutter/material.dart';
import 'package:sizer/sizer.dart';
class OnBoardingDataPage1 extends StatefulWidget {
const OnBoardingDataPage1({Key? key}) : super(key: key);
@override
State<OnBoardingDataPage1> createState() => _OnBoardingDataPage1State();
}
class _OnBoardingDataPage1State extends State<OnBoardingDataPage1> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: 5.h),
Text(
"MugiwarApp",
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleLarge,
),
Image.asset(
"assets/images/animation.gif",
height: 125.0,
width: 125.0,
)
]),
)),
);
}
}
2
Answers
Because column’s parent are not bounded, so it takes size from its children. So wrap your
column
withSizedBox
and set its width todouble.infinity
:Add Center widget in your widgets tree.