FLUTTER Expected a key while parsing a block mapping
ERROR
I used this way for image
Running "flutter pub get" in flutter_app...
Error on line 39, column 10 of pubspec.yaml: Mapping values are not allowed here.
ERROR
I used this way for image
flutter: uses-material-design: true assets: - images/matka.jpgC:\src\flutter\bin\flutter.bat --no-color packages get
Running "flutter pub get" in flutter_app...
Error on line 39, column 10 of pubspec.yaml: Mapping values are not allowed here.
Did you miss a colon earlier?
╷
39 │ assets:
│ ^
╵
Error detected in pubspec.yaml:
Error on line 39, column 10: Mapping values are not allowed here.
╷
39 │ assets:
│ ^
╵
Error detected in pubspec.yaml:
Error on line 39, column 10: Mapping values are not allowed here.
Did you miss a colon earlier?
╷
39 │ assets:
│ ^
╵
Please correct the pubspec.yaml file at E:\flutterApps\flutter_app\pubspec.yaml
Process finished with exit code 1
SOLUTIONS:
COrrect way for image
SO FINAL CODE FOR IMAGE ASSETS:
╷
39 │ assets:
│ ^
╵
Please correct the pubspec.yaml file at E:\flutterApps\flutter_app\pubspec.yaml
Process finished with exit code 1
SOLUTIONS:
COrrect way for image
flutter: uses-material-design: true assets: - images/matka.jpgThe simple fix was to make sure my
assets section was aligned to my
uses-material-design section:
Now, when I click on “Get dependencies”,all is well.Simple issue to fix, but hopefully readingthis article will save you some time!
SO FINAL CODE FOR IMAGE ASSETS:
import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart' show debugPaintSizeEnabled; void main() { //debugPaintSizeEnabled = true; // Remove to suppress visual layout runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter layout demo', home: Scaffold( appBar: AppBar( title: Text('Flutter layout demo'), ), // Change to buildColumn() for the other column example
body: Center(child: buildRow()), ), ); } Widget buildRow() => // #docregion Row Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ Expanded( child: Image.asset('images/matka.jpg'),//matka.jpg is the name of my
image inserted in Images folder in flutter ), Expanded( flex: 2, child: Image.asset('images/matka.jpg'), ), Expanded( child: Image.asset('images/matka.jpg'), ), ], ); // #enddocregion Row Widget buildColumn() => // #docregion Column Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Image.asset('images/matka.jpg'), Image.asset('images/matka.jpg'), ], ); // #enddocregion Column}
Post a Comment
0Comments