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?
you can simply use print('whatever you want to print') same as console. log() in javascript.
To toggle the display of construction lines (debugPaintSizeEnabled), press "p". (this is the easiest option!) Show activity on this post. type Flutter: Toggle Debug Painting and click on it.
After setting the flag debugPaintSizeEnabled to true, the app the does not display the layout grids while running the app in debug mode. After setting the flag debugPaintSizeEnabled to true, the app the does not display the layout grids while running the app in debug mode. Skip to content Sign up Why GitHub? Features → Mobile →
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
The portal is full of cool resources from Flutter like Flutter Widget Guide , Flutter Projects , Code libs and etc. Flutter App Design Flutter App Development Flutter Design Flutter Development Flutter Mobile Design Flutter Mobile Development Flutter Release APK Release APK Release APK Is Not Working Release APK Is Not Working Properly
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.
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;
It's not necessary import anything in VSCode, just:
Flutter: Toggle Debug Painting
and click on it: example.In the terminal press 'p'
To toggle the display of construction lines (debugPaintSizeEnabled), press "p".
(this is the easiest option!)
I think you need import 'package:flutter/rendering.dart';
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With