Get Button Name On Button Click
Complete Code For Get Button Name On Button Click In Flutter
main.dart
import 'dart:io'; import 'package:flutter/material.dart'; void main(){ runApp(MyApp()); } class MyApp extends StatelessWidget{ @override Widget build(BuildContext context) { // TODO: implement build return MaterialApp( debugShowCheckedModeBanner: false, home: MyHomePage(), ); } } class MyHomePage extends StatefulWidget { @override _MyHomePageState createState() => new _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { String _buttonName = ""; _onPressed() { setState(() { _buttonName = "A Button Name"; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.amber, title: Text('Button Name'), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: <Widget>[ Text("Button Name: $_buttonName"), RaisedButton( onPressed: _onPressed, child: Text('A Button Name'), color: Colors.amber, ) ], ), )); } }