在我的 Flutter 项目中,除了 main.dart 之外,我还有第二个 dart 文件 (helpers.dart),我在其中尝试使用 debugPrint()
函数:
debugPrint(someString);
我收到以下消息:
The function 'debugPrint' isn't defined. Try importing the library that defines 'debugPrint', correcting the name to the name of an existing function, or defining a function named 'debugPrint'.
Flutter 官方documentation说明 debugPrint 函数是 Flutter 基础库的一部分。但是 import 'package:flutter/foundation.dart';
并没有解决问题。那么我必须导入哪个库/包?
最佳答案
导入素材包解决问题:
import 'package:flutter/material.dart';
关于flutter - 找不到函数 debugPrint(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63737178/