A text button is a zero elevation button that commonly contains a text label in the center. It is a Material Design button.
A TextButton
class is used to create a text button. By default, text button do not have background color and borders. The style
parameter can be used to provide the style of button.
import 'package:flutter/material.dart';
void main() => runApp(const MaterialApp(home: MyApp()));
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Text button')),
body: Center(
child: TextButton(
style: TextButton.styleFrom(
backgroundColor: Colors.black12,
foregroundColor: Colors.indigo,
),
onPressed: () {
print('Pressed');
},
child: const Text('Add'),
)));
}
}
Leave a Comment
Cancel reply