我不知道为什么此错误会出现在控制台框中。一切看起来都很好,但下面仍然出现
带有不匹配参数的闭包调用:函数'_myListView.functionOne' 接收方:闭包:()=>空 尝试调用:_myListView.functionOne(“ SliverMultiBoxAdaptorElement”的实例) 找到:_myListView.functionOne()=>空
这是我用于列表查看的代码
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;
},);
}
这是我用于LISTVIEW导航详细信息的代码
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,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,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,title: Text('Good for Neuron'),body: new Center(
child: SingleChildScrollView(
child: Html(
data: """
<h1>1st page</h1>
""",));
}}
}}