Basics For Adding Click Event
Complete Code For Basics For Adding Click Event In Flutter
Main.dart
import 'package:flutter/material.dart'; void main() { runApp( MaterialApp( debugShowCheckedModeBanner: false, home: MyApp(), ) ); } class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { String name = "no name"; @override Widget build(BuildContext context) { return Scaffold( appBar: new AppBar( backgroundColor: Colors.amber, title: new Text("My App Title"), ), backgroundColor: Colors.white70, body: Container( child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text(name), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[ IconButton( icon: Icon(Icons.star), onPressed: () { setState(() { name = "Bajarangisoft.com"; }); }, ), GestureDetector( child: new Text("Gesture"), onTap: () { setState(() { name = "Welcome TO Bajarangisoft"; }); }, ), InkWell( child: Container( child: Text("InkWell"), ), onTap: changeName, ) ], ), ], ), ), ); } void changeName() { setState(() { name = "Your own codes"; }); } }