본문 바로가기

안드로이드/Flutter

flutter dialog width change

 

Hello guys today, Im going to tell you

"How to make your dialog's width be full of your device screen!"

 

How?

1. find the file  'dialog.dart' from  

\flutter\packages\flutter\lib\src\cupertino
(this is the location where you installed your flutter)

2. change the line 

padding: MediaQuery.of(context).viewInsets + const EdgeInsets.symmetric(horizontal: 40.0, vertical: 24.0),

to

padding: MediaQuery.of(context).viewInsets + const EdgeInsets.symmetric(horizontal: 0.0, vertical: 24.0),

And ctrl + s

 

Its done!

Enjoy your wide dialog

byebye

 

Wait!!!

 

it is not done.

You don't have to change the dialog.dart file in the flutter directory.

It causes some problems when updating it's version or something.

so follow it

 

1. copy all texts in the dialog.dart

 

2. make a new dart file named 'customDialog.dart' in your project's lib

and paste 1.'s texts at customDialog.dart

 

3. change the line

padding: MediaQuery.of(context).viewInsets + const EdgeInsets.symmetric(horizontal: 40.0, vertical: 24.0),

to

padding: MediaQuery.of(context).viewInsets + const EdgeInsets.symmetric(horizontal: 0.0, vertical: 24.0),

 

4. add this to your main.dart

import 'package:nininaenae/custom_dialog.dart' as customDialog;

5. use 'return customDialog.AlertDialog();'

when you need a full width dialog

 

 

it's end

so please use it. it's very good

 

byebye