Reputation: 1732
I just began learning flutter and built the sample app present in Building Layout tutorial.
In the source code it's suggested to un-comment two lines, to see the visual debug lines, but so far no luck.
import 'package:flutter/material.dart';
// Uncomment lines 7 and 10 to view the visual layout at runtime.
//import 'package:flutter/rendering.dart' show debugPaintSizeEnabled;
void main() {
//debugPaintSizeEnabled = true;
runApp(new MyApp());
}
What I have tried?
debugPaintPointersEnabled =
debugPaintBaselinesEnabled =
debugPaintLayerBordersEnabled =
debugRepaintRainbowEnabled = true;
, which I read from Docs. They worked fine.
My Setup?
Question: How to make the visual debugger work?
Upvotes: 31
Views: 11860
Reputation: 96
I had the same issue, wasn't able to see any debug information.
Fixed it by running in debug mode instead of profile or release. Maybe this will help someone.
Upvotes: 0
Reputation: 815
I had exactly the same problem and the only solution i found, is to toggle debug painting from VSCode command palette.
Flutter: Toggle Debug Painting
You can also make it works using the rendering library.
First you need to import it
import 'package:flutter/rendering.dart';
Then, set debugPaintSizeEnabled to true in the main method of your application or in a widget's build method
void main() {
debugPaintSizeEnabled=true;
runApp(MyApp());
}
You need to fully restart your application to apply effects
Here's the official documentation.
Upvotes: 70
Reputation: 106
It's not necessary import anything in VSCode, just:
Flutter: Toggle Debug Painting
and click on it: example.Upvotes: 8
Reputation: 301
void main() { debugPaintSizeEnabled = true; runApp(new MyApp()); }
Open command palette by CTRL + SHIFT + P (for window),
Upvotes: 0
Reputation: 24097
In the terminal press 'p'
To toggle the display of construction lines (debugPaintSizeEnabled), press "p".
(this is the easiest option!)
Upvotes: 3
Reputation: 435
UPDATE
The following steps work on both android device and android virtual device if you are working with ANDROID STUDIO. It works only on Android virtual device if you are working wih VSCode
I was following the same tutorial recently to learn all about the layout elements in Flutter. To enable visual layout at runtime, what I did was quite straightforward -
I added import 'package:flutter/rendering.dart' show debugPaintSizeEnabled; at the top of my main.dart file
I added debugPaintSizeEnabled = true; to my main() method
void main() {
debugPaintSizeEnabled = true;
runApp(new MyApp());
}
I performed a full restart of my app to reflect all the changes. It doesn't reflect changes if you perform a hot reload.
Hope this helps.
Upvotes: 3
Reputation: 681
Add import statements :
import 'dart:developer';
import 'package:flutter/rendering.dart';
Then in the build add the debugPaintSizeEnabled=true; like :
Widget build(BuildContext context) {
debugPaintSizeEnabled=true;
Upvotes: 13