flutter 未为类型“problemModel”定义方法“toLowerCase”

yvfmudvl  于 2023-06-24  发布在  Flutter
关注(0)|答案(1)|浏览(119)

未为类型“problemModel”定义方法“toLowerCase”。尝试将名称更正为现有方法的名称,或定义名为“toLowerCase”的方法。

class _view_problemState extends State<view_problem> {
  List<problemModel> problemlist = [];
  StreamController _streamController = StreamController();
  Future getAllProblem() async {
    problemlist = await problemcontrollers().getProblem();
    _streamController.sink.add(problemlist);
  }

  @override
  void initState() {
     // TODO: implement initState
    Timer.periodic(Duration(seconds: 1), (timer) {
      getAllProblem();
    });
    super.initState();
  }

  void _filterSearch(String query) {
    List<problemModel> duplicateItems = [];
    setState(() {
      problemlist = duplicateItems
          .where((problemlist) =>
              problemlist.toLowerCase().contains(query.toLowerCase()))
          .toList();
    });
  }
k4aesqcs

k4aesqcs1#

toLowerCase()仅用于String。你的problemlist不是String,而是problemModel对象。
阅读更多信息https://api.flutter.dev/flutter/dart-core/String/toLowerCase.html

相关问题