Set OnClick onPress event on Raised Button in Flutter Android iOS

Raised Button is our main widget to create buttons in Flutter. Raised button has its own onClick method known as onPressed. We can pass any function here in onPressed event and that particular function will called on button onPress event. We cannot set onPressed empty we should have pass something here like a function our inline function body code. So in this tutorial we would Set OnClick onPress event on Raised Button in Flutter Android iOS.

Contents in this project Set OnClick onPress event on Raised Button in Flutter Android iOS App Example Tutorial:

1. Import material.dart package in your app’s main.dart file.

2. Call our main MyApp class using void main runApp method.

3. Create a class named as MyApp extends with StatelessWidget. This is our main view class.

4. Create a function named as sampleFunction() in your MyApp class. We would call this function on button onPress event. We are printing a simple message on Command Prompt Terminal screen using print() method of dart.

5. Create a Raised Button Widget in Column widget as children.

  • onPressed : Call here the function here which we would created before.

6. Complete source code for main.dart file:

Screenshot:

Set OnClick onPress event on Raised Button in Flutter Android iOS

2 Comments

  1. nice examples bro… I use these techniques for own work…

Leave a Reply

Your email address will not be published.