Alignement lignes colonnes

This commit is contained in:
Gabriel
2023-05-31 12:06:17 +02:00
parent c5648f82e3
commit c344ae4051

View File

@@ -64,45 +64,58 @@ class _HomePageState extends State<HomePage> {
)
),
Card(
color: Colors.white,
child: FutureBuilder<List<ShipModel>>(
future: getShips(),
builder: (BuildContext context, AsyncSnapshot<List<ShipModel>> snapshot) {
if (snapshot.hasData) {
List<ShipModel> ships = snapshot.data!;
return SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
color: Colors.white,
child: FutureBuilder<List<ShipModel>>(
future: getShips(),
builder: (BuildContext context, AsyncSnapshot<List<ShipModel>> snapshot) {
if (snapshot.hasData) {
List<ShipModel> ships = snapshot.data!;
return SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: MediaQuery.of(context).size.width, // Utiliser la largeur de l'écran
child: Card(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Table(
defaultColumnWidth: IntrinsicColumnWidth(),
children: ships.map((ship) {
return Container(
width: MediaQuery.of(context).size.width,
child: Card(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text('${ship.symbol ?? 'N/A'}'),
Text('${ship.nav?.status ?? 'N/A'}'),
Text('Fuel: ${ship.fuel?.current ?? 'N/A'} / ${ship.fuel?.capacity ?? 'N/A'}'),
Text('Cargo: ${ship.cargo?.units ?? 'N/A'} / ${ship.cargo?.capacity ?? 'N/A'}'),
],
),
),),
return TableRow(
children: [
TableCell(
child: Text('${ship.symbol ?? 'N/A'}'),
),
TableCell(
child: Text('${ship.nav?.status ?? 'N/A'}'),
),
TableCell(
child: Text('Fuel: ${ship.fuel?.current ?? 'N/A'} / ${ship.fuel?.capacity ?? 'N/A'}'),
),
TableCell(
child: Text('Cargo: ${ship.cargo?.units ?? 'N/A'} / ${ship.cargo?.capacity ?? 'N/A'}'),
),
],
);
}).toList(),
}).toList(),
),
),
),
);
}else if (snapshot.hasError) {
return Text('Error: ${snapshot.error}');
}else {
return CircularProgressIndicator();
}
},
),
),
],
),
);
} else if (snapshot.hasError) {
return Text('Error: ${snapshot.error}');
} else {
return CircularProgressIndicator();
}
},
),
),
],
),
),