Jagora don Amfani Padding a ciki Flutter

A Flutter, Padding yana ɗaya daga cikin mahimman kayan aikin don ƙirƙirar tazara tsakanin abubuwa a cikin mahaɗin mai amfani da ku. Wannan yana taimaka muku cimma kyakkyawan tsari mai kyan gani da inganci. Wannan labarin zai jagorance ku kan yadda ake amfani da shi Padding don ƙirƙirar tazara tsakanin abubuwa a cikin Flutter aikace-aikacenku.

Asalin Amfani

Padding ana amfani dashi ta hanyar nade abin da widget kuke son ƙara tazara a kusa. A ƙasa shine yadda zaku iya amfani da ku Padding don ƙarawa padding kusa da widget:

Padding(
  padding: EdgeInsets.all(16.0), // Adds 16 points of padding around the child widget  
  child: YourWidgetHere(),  
)  

Keɓance Tazara

Kuna iya keɓance tazara don kowane gefe(hagu, dama, sama, ƙasa, tsaye, a kwance) ta amfani da EdgeInsets kayan:

Padding(
  padding: EdgeInsets.only(left: 10.0, right: 20.0), // Adds 10 points of padding on the left and 20 points on the right  
  child: YourWidgetHere(),  
)  
Padding(
  padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0), // Adds vertical and horizontal padding  
  child: YourWidgetHere(),  
)  

Haɗuwa tare da Layouts

Padding yawanci ana amfani dashi don daidaita tazara tsakanin widget din a cikin shimfidu kamar Column, Row, ListView, da sauransu.

Column(  
  children: [  
    Padding(  
      padding: EdgeInsets.only(bottom: 10.0),  
      child: Text('Element 1'),  
   ),  
    Padding(  
      padding: EdgeInsets.only(bottom: 10.0),  
      child: Text('Element 2'),  
   ),  
    // ...  
  ],  
)  

Sassauci tare da Girmama

Padding ba kawai yana ƙara tazara ba amma kuma yana iya ƙirƙirar tasiri kama da gefe. Lokacin amfani Padding, baya shafar sarari a wajen widget.

 

Ƙarshe:

Padding kayan aiki ne mai amfani don ƙirƙirar tazara da daidaita matsayin abubuwa a cikin Flutter UI ɗin ku. Ta amfani da Padding, za ka iya ƙirƙirar mafi ban sha'awa da kuma ingantaccen shimfidu don aikace-aikacenku.