I am attempting use TileList passed into ListView.Builder but receive the error: error: The argument type '(BuildContext, int, Items) → Card' can't be assigned to the parameter type '(BuildContext, int) → Widget'. (argument_type_not_assignable).
I have defined _makeCard and _makeTyle as a widget with no success.
import 'package:flutter/material.dart';
import 'package:flutter/painting.dart';
import 'package:app_settings/app_settings.dart';
import 'package:coffee/models/settings_items.dart';
class Selections extends StatefulWidget {
@override
State<Selections> createState() => _Selections();
final List<String> menu;
Selections(this.menu);
}
class _Selections extends State<Selections> {
List items;
@override
void initState() {
items = getItems();
super.initState();
}
Card _makeCard(BuildContext context, int index, Items item) {
return Card(
elevation: 8.0,
margin: new EdgeInsets.symmetric(horizontal: 10.0, vertical: 6.0),
child: Container(
decoration: BoxDecoration(color: Color.fromRGBO(64, 75, 96, .0)),
child: _buildMenu(context, index, item),
),
);
}
ListTile _buildMenu(BuildContext context, int index, Items item) {
return ListTile(
contentPadding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0),
leading: Container(
padding: EdgeInsets.only(right: 12.0),
decoration: new BoxDecoration(
border: new Border(
right: new BorderSide(width: 1.0, color: Colors.blue),
),
),
child: Icon(
Icons.location_on,
color: Colors.redAccent,
),
),
title: Text(
item.title,
style: TextStyle(color: Colors.blue, fontWeight: FontWeight.bold),
),
onTap: () {
AppSettings.openLocationSettings();
},
);
}
@override
Widget build(BuildContext context) {
return Container(
child: ListView.builder(
itemBuilder: _makeCard,
itemCount: 2,
scrollDirection: Axis.vertical,
shrinkWrap: true),
);
}
List getItems() {
return [
Items(
title: "Turn on Location Services!"
),
Items(
title: "My Profile"
),
];
}
}
Two ListTIles will be displayed: one with the text "Turn on Location Services" and the other with "My Profile".