'I am trying to provide a single uniform theme to the whole app, but it is giving error
I am trying to apply an uniform theme of background color to my app but it is giving this error and I am not able to resolve it. This is the link to the error image.
Solution 1:[1]
Try adding scaffold to the container on the second page
import 'package:flutter/material.dart';
import 'package:flutter/services.dart'
void main() => runApp(MaterialApp(
theme: ThemeData( brightness: Brightness.light,
primaryColor: Colors.white,
scaffoldBackgroundColor: Colors.white,),
home: Scaffold(
backgroundColor: Colors.white,
body: Application(),
),
));
class Application extends StatelessWidget {
const Application({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(body:
Container(
),
Solution 2:[2]
Remove const from material app
MaterialApp(
home: MyAppBarWidget(),
theme: ThemeData(brightness: Brightness.dark, primaryColor: Colors.white),
);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Bhavik Dalal |
| Solution 2 | keyur |
