I’m a little bit confused about primarySwatch and primaryColor, and their usage.
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
final appName = 'Custom Themes';
return MaterialApp(
title: appName,
theme: ThemeData(
// Define the default brightness and colors.
brightness: Brightness.dark,
primarySwatch: Colors.green,
primaryColor: Colors.red[800],
accentColor: Colors.orange[600],
),
home: MyHomePage(
title: appName,
),
);
}
}
class MyHomePage extends StatelessWidget {
final String title;
MyHomePage({Key? key, required this.title}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(title),
),
body: Center(
child: Column(children: [
Container(
color: Theme.of(context).accentColor,
child: Text('Text with a background color'),
),
ElevatedButton(
onPressed: () {},
child: Text('Anmelden'),
),
]),
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: Icon(Icons.add),
),
);
}
}