79605417

Date: 2025-05-04 08:21:56
Score: 3
Natty:
Report link

Puedes intentar con esto :)

este Widget elimina todo el margen del Appbar y puedes decidir donde se orientará el contenido del mismo, solamente tienes que usar Align para decidir en donde debe estar y listo. También le puedes poner un padding y cosas por el estilo si gustas

import 'package:flutter/material.dart';

class AppBarWithoutMarginWidget extends StatelessWidget implements PreferredSizeWidget {
  const AppBarWithoutMarginWidget({super.key, required this.child});

  final Widget child;

  @override
  Widget build(BuildContext context) {
    return AppBar(
      backgroundColor: Colors.red,
      automaticallyImplyLeading: false,
      centerTitle: false,
      titleSpacing: 0,
      flexibleSpace: SafeArea(
        child: child,
      ),
    );
  }
  
  @override
  Size get preferredSize => Size.fromHeight(kToolbarHeight);
}

Ejemplo de uso:

appBar: AppBarWithoutMarginWidget(
        child: Align(
          alignment: Alignment.centerLeft,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Icon(Icons.abc), 
              Text("Holaaaa")])
        )
      ),

Resultado:
enter image description here

Reasons:
  • Blacklisted phrase (1): enter image description here
  • RegEx Blacklisted phrase (2.5): mismo
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Saul Misael Colli Kumul