Change AppBar Height In Flutter

In this article, you will learn How to change AppBar Height in your Flutter Application. Creating AppBar main.dart Here, you have a simple Scaffold with…

The post Change AppBar Height In Flutter appeared first on CodeSource.io.


This content originally appeared on CodeSource.io and was authored by Jatin Hemnani

In this article, you will learn How to change AppBar Height in your Flutter Application.

Creating AppBar

main.dart

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: PreferredSize(
          preferredSize: Size.fromHeight(100.0),
          child: AppBar(
            title: Text('Home'),
            centerTitle: true,
          ),
        ),
        body: Center(
          child: Text('Codesource.io'),
        ),
      ),
    );
  }
}

Here, you have a simple Scaffold with AppBar. If you want to add extra height to your AppBar you have to use the PreferredSize() widget as AppBar doesn’t have height property by default. PreferredSize have two properties i.e

  • preferredSize: it takes the Size property and you can then choose fromHeight method to give extra height to your AppBar.
  • child: the child widget which is AppBar.

Result

Before PreferredSize()
After PreferredSize()

The post Change AppBar Height In Flutter appeared first on CodeSource.io.


This content originally appeared on CodeSource.io and was authored by Jatin Hemnani


Print Share Comment Cite Upload Translate Updates
APA

Jatin Hemnani | Sciencx (2021-02-26T16:29:02+00:00) Change AppBar Height In Flutter. Retrieved from https://www.scien.cx/2021/02/26/change-appbar-height-in-flutter/

MLA
" » Change AppBar Height In Flutter." Jatin Hemnani | Sciencx - Friday February 26, 2021, https://www.scien.cx/2021/02/26/change-appbar-height-in-flutter/
HARVARD
Jatin Hemnani | Sciencx Friday February 26, 2021 » Change AppBar Height In Flutter., viewed ,<https://www.scien.cx/2021/02/26/change-appbar-height-in-flutter/>
VANCOUVER
Jatin Hemnani | Sciencx - » Change AppBar Height In Flutter. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/02/26/change-appbar-height-in-flutter/
CHICAGO
" » Change AppBar Height In Flutter." Jatin Hemnani | Sciencx - Accessed . https://www.scien.cx/2021/02/26/change-appbar-height-in-flutter/
IEEE
" » Change AppBar Height In Flutter." Jatin Hemnani | Sciencx [Online]. Available: https://www.scien.cx/2021/02/26/change-appbar-height-in-flutter/. [Accessed: ]
rf:citation
» Change AppBar Height In Flutter | Jatin Hemnani | Sciencx | https://www.scien.cx/2021/02/26/change-appbar-height-in-flutter/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.