why the appbar do not take the default colour in flutter

66 views Asked by At
import 'package:businesscard/cubits/get_weather_cubits/get_weather_cubit.dart';
import 'package:businesscard/cubits/get_weather_cubits/get_weather_states.dart';

import 'package:businesscard/screens/searchPage.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

import '../widgets/No_weather.dart';
import '../widgets/Weather_info.dart';

class HomeScreen extends StatelessWidget {
  const HomeScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return BlocProvider(
      create: (context) => GetWeatherCubit(),
      child: Builder(
        builder: (context) =>    MaterialApp(
          theme: ThemeData(
            primarySwatch: getWeatherColor(
                BlocProvider.of<GetWeatherCubit>(context)
                    .weather
                    ?.weatherstatus),
          ),
          debugShowCheckedModeBanner: false,
          home: const  HomeBage(),
        ),
      ),
    );
  }
}


enter image description here enter image description here here i need to change the theme of the app but no action acquire even the app bar did not have the default color

i tried to give the app bar a color it appears but the themes still do not change

1

There are 1 answers

0
Dhafin Rayhan On

You can specify the default app bar color in your ThemeData:

ThemeData(
  // ...
  appBarTheme: AppBarTheme(
    color: Colors.amber,
  ),
)

Or if what you want is the app bar style to behave just like in Material 2, then you can opt out of Material 3:

ThemeData(
  // ...
  useMaterial3: false,
)