Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 参数不匹配的闭包调用:函数'_myListView.functionOne';_Flutter_Dart - Fatal编程技术网

Flutter 参数不匹配的闭包调用:函数'_myListView.functionOne';

Flutter 参数不匹配的闭包调用:函数'_myListView.functionOne';,flutter,dart,Flutter,Dart,我不知道为什么控制台框中会出现此错误。一切看起来都很好,但下面仍然显示了这一点 参数不匹配的闭包调用:函数“\u myListView.functionOne” 接收方:闭包:()=>Null 尝试调用:_myListView.functionOne(“SliverMultiboxAdapterElement”的实例) 找到:_myListView.functionOne()=>Null 这是我的LISTVIEW代码 import 'package:flutter/material.dart'

我不知道为什么控制台框中会出现此错误。一切看起来都很好,但下面仍然显示了这一点

参数不匹配的闭包调用:函数“\u myListView.functionOne” 接收方:闭包:()=>Null 尝试调用:_myListView.functionOne(“SliverMultiboxAdapterElement”的实例) 找到:_myListView.functionOne()=>Null

这是我的LISTVIEW代码


import 'package:flutter/material.dart';

import 'package:linear_gradient/linear_gradient.dart';
import 'package:gradient_text/gradient_text.dart';
import 'package:apple_beauty/cdetails.dart';



Gradient gradient = LinearGradient(
    colors: [Colors.teal, Colors.deepOrange, Colors.pink]);


class RamList extends StatefulWidget {
  @override
  _RamListState createState() => _RamListState();
}

class _RamListState extends State<RamList> {
  @override
  Widget build(BuildContext context) {
    return _myListView(context);
  }
}




Widget _myListView(BuildContext context) {
  final titles = [
    '1st',
    '2nd',
    '3rd',
    '4th',
    '5th',
                ];

  final numbers = [
    '1 ',
    '2 ',
    '3 ',
    '4 ',
    '5 ',



  ];

  functionOne() {
    Navigator.push(
        context, new MaterialPageRoute(builder: (context) =>  RamOne()));
  }

  functionTwo() {
    Navigator.push(context, MaterialPageRoute(builder: (context) => RamTwo()));
  }

  functionThree() {
    Navigator.push(
        context, MaterialPageRoute(builder: (context) => RamThree()));
  }

  functionFour() {
    Navigator.push(context, MaterialPageRoute(builder: (context) => RamFour()));
  }




  functionFive(BuildContext context)=>_onAlertButtonPressed1(context);





  final List<Function> onTaps = [
    functionOne,
    functionTwo,
    functionThree,
    functionFour,
    functionFive,

  ];

  return ListView.builder(

      itemCount: titles.length,
      itemBuilder: (context, index) {
        return Card(
            elevation: 50,
            child: InkWell(


              splashColor: Colors.green,
              highlightColor: Colors.red,
              child: Row(
                children: <Widget>[


                  Container(


                    height: 100.0,
                    width:50.0,

                    decoration: BoxDecoration(
                        gradient:LinearGradientStyle.linearGradient(
                            orientation:LinearGradientStyle.ORIENTATION_HORIZONTAL,
                            gradientType: LinearGradientStyle.GRADIENT_TYPE_AMIN
                        )
                    ),),

                  Container(
                      margin: EdgeInsets.all(10),
                      child: Text(
                        numbers[index],
                      )),


                  Flexible(child:  Container(
                    margin: EdgeInsets.all(10),
                    child: GradientText((titles[index]),
                      gradient:gradient,

                      style:TextStyle(fontSize:20.0,fontWeight:FontWeight.bold, ),
                    ),
                    //Text(titles[index]),
                  ))
                ],
              ),
              onTap: () => onTaps[index](context),
            ));
      });


}

_onAlertButtonPressed1(context) {
  AlertDialog alert = AlertDialog(
    title: Text('Coming soon'),
    content: Text("This link will be available in future updates"),
    actions: [

    ],
  );


  showDialog(
    context: context,
    builder: (BuildContext context) {
      return alert;
    },
  );
}


import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
//import 'package:html/dom.dart' as dom;
import 'package:gradient_app_bar/gradient_app_bar.dart';

class RamOne extends StatefulWidget {
  RamOne({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _RamOneState createState() => new _RamOneState();
}

class _RamOneState extends State<RamOne> {
  @override
  Widget build(BuildContext context) {
    return  Scaffold(
        appBar:   GradientAppBar(
            gradient: LinearGradient(
                colors: [Colors.green, Colors.greenAccent]),
          title:  Text('Overview'),
        ),
        body: new Center(
          child: SingleChildScrollView(
            child: Html(

              data: """ <h1>1st page</h1>


  """,

            ),
          ),
        ));
  }}


class RamTwo extends StatefulWidget {
  RamTwo({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _RamTwoState createState() => new _RamTwoState();
}

class _RamTwoState extends State<RamTwo> {
  @override
  Widget build(BuildContext context) {
    return  Scaffold(
        appBar:   GradientAppBar(
          gradient: LinearGradient(
              colors: [Colors.green, Colors.greenAccent]),
          title:  Text('Nutritional Value'),
        ),
        body: new Center(
          child: SingleChildScrollView(
            child: Html(
              data: """
<h1>1st page</h1>""",

            ),
          ),
        ));
  }}


class RamThree extends StatefulWidget {
  RamThree({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _RamThreeState createState() => new _RamThreeState();
}

class _RamThreeState extends State<RamThree> {
  @override
  Widget build(BuildContext context) {
    return  Scaffold(
        appBar:   GradientAppBar(
          gradient: LinearGradient(
              colors: [Colors.green, Colors.greenAccent]),
          title:  Text('Types of apple'),
        ),
        body: new Center(
          child: SingleChildScrollView(
            child: Html(
              data: """
              <h1>1st page</h1>
  """,

            ),
          ),
        ));
  }}


class RamFour extends StatefulWidget {
  RamFour({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _RamFourState createState() => new _RamFourState();
}

class _RamFourState extends State<RamFour> {
  @override
  Widget build(BuildContext context) {
    return  Scaffold(
        appBar:   GradientAppBar(
          gradient: LinearGradient(
              colors: [Colors.green, Colors.greenAccent]),
          title:  Text('Good for Neuron'),
        ),
        body: new Center(
          child: SingleChildScrollView(
            child: Html(
              data: """
     <h1>1st page</h1>
  """,

            ),
          ),
        ));
  }}





  }}



进口“包装:颤振/材料.省道”;
导入“包装:线性梯度/线性梯度.省道”;
导入“package:gradient_text/gradient_text.dart”;
进口“包装:apple_beauty/cdetails.dart”;
梯度=线性梯度(
颜色:[colors.teal,colors.deepOrange,colors.pink]);
类RamList扩展了StatefulWidget{
@凌驾
_RamListState createState()=>\u RamListState();
}
类_RamListState扩展了状态{
@凌驾
小部件构建(构建上下文){
返回myListView(上下文);
}
}
Widget\u myListView(构建上下文){
最终标题=[
“第一”,
"第二",,
"第三",,
"第四",,
“5号”,
];
最终数字=[
'1 ',
'2 ',
'3 ',
'4 ',
'5 ',
];
函数一(){
导航器。推(
context,newmaterialpage(builder:(context)=>RamOne());
}
函数二(){
push(context,MaterialPageRoute(builder:(context)=>ramtwoo());
}
函数三(){
导航器。推(
context,MaterialPageRoute(builder:(context)=>RamThree());
}
函数四(){
push(context,MaterialPageRoute(builder:(context)=>RamFour());
}
functionFive(构建上下文)=>\u onAlertButtonPressed1(上下文);
最终列表onTaps=[
功能一,
职能二,,
第三,
职能四,,
职能五,,
];
返回ListView.builder(
itemCount:titles.length,
itemBuilder:(上下文,索引){
回程卡(
标高:50,
孩子:InkWell(
颜色:颜色。绿色,
highlightColor:Colors.red,
孩子:排(
儿童:[
容器(
高度:100.0,
宽度:50.0,
装饰:盒子装饰(
渐变:LinearGradientStyle.linearGradient(
方向:LinearGradientStyle.orientation\u水平,
gradientType:LinearGradientStyle.GRADIENT\u TYPE\u AMIN
)
),),
容器(
保证金:所有(10),
子:文本(
数字[索引],
)),
柔性(子:容器)(
保证金:所有(10),
子项:GradientText((标题[索引]),
梯度:梯度,
样式:TextStyle(fontSize:20.0,fontWeight:fontWeight.bold,),
),
//正文(标题[索引]),
))
],
),
onTap:()=>onTaps[index](上下文),
));
});
}
_onAlertButtonPressed1(上下文){
AlertDialog alert=AlertDialog(
标题:文本(“即将发布”),
内容:文本(“此链接将在将来的更新中提供”),
行动:[
],
);
显示对话框(
上下文:上下文,
生成器:(BuildContext上下文){
返回警报;
},
);
}
这是我的LISTVIEW导航详细信息代码


import 'package:flutter/material.dart';

import 'package:linear_gradient/linear_gradient.dart';
import 'package:gradient_text/gradient_text.dart';
import 'package:apple_beauty/cdetails.dart';



Gradient gradient = LinearGradient(
    colors: [Colors.teal, Colors.deepOrange, Colors.pink]);


class RamList extends StatefulWidget {
  @override
  _RamListState createState() => _RamListState();
}

class _RamListState extends State<RamList> {
  @override
  Widget build(BuildContext context) {
    return _myListView(context);
  }
}




Widget _myListView(BuildContext context) {
  final titles = [
    '1st',
    '2nd',
    '3rd',
    '4th',
    '5th',
                ];

  final numbers = [
    '1 ',
    '2 ',
    '3 ',
    '4 ',
    '5 ',



  ];

  functionOne() {
    Navigator.push(
        context, new MaterialPageRoute(builder: (context) =>  RamOne()));
  }

  functionTwo() {
    Navigator.push(context, MaterialPageRoute(builder: (context) => RamTwo()));
  }

  functionThree() {
    Navigator.push(
        context, MaterialPageRoute(builder: (context) => RamThree()));
  }

  functionFour() {
    Navigator.push(context, MaterialPageRoute(builder: (context) => RamFour()));
  }




  functionFive(BuildContext context)=>_onAlertButtonPressed1(context);





  final List<Function> onTaps = [
    functionOne,
    functionTwo,
    functionThree,
    functionFour,
    functionFive,

  ];

  return ListView.builder(

      itemCount: titles.length,
      itemBuilder: (context, index) {
        return Card(
            elevation: 50,
            child: InkWell(


              splashColor: Colors.green,
              highlightColor: Colors.red,
              child: Row(
                children: <Widget>[


                  Container(


                    height: 100.0,
                    width:50.0,

                    decoration: BoxDecoration(
                        gradient:LinearGradientStyle.linearGradient(
                            orientation:LinearGradientStyle.ORIENTATION_HORIZONTAL,
                            gradientType: LinearGradientStyle.GRADIENT_TYPE_AMIN
                        )
                    ),),

                  Container(
                      margin: EdgeInsets.all(10),
                      child: Text(
                        numbers[index],
                      )),


                  Flexible(child:  Container(
                    margin: EdgeInsets.all(10),
                    child: GradientText((titles[index]),
                      gradient:gradient,

                      style:TextStyle(fontSize:20.0,fontWeight:FontWeight.bold, ),
                    ),
                    //Text(titles[index]),
                  ))
                ],
              ),
              onTap: () => onTaps[index](context),
            ));
      });


}

_onAlertButtonPressed1(context) {
  AlertDialog alert = AlertDialog(
    title: Text('Coming soon'),
    content: Text("This link will be available in future updates"),
    actions: [

    ],
  );


  showDialog(
    context: context,
    builder: (BuildContext context) {
      return alert;
    },
  );
}


import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
//import 'package:html/dom.dart' as dom;
import 'package:gradient_app_bar/gradient_app_bar.dart';

class RamOne extends StatefulWidget {
  RamOne({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _RamOneState createState() => new _RamOneState();
}

class _RamOneState extends State<RamOne> {
  @override
  Widget build(BuildContext context) {
    return  Scaffold(
        appBar:   GradientAppBar(
            gradient: LinearGradient(
                colors: [Colors.green, Colors.greenAccent]),
          title:  Text('Overview'),
        ),
        body: new Center(
          child: SingleChildScrollView(
            child: Html(

              data: """ <h1>1st page</h1>


  """,

            ),
          ),
        ));
  }}


class RamTwo extends StatefulWidget {
  RamTwo({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _RamTwoState createState() => new _RamTwoState();
}

class _RamTwoState extends State<RamTwo> {
  @override
  Widget build(BuildContext context) {
    return  Scaffold(
        appBar:   GradientAppBar(
          gradient: LinearGradient(
              colors: [Colors.green, Colors.greenAccent]),
          title:  Text('Nutritional Value'),
        ),
        body: new Center(
          child: SingleChildScrollView(
            child: Html(
              data: """
<h1>1st page</h1>""",

            ),
          ),
        ));
  }}


class RamThree extends StatefulWidget {
  RamThree({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _RamThreeState createState() => new _RamThreeState();
}

class _RamThreeState extends State<RamThree> {
  @override
  Widget build(BuildContext context) {
    return  Scaffold(
        appBar:   GradientAppBar(
          gradient: LinearGradient(
              colors: [Colors.green, Colors.greenAccent]),
          title:  Text('Types of apple'),
        ),
        body: new Center(
          child: SingleChildScrollView(
            child: Html(
              data: """
              <h1>1st page</h1>
  """,

            ),
          ),
        ));
  }}


class RamFour extends StatefulWidget {
  RamFour({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _RamFourState createState() => new _RamFourState();
}

class _RamFourState extends State<RamFour> {
  @override
  Widget build(BuildContext context) {
    return  Scaffold(
        appBar:   GradientAppBar(
          gradient: LinearGradient(
              colors: [Colors.green, Colors.greenAccent]),
          title:  Text('Good for Neuron'),
        ),
        body: new Center(
          child: SingleChildScrollView(
            child: Html(
              data: """
     <h1>1st page</h1>
  """,

            ),
          ),
        ));
  }}





  }}


导入“包装:颤振/材料.省道”;
导入“package:flatter_html/flatter_html.dart”;
//导入“package:html/dom.dart”作为dom;
导入“包:渐变条/渐变条.省道”;
类RamOne扩展了StatefulWidget{
RamOne({Key-Key,this.title}):super(Key:Key);
最后的字符串标题;
@凌驾
_RamOneState createState()=>new_RamOneState();
}
类RamOneState扩展了状态{
@凌驾
小部件构建(构建上下文){
返回脚手架(
appBar:GradientAppBar(
梯度:线性梯度(
颜色:[颜色。绿色,颜色。绿色口音],
标题:文本(“概述”),
),
正文:新中心(
子:SingleChildScrollView(
孩子:Html(
数据:“”第1页
""",
),
),
));
}}
类RamTwo扩展了StatefulWidget{
RamTwo({Key-Key,this.title}):super(Key:Key);
最后的字符串标题;
@凌驾
_RamTwoState createState()=>new_RamTwoState();
}
类_RamTwoState扩展了状态{
@凌驾
小部件构建(构建上下文){
返回脚手架(
appBar:GradientAppBar(
梯度:线性梯度(
颜色:[颜色。绿色,颜色。绿色口音],
标题:文本(“营养价值”),
),
正文:新中心(
子:SingleChildScrollView(
孩子:Html(
数据:“”
第1页“”,
),
),
));
}}
类RamThree扩展了StatefulWidget{
RamThree({Key-Key,this.title}):super(Key:Key);
最后的字符串标题;
@凌驾
_RamThreeState createState()=>new_RamThreeState();
}
类RamThreeState扩展了状态{
@凌驾
小部件构建(构建上下文){
返回脚手架(
appBar:GradientAppBar(
梯度:线性梯度(
颜色:[颜色。绿色,颜色。绿色口音],
标题:文本(“苹果类型”),
),
正文:新中心(
子:SingleChildScrollView(
孩子:Html(
数据:“”
第一页
""",
),
),
));
}}
类RamFour扩展了StatefulWidget{
RamFour({Key-Key,this.title}):super(Key:Key);
最后的字符串标题;
@凌驾
_RamFourState createState()=>new_RamFourState();
}
类_RamFourState扩展了St