Created
September 14, 2022 21:20
-
-
Save juanagu/0199904cac2a477c420efe473ed21319 to your computer and use it in GitHub Desktop.
How to put two IconButtons in the same Column (AppBar and Body)?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file | |
| // for details. All rights reserved. Use of this source code is governed by a | |
| // BSD-style license that can be found in the LICENSE file. | |
| import 'package:flutter/material.dart'; | |
| void main() => runApp(MyApp()); | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| title: 'Flutter Demo', | |
| debugShowCheckedModeBanner: false, | |
| theme: ThemeData( | |
| primarySwatch: Colors.blue, | |
| ), | |
| home: HomePage(), | |
| ); | |
| } | |
| } | |
| class HomePage extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| appBar: _buildAppBar(), | |
| body: _buildBody(), | |
| ); | |
| } | |
| PreferredSizeWidget _buildAppBar() { | |
| return AppBar( | |
| leading: IconButton( | |
| icon: const Icon(Icons.arrow_back), | |
| onPressed: () {}, | |
| ), | |
| actions: [ | |
| IconButton( | |
| icon: const Icon(Icons.flutter_dash_rounded), | |
| onPressed: () {}, | |
| ), | |
| IconButton( | |
| icon: const Icon(Icons.flutter_dash), | |
| onPressed: () {}, | |
| ), | |
| ], | |
| ); | |
| } | |
| Widget _buildBody() { | |
| return Padding( | |
| padding: const EdgeInsets.only(left: 16.0), | |
| child: Column( | |
| children: [ | |
| Row( | |
| children: [ | |
| const Expanded( | |
| child: Text( | |
| 'Name', | |
| style: TextStyle( | |
| fontWeight: FontWeight.bold, | |
| fontSize: 18.0, | |
| ), | |
| )), | |
| IconButton( | |
| icon: const Icon(Icons.flutter_dash), | |
| onPressed: () {}, | |
| ), | |
| ], | |
| ), | |
| ], | |
| ), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment