简体   繁体   English

错误:没有为该类型定义方法“onChanged”

[英]error: The method 'onChanged' isn't defined for the type

Expanded(
            child: Container(
              padding: const EdgeInsets.symmetric(horizontal: 20.0),
              decoration: const BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.only(
                  topLeft: Radius.circular(20.0),
                  topRight: Radius.circular(20.0),
                ),
              ),
              child: ListView(
                children: [
                  const ListTile(
                    title: Text('This is a task.'),
                    trailing: Checkbox(
                        value: false, onChanged: (value) => onChanged()),
                  ),
                ],
              ),
            ),
          ),

//I tried to delete onChanged but it doesn't work says OnCgange required. //我试图删除 onChanged 但它不起作用说需要 OnCgange。 I am open any suggestion我愿意提出任何建议

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: SafeArea(
        child: Scaffold(
          body: Center(
            child: Expanded(
              child: Container(
                padding: const EdgeInsets.symmetric(horizontal: 20.0),
                decoration: const BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(20.0),
                    topRight: Radius.circular(20.0),
                  ),
                ),
                child: ListView(
                  children: [
                    ListTile(
                      title: Text('This is a task.'),
                      trailing: Checkbox(
                        value: false,
                        onChanged: (value) => null,
                      ),
                    )
                  ],
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}

remove the cont value in front of the Listtile and modify unchanged function去掉Listtile前面的cont值,修改不变的function

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:错误:没有为类型“_StoryPageState”定义方法“nextStory” - Error: error: The method 'nextStory' isn't defined for the type '_StoryPageState' Flutter 错误 - 未为该类型定义方法“setState” - Flutter Error - Method 'setState' isn't defined for the type Flutter 错误:没有为“ScreenUtil”类型定义方法“setContext” - Flutter Error: The method 'setContext' isn't defined for the type 'ScreenUtil' 错误:没有为“完成者”类型定义方法“setMapStyle” - error: The method 'setMapStyle' isn't defined for the type 'Completer' flutter 错误:没有为“Observable”类型定义方法“combineLatest4” - flutter error: The method 'combineLatest4' isn't defined for the type 'Observable' BloC 测试“未为类型‘对象’定义方法 xxx”错误 - BloC testing "The method xxx isn't defined for the type 'Object'" error 错误:未在 flutter 中为类型“FirebaseMessaging”定义方法“configure” - error: The method 'configure' isn't defined for the type 'FirebaseMessaging' in flutter 错误 Flutter - 未为类型“FirebaseMessaging”定义方法“configure” - Error Flutter - The method 'configure' isn't defined for the type 'FirebaseMessaging' Dart Flutter 未为类型“sqliteDaatabase”定义方法“getDatabasePath”。 错误 - Dart Flutter The method 'getDatabasePath' isn't defined for the type 'sqliteDaatabase'. Error Dart:没有为“Type”类型定义方法 - Dart: method isn't defined for the type 'Type'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM