Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

primaryColor: Doesnt Work #37

Open
GhulamRasool513 opened this issue Dec 30, 2022 · 3 comments
Open

primaryColor: Doesnt Work #37

GhulamRasool513 opened this issue Dec 30, 2022 · 3 comments

Comments

@GhulamRasool513
Copy link

No description provided.

@rahulshinders
Copy link

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

@sazzad700
Copy link

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

@Prince-GH
Copy link

Prince-GH commented Apr 16, 2024

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,
          ),
        ),
      ),
    );
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants