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


Picture showing the output of the RaisedButton widget in flutter
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'),
        ),
      ));
  }
}




Picture showing the output written on the logcat window
Click to Enlarge


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

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250