【Flutter】Remove padding

IconButton

IconButton(
  onPressed: () {},
  padding: EdgeInsets.zero,
  constraints: const BoxConstraints(),
  style: const ButtonStyle(tapTargetSize: MaterialTapTargetSize.shrinkWrap),
  icon: const Icon(Icons.add),
),

ElevatedButton

ElevatedButton(
  onPressed: () {},
  style: ElevatedButton.styleFrom(
    padding: EdgeInsets.zero,
    minimumSize: Size.zero,
  ),
  child: const Text('Hi'),
),

OutlinedButton

OutlinedButton(
  onPressed: () {},
  style: OutlinedButton.styleFrom(
    side: BorderSide(color: Colors.grey.shade300),
    foregroundColor: Colors.grey,
    shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5)),
    padding: EdgeInsets.zero,
    minimumSize: Size.zero,
  ),
  child: const Text('Hi'),
),

ListTile

ListTile(
  dense: true,
  contentPadding: EdgeInsets.zero,
  visualDensity: const VisualDensity(horizontal: -4, vertical: -4),
),
發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *