2
Good morning! I’m starting to learn programming with flutter, I’m very new in the field.
I want to know how to open the link of a site, when clicked on a certain image that is in the flutter Gridview?
I also need to know how to make the name/text different on each Gridview item? Follow the code that needs to be implemented these features:
import 'package:flutter/material.dart';
class Settings extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: GridView.count(
// Create a grid with 2 columns. If you change the scrollDirection to
// horizontal, this would produce 2 rows.
crossAxisCount: 2,
// Generate 100 Widgets that display their index in the List
children: List.generate(6, (index) {
/*return Card (child: Image.asset('images/image$index.jpg'));*/
return Card(
color: Colors.white,
child: Padding(
padding:
EdgeInsets.only(left: 10.0, right: 10.0, bottom: 10.0, top: 10.0),
child: Container(
alignment: Alignment.center,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Flexible(
child: Image.asset('images/image$index.jpg',
width: 150,
height: 150,
),
),
Padding(
padding: EdgeInsets.all(10.0),
child: Text(
'Título $index',
maxLines: 1,
softWrap: true,
textAlign: TextAlign.center,
),
),
],
),
),
),
);
}),
),
);
}
}
Lucas Paz, good afternoon! First I want to thank you for the support. With your help I managed to make the site open. However, I need to individualize the cards of each image so that each one opens a specific link. The way this one, where I have 6 cards with images, all open the same link.
– Valdir
Where does the specific link come from? Just set inside the Launch... Create a variable if it is dynamically and pass as parameter.
– Lucas Paz