Articles → FLUTTER AND DART → RaisedButton widget in flutter

RaisedButton widget in flutter






Purpose





Example


import 'package:flutter/material.dart';

void main()
{
  runApp(MyApp());
}

class MyApp extends StatelessWidget
{
  Widget build(BuildContext context) {
    return MaterialApp(home:Scaffold(
      appBar: AppBar(title: Text("my app bar")),
    body: RaisedButton(
    onPressed: null,
    child: Text(
    'Disabled Button'
    ),
    ),
    )
    );
  }
}



Output



Click to Enlarge


OnPressed event






import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
          appBar: AppBar(),
      body: RaisedButton(
        onPressed: () {
          print("Raised Button Clicked");
        },
        child: Text('Button'),
      ),
    ));
  }
}




import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {

  printCommand()
  {
    print("Raised Button Clicked");
  }

  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
          appBar: AppBar(),
      body: RaisedButton(
        onPressed: printCommand,
        child: Text('Button'),
      ),
    ));
  }
}




import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
      appBar: AppBar(),
      body: RaisedButton(
        onPressed: () => print("Raised"),
        child: Text('Button'),
      ),
    ));
  }
}





Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, August 20, 2019

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250