Open GhulamRasool513 opened 1 year ago
theme: ThemeData( colorScheme: ColorScheme.fromSwatch().copyWith( primary: Colors.red, secondary: Colors.pink )
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
// Define the theme
theme: ThemeData(
// Define the primary color
primaryColor: Colors.blue,
// Optionally, you can also define other theme properties
// such as accentColor, scaffoldBackgroundColor, etc.
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
// Use the primary color for the app bar
backgroundColor: Theme.of(context).primaryColor,
title: Text('Flutter App with Primary Color'),
),
body: Center(
child: Text(
'Hello, Flutter!',
style: TextStyle(
// Use the primary color for text
color: Theme.of(context).primaryColor,
fontSize: 24.0,
fontWeight: FontWeight.bold,
),
),
),
);
}
}
Use primarySwatch instead like - theme: ThemeData( primarySwatch: Colors.red, ),