londonappbrewery / bmi-calculator-flutter

Learn to Code While Building Apps - The Complete Flutter Development Bootcamp
https://www.appbrewery.co
192 stars 838 forks source link

primaryColor: Doesnt Work #37

Open GhulamRasool513 opened 1 year ago

rahulshinders commented 1 year ago

Use primarySwatch instead like - theme: ThemeData( primarySwatch: Colors.red, ),

sazzad700 commented 1 year ago

theme: ThemeData( colorScheme: ColorScheme.fromSwatch().copyWith( primary: Colors.red, secondary: Colors.pink )

Prince-GH commented 7 months ago
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,
          ),
        ),
      ),
    );
  }
}