Home > Software design >  FLUTTER: how to set my Drawer background image width to Drawer width
FLUTTER: how to set my Drawer background image width to Drawer width

Time:11-02

want to add a background image to my drawer. I want to fix my background image over Drawer width

 Drawer(
    shape: const RoundedRectangleBorder(
      borderRadius: BorderRadius.only(
        topRight: Radius.circular(40),
        bottomRight: Radius.circular(40),
        topLeft: Radius.circular(40),
        bottomLeft: Radius.circular(40),
      ),
    ),
    child: Stack(children: <Widget>[
      Image.asset(
        "assets/images/menu.png",
        width: double.infinity,
        fit: BoxFit.cover,
      ),

CodePudding user response:

Wrap your Image.asset in a Positioned.fill(child: Image.asset ... ).

This should make it expand to fill the Stack.

CodePudding user response:

Try the following code:

 Drawer(
    shape: const RoundedRectangleBorder(
      borderRadius: BorderRadius.only(
        topRight: Radius.circular(40),
        bottomRight: Radius.circular(40),
        topLeft: Radius.circular(40),
        bottomLeft: Radius.circular(40),
      ),
    ),
    child: Stack(children: <Widget>[
      Image.asset(
        "assets/images/menu.png",
        width: MediaQuery.of(context).size.width,
        fit: BoxFit.cover,
      ),
  • Related