When I wrote this code in Android Studio, that is what came up in my dart analysis toolbar: The code I wrote How do I prevent this?
Asked
Active
Viewed 292 times
0
-
You should start by watching the course – regenin Mar 09 '22 at 11:34
-
1Try posting code in text form instead of picture form – Junaid Khalid Mar 09 '22 at 11:36
-
Okay I'll take note of that – Gordon Atsunyo Jan 02 '23 at 23:11
3 Answers
3
You are missing a )
bracket add it before the semicolon .
This link explains the about positional and named arguments . And The process you are trying is not a good practice. You need to breakdown the widgets so that it becomes easier to maintain.
Try as follows:
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.blueGrey,
appBar: AppBar(
title: const Text('I am rich'),
backgroundColor: Colors.blueGrey[900],
),
body: Center(
child: Image.asset('images/diamond.png'),
),
),
);
}
}

Nabin Dhakal
- 1,949
- 3
- 20
- 48
3
Replace your MaterialApp
with this:
MaterialApp(
title: 'SaHomeDecor',
home: Scaffold(
backgroundColor: Colors.blueGrey,
appBar: AppBar(
title: Text('I am rich'),
backgroundColor: Colors.blueGrey[900],
),
body: Center(
child: Image.asset('images/diamond.png'),
),
),
);
If you are using AppBar
you have to give Scaffold.appBar
property like Scaffold(appBar:AppBar())
.
For the image you have to use Scaffold.body
property.

Mohit Ratanpara
- 49
- 5