38242

Resize leading widget in flutter AppBar

<h3>Question</h3>

I am making a custom AppBar that has a larger height than the typical AppBar. I would like to resize the leading widget/icon as well, and take advantage of the automaticallyImplyLeading default behaviors (so the menu icons and back icons are automatically implemented).

This is the solution I thought I would implement:

class AppAppBar extends PreferredSize{ AppAppBar(String title) : super( preferredSize: Size.fromHeight(56.0), child: AppBar( centerTitle: true, title: Text(title, style: textStyle) )) { (child as AppBar).leading = SizedBox(width: 30.0, height: 30.0, child: (child as AppBar).leading); } static const textStyle = TextStyle(fontSize: 32.0); }

But of course this won't work because (child as AppBar).leading is final.

So in the AppBar below (text size made dramatically larger for illustration purposes), I would like to make the automatically added hamburger icon larger in comparison.

What do you think? Are there solutions for this or should I give up on the automatic icons and add them myself?

Edit: Added an image to show what I mean


<h3>Answer1:</h3>

You cant because it is a predefined widget.

You can work around it with a Row widget:

Scaffold( key:_scaffoldKey, drawer: Drawer(), appBar: AppBar( automaticallyImplyLeading: false title: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ SizedBox( height: 20, // Your Height width: 20, // Your width child: IconButton( // Your drawer Icon onPressed: () => _scaffoldKey.currentState.openDrawer()), icon: Icon(Icons.arrow_back, color: Colors.white), ),) // Your widgets here ], ), ), )

You need the Key to open the drawer with _scaffoldKey.currentState.openDrawer().

automaticallyImplyLeading: false will prevent the default drawer Icon.

来源:https://stackoverflow.com/questions/52082857/resize-leading-widget-in-flutter-appbar

Recommend

  • Resize leading widget in flutter AppBar
  • Resize leading widget in flutter AppBar
  • Cant Install Tensorflow 2.2.0rc0 in Ubuntu with Github Actions inside setup.py
  • How to debug .exe started by another .exe in Delphi
  • How can I call a javascript function when Checkbox is checked
  • Check for existence of multiple fields in MongoDB document
  • kube-apiserver high CPU and requests
  • OWL Api, move class from parent A to B
  • Simple Donut Chart with Raphael
  • Count of values within specified range of value in each row using data.table
  • What is the function of Spring Session?
  • pass sessionid through jquery ajax call to php
  • convert eye-tracking .edf file to ASC/CSV format
  • Is there a command line tool to get the machine code for an assembly instruction?
  • Caffe : train network accuracy = 1 constant ! Accuracy issue
  • Faces Servlet not parsing .xhtml pages in jsf 2. running on tomcat 7
  • Network communication options in Java (Client/Server)
  • mssql script data insert or update
  • Dynamically change JavaFX css property
  • Slick: How can I combine a SQL LIKE statement with a SQL IN statement
  • Smarter Removing Unnecessary WhiteSpace CSV
  • Auto send email based on the time and email address in database
  • Unsupported ciphersuite TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
  • PHP: Need to close STDIN in order to read STDOUT?
  • What does “T extends Junk” mean in a generic class in Java?
  • ASP.NET MVC 2 actions for the same route?
  • how to specify different css for ie
  • How do I use libcurl to printf a remote FTP directory listing?
  • Rotating Towards Path in OpenGL
  • How to clear a browser cache in Protractor
  • Capture SIGFPE from SIMD instruction
  • Using Service Component Runtime
  • How do I use TagLib-Sharp to write custom (PRIV) ID3 frames?
  • CAS 4 - Not able to retrieve the LDAP groups after successful authentication
  • ReferenceError: TextEncoder is not defined