text stringlengths 1 474 |
|---|
), |
); |
} |
class AppHome extends StatelessWidget { |
const AppHome({super.key}); |
@override |
Widget build(BuildContext context) { |
return Material( |
child: Center( |
child: Semantics( |
button: true, |
enabled: true, |
label: 'Clickable text here!', |
child: GestureDetector( |
onTap: () { |
debugDumpSemanticsTree(); |
if (kDebugMode) { |
print('Clicked!'); |
} |
}, |
child: const Text('Click Me!', style: TextStyle(fontSize: 56))), |
), |
), |
); |
} |
}<code_end> |
<topic_end> |
<topic_start> |
Print event timings |
If you want to find out where your events happen relative to the frame’s |
begin and end, you can set prints to log these events. |
To print the beginning and end of the frames to the console, |
toggle the debugPrintBeginFrameBanner |
and the debugPrintEndFrameBanner.The print frame banner log for Example 1To print the call stack causing the current frame to be scheduled, |
use the debugPrintScheduleFrameStacks flag.<topic_end> |
<topic_start> |
Debug layout issues |
To debug a layout problem using a GUI, set |
debugPaintSizeEnabled to true. |
This flag can be found in the rendering library. |
You can enable it at any time and affects all painting while true. |
Consider adding it to the top of your void main() entry point.<topic_end> |
<topic_start>Example 9 |
See an example in the following code: |
<code_start>//add import to rendering library |
import 'package:flutter/rendering.dart'; |
void main() { |
debugPaintSizeEnabled = true; |
runApp(const MyApp()); |
}<code_end> |
When enabled, Flutter displays the following changes to your app:The debugPaintBaselinesEnabled flag |
does something similar but for objects with baselines. |
The app displays the baseline for alphabetic characters in bright green |
and the baseline for ideographic characters in orange. |
Alphabetic characters “sit” on the alphabetic baseline, |
but that baseline “cuts” through the bottom of CJK characters. |
Flutter positions the ideographic baseline at the very bottom of the text line.The debugPaintPointersEnabled flag turns on a special mode that |
highlights any objects that you tap in teal. |
This can help you determine if an object fails to hit test. |
This might happen if the object falls outside the bounds of its parent |
and thus not considered for hit testing in the first place.If you’re trying to debug compositor layers, consider using the following flags.Use the debugPaintLayerBordersEnabled flag to find the boundaries |
of each layer. This flag results in outlining each layer’s bounds in orange.Use the debugRepaintRainbowEnabled flag to display a repainted layer. |
Whenever a layer repaints, it overlays with a rotating set of colors.Any function or method in the Flutter framework that starts with |
debug... only works in debug mode.<topic_end> |
<topic_start> |
Debug animation issues |
info Note |
To debug animations with the least effort, slow them down. |
To slow down the animation, |
click Slow Animations in DevTools’ Inspector view. |
This reduces the animation to 20% speed. |
If you want more control over the amount of slowness, |
use the following instructions.Set the timeDilation variable (from the scheduler |
library) to a number greater than 1.0, for instance, 50.0. |
It’s best to only set this once on app startup. If you |
change it on the fly, especially if you reduce it while |
animations are running, it’s possible that the framework |
will observe time going backwards, which will probably |
result in asserts and generally interfere with your efforts.<topic_end> |
<topic_start> |
Debug performance issues |
info Note |
You can achieve similar results to some of these debug |
flags using DevTools. Some of the debug flags provide little benefit. |
If you find a flag with functionality you would like to add to DevTools, |
file an issue.Flutter provides a wide variety of top-level properties and functions |
to help you debug your app at various points along the |
development cycle. |
To use these features, compile your app in debug mode.The following list highlights some of flags and one function from the |
rendering library for debugging performance issues.To set these flags either:You can generate stack traces on demand as well. |
To print your own stack traces, add the debugPrintStack() |
function to your app.<topic_end> |
<topic_start> |
Trace Dart code performance |
info Note |
You can use the DevTools Timeline events tab to perform traces. |
You can also import and export trace files into the Timeline view, |
but only files generated by DevTools.To perform custom performance traces and |
measure wall or CPU time of arbitrary segments of Dart code |
like Android does with systrace, |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.