I have a data Class - Business I have a List of Business - Stores
I want to Implement a GridView of Stores... however, I want to use the formatting of an Object I created called Business Card
I am unable to figure out how to take the data from List of Stores and display it on a "Business Card" which is being called in Gridview
Looked through a number of utube vids and flutter documentations
filename: Business-data.dart
class Business {
String bizname, price, primarycategory, image;
bool userLiked;
double discount;
Business({this.bizname, this.price, this.discount, this.image, this.userLiked});
}
List<Business> stores = [
Business(
bizname: "Company",
image: "assets/images/company.png",
userLiked: true,
),
Business(
name: "Company",
image: "assets/images/company2.png",
userLiked: false,
),
Business(
name: "Company",
image: 'assets/images/company3.png',
userLiked: false,
),
Business(
name: "Company",
image: "assets/images/restaurant.png",
userLiked: true,
)
];
filename: Business Card.dart
import 'package:theboardwalk/homeScreen/Data/Business-data.dart';
Widget BusinessCard(BuildContext context,
{String bizName, Image bizLogo,double onLike, onTapped, bool isProductPage = false}) {
return
RaisedButton(
color: white,
elevation: 20,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) {
return BusinessScreen();
},
),
);
},
child: Stack(
fit: StackFit.expand,
children: <Widget>[
Center(child: Text(bizName)),
// Image.asset(
// image,
// //color: Colors.red,
// ),
],
),
);
}
filename: miniAppGrid.dart
import 'package:theboardwalk/homeScreen/Components/3 MiniAppGrid/3.1 Business Card.dart';
import 'package:theboardwalk/homeScreen/Data/Business.dart';
import '../../Data/Business.dart';
Widget MiniAppGrid(BuildContext context) {
return SizedBox(
height: MediaQuery.of(context).size.height * .650,
width: MediaQuery.of(context).size.width * .96,
child: GridView.count(
// itemCount: stores.length,
crossAxisSpacing: MediaQuery.of(context).size.width * .035,
mainAxisSpacing: MediaQuery.of(context).size.height * .0175,
crossAxisCount: 2,
children: stores.map(
(data) => BusinessCard(
bizName: (Business.bizname),
bizLogo: image,
),
),
),
);
}
I am expecting X number Business Cards to be built based on the list of stores I have. I believe that I should be able to access the stores list of businesses and each business's name within that list.
found it! took me a few more trys!
children: stores.map(
(data) => businessCard(
bizName: data.name,
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.