I am learning Flutter and have just added the capability to sign in with Apple Sign in and Google Sign in. The buttons are of different size and I want to set the size such that they are proportional to the screen width.
I have tried with a ColumnView, CrossAxisAlignment.center and wrapping the button in a SizedBox.
I have tried some other things, like Expanded but have not had any success with that.
class LoginView extends StatelessWidget {
final AppleAuthenticationProvider _appleAuthenticationProvider =
AppleAuthenticationProvider();
LoginView({Key? key}) : super(key: key);
Widget appleButton(BuildContext context) {
return SignInWithAppleButton(
style: SignInWithAppleButtonStyle.black,
onPressed: () {
_appleAuthenticationProvider.signInWithApple().then((user) {
if (user != null) {
loadUserData(user).then((value) {
Navigator.of(context).push<void>(
MaterialPageRoute<void>(
builder: (BuildContext context) {
return const MainView();
},
),
);
});
}
});
},
);
}
return MaterialApp(
color: Color.fromARGB(255, 10, 97, 247),
home: Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [SizedBox(width: 0.9 * deviceWidth, child: appleButton(context))],
),
),
);
}
}
