Skip to content

Instantly share code, notes, and snippets.

@fladago
Last active August 20, 2021 10:31
Show Gist options
  • Save fladago/54f82b7877b3907f3226dfc92cb15374 to your computer and use it in GitHub Desktop.
Save fladago/54f82b7877b3907f3226dfc92cb15374 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'New buttons in Flutter',
theme: ThemeData(
primarySwatch: Colors.indigo,
),
home: const SignInPage(),
);
}
}
class SignInPage extends StatelessWidget {
const SignInPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('New buttons in Flutter'),
centerTitle: true,
elevation: 2.0,
),
body: _buildContent(),
);
}
Widget _buildContent() {
return Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () {},
child: const Text('ElevatedButton'),
style: ElevatedButton.styleFrom(
primary: Colors.yellow, //background button color
onPrimary: Colors.green, //text color
onSurface: Colors.grey,
padding: const EdgeInsets.all(10),
),
),
const SizedBox(height: 10.0),
TextButton(
onPressed: () {},
child: const Text('TextButton'),
style: TextButton.styleFrom(
backgroundColor: Colors.yellow,
primary: Colors.deepOrangeAccent,
padding: const EdgeInsets.all(10),
),
),
const SizedBox(height: 10.0),
OutlinedButton(
onPressed: () {},
child: const Text('OutlinedButton'),
style: OutlinedButton.styleFrom(
primary: Colors.deepOrangeAccent,
side: const BorderSide(
color: Colors.red,
width: 2.0,
),
),
),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment