How to create Raise Button in Flutter

This Article is posted by nikhilchaudhary12155 at 9/25/2019 9:42:16 AM



Buttons are the basic UI component of any framework. In this tutorial, we will do a Flutter Raised Button Example. Flutter’s basic motto is to create stunning UI.  There are 7 different types of buttons in Flutter. Here you can learn about all those flutter’s buttons.
flutter raisedbutton example code- A complete tutorial
Code : 
RaisedButton(child: Text("Rock & Roll"),
                onPressed: _changeText,
                color: Colors.red,
                textColor: Colors.yellow,
                padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
                splashColor: Colors.grey,
              )

RAISEDBUTTON PROPERTIES

Raised button has a single constructor but a long list of attributes. I am just mentioning the basic one we have used.

  • onPressed: onPressed function is called when we click on the button.
  • color: Color set the button color. Our button color is red.
  • textColor: This attribute is used to give the color to the button’s text.
  • padding: Padding to the text inside the button.
  • splash color: A color effect that we get when we click on the button.

FLUTTER RAISED BUTTON EXAMPLE CODE :

void main() => runApp(MaterialApp(title: "RaisedButton", home: MainActivity()));
 
class MainActivity extends StatefulWidget {
  @override
  _MainActivityState createState() => _MainActivityState();
}
 
class _MainActivityState extends State {
  String msg = 'Flutter RaisedButton example';
 
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.yellow,
      appBar: AppBar(
        title: Text('Raised Button'),
      ),
      body: Container(
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text(
                msg,
                style: TextStyle(fontSize: 20, fontStyle: FontStyle.italic),
              ),
              RaisedButton(
                child: Text("Rock & Roll"),
                onPressed: _changeText,
                color: Colors.red,
                textColor: Colors.yellow,
                padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
                splashColor: Colors.grey,
              )
            ],
          ),
        ),
      ),
    );
  }
 
  _changeText() {
    setState(() {
      if (msg.startsWith('F')) {
        msg = 'I have learned FlutterRaised example ';
      } else {
        msg = 'Flutter RaisedButton example';
      }
    });
  }
}
__________________________________________________________________________________

For More Info About Flutter :

Check Out Live Flutter Web Demo: http://nikhil.cf/
Follow us on Github Account https://github.com/nikhil269

Tags: Flutter RaiseButton Flutterapp








0 Comments
Login to comment.
Recent Comments












© 2018 - Fluttercentral | Email to me - seven.srikanth@gmail.com