by @kodeazy

flutter how to display buttons side by side?

Home » flutter » flutter how to display buttons side by side?
  • I have two buttons.
  • To display these buttons side by side we use Row() widget.
  • Row() widget aligns both the buttons into single row.
  • Below is the syntax.

    Row(children: [
            new RaisedButton(
              child: new Text("Button_1"),
              onPressed: null,
            ),
            new RaisedButton(
              child: new Text("Button_2"),
              onPressed: null,
            )
          ])
  • Below is the example program to display buttons side by side.

    import 'package:flutter/material.dart';
    void main() {
    runApp(MyApp());
    }
    class MyApp extends StatelessWidget {
    Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Tittle',
        home: Scaffold(
          body: Row(children: [
            new RaisedButton(child: new Text("Button_1"), onPressed: null),
            SizedBox(width: 150),
            new RaisedButton(
              child: new Text("Button_2"),
              onPressed: null,
            )
          ]),
        ));
    }
    }