Commit 1a719333 authored by m-spi's avatar m-spi

TP2 exo5

parent 62667a66
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
"name": "flutter", "name": "flutter",
"rootUri": "file:///home/spinelli/IMT/M1/AMSE/flutter/packages/flutter", "rootUri": "file:///home/spinelli/IMT/M1/AMSE/flutter/packages/flutter",
"packageUri": "lib/", "packageUri": "lib/",
"languageVersion": "3.2" "languageVersion": "3.3"
}, },
{ {
"name": "flutter_lints", "name": "flutter_lints",
...@@ -170,7 +170,7 @@ ...@@ -170,7 +170,7 @@
"languageVersion": "3.4" "languageVersion": "3.4"
} }
], ],
"generated": "2024-02-14T09:30:03.769996Z", "generated": "2024-02-19T13:16:14.727949Z",
"generator": "pub", "generator": "pub",
"generatorVersion": "3.4.0-131.0.dev" "generatorVersion": "3.4.0-154.0.dev"
} }
...@@ -103,7 +103,7 @@ sky_engine ...@@ -103,7 +103,7 @@ sky_engine
file:///home/spinelli/IMT/M1/AMSE/flutter/bin/cache/pkg/sky_engine/ file:///home/spinelli/IMT/M1/AMSE/flutter/bin/cache/pkg/sky_engine/
file:///home/spinelli/IMT/M1/AMSE/flutter/bin/cache/pkg/sky_engine/lib/ file:///home/spinelli/IMT/M1/AMSE/flutter/bin/cache/pkg/sky_engine/lib/
flutter flutter
3.2 3.3
file:///home/spinelli/IMT/M1/AMSE/flutter/packages/flutter/ file:///home/spinelli/IMT/M1/AMSE/flutter/packages/flutter/
file:///home/spinelli/IMT/M1/AMSE/flutter/packages/flutter/lib/ file:///home/spinelli/IMT/M1/AMSE/flutter/packages/flutter/lib/
flutter_test flutter_test
......
3.20.0-4.0.pre.92 3.20.0-10.0.pre.44
\ No newline at end of file \ No newline at end of file
{"inputs":[],"outputs":[]}
\ No newline at end of file
{"inputs":[],"outputs":[]}
\ No newline at end of file
{"inputs":[],"outputs":[]}
\ No newline at end of file
This diff is collapsed.
...@@ -8,7 +8,6 @@ class Tile { ...@@ -8,7 +8,6 @@ class Tile {
Tile({required this.image, required this.alignment}); Tile({required this.image, required this.alignment});
Widget croppedImageTile(double widthFactor) { Widget croppedImageTile(double widthFactor) {
print("creating single tile");
return FittedBox( return FittedBox(
fit: BoxFit.fill, fit: BoxFit.fill,
...@@ -42,31 +41,68 @@ class _Exo5 extends State<Exo5> { ...@@ -42,31 +41,68 @@ class _Exo5 extends State<Exo5> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
print("building state"); print("building state");
int i = 0;
int j = 0;
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text('Display a Tile as a Cropped Image'), title: const Text('Display a Tile as a Cropped Image'),
centerTitle: true, centerTitle: true,
), ),
body: body: Column(children: [
Column( Container(
children: [ margin: const EdgeInsets.all(10.0),
Text("col"), child: SizedBox(
Container( height: MediaQuery.of(context).size.height * 0.7,
margin: const EdgeInsets.all(20.0), width: MediaQuery.of(context).size.height * 0.7,
child: GridView.count( child: GridView.builder(
primary: false, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
padding: const EdgeInsets.all(1), crossAxisCount: colNb,
crossAxisSpacing: 1, ),
mainAxisSpacing: 1, itemCount: colNb * colNb,
crossAxisCount: colNb, // Nombre de colonnes itemBuilder: (BuildContext context, int index) {
children: [Text("aaaa"), Text("bbb"), Text("ccc")] // createTilesFromImage(colNb) Tile tile;
)), tile = Tile(image: image, alignment:
], Alignment(-1 + 2 * j.toDouble() / (colNb.toDouble() - 1),
)) -1 + 2 * i.toDouble() / (colNb.toDouble() - 1))
; );
}
int ii = i;
int jj = j;
j++;
if(j == colNb){
i++;
j = 0;
}
return Flexible(child: Container(
margin: EdgeInsets.all(10.0 / colNb),
child: InkWell(
child: tile.croppedImageTile(1 / colNb),
onTap: () {
print("tapped on " + ii.toString() + " " + jj.toString());
}
)
));
}
)
)
),
Slider(
value: colNb.toDouble(),
min: 2,
max: 6,
onChanged: (double value) {
setState(() {
colNb = value.toInt();
});
}
),
]),
);
}
List<Widget> createTilesFromImage(int colNb) { List<Widget> createTilesFromImage(int colNb) {
print("creating tiles"); print("creating tiles");
...@@ -74,13 +110,13 @@ class _Exo5 extends State<Exo5> { ...@@ -74,13 +110,13 @@ class _Exo5 extends State<Exo5> {
List<Widget> res = <Widget>[]; List<Widget> res = <Widget>[];
for(int i=0; i<colNb; i++){ for(int i=0; i<colNb; i++){
for(int j=0; j<colNb; j++){ for(int j=0; j<colNb; j++){
tile = Tile(image: image, alignment: Alignment(-1 + 2 * j.toDouble() / colNb.toDouble(), -1 + 2 * i.toDouble() / colNb.toDouble())); tile = Tile(image: image, alignment:
Alignment(-1 + 2 * j.toDouble() / (colNb.toDouble() - 1),
-1 + 2 * i.toDouble() / (colNb.toDouble() - 1))
);
res.add(InkWell( res.add(InkWell(
child: tile.croppedImageTile(1 / colNb), child: tile.croppedImageTile(1 / colNb),
onTap: () {
print("tapped on tile $i $j");
},
)); ));
} }
} }
......
...@@ -79,26 +79,26 @@ packages: ...@@ -79,26 +79,26 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker name: leak_tracker
sha256: cdd14e3836065a1f6302a236ec8b5f700695c803c57ae11a1c84df31e6bcf831 sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "10.0.3" version: "10.0.4"
leak_tracker_flutter_testing: leak_tracker_flutter_testing:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker_flutter_testing name: leak_tracker_flutter_testing
sha256: "9b2ef90589911d665277464e0482b209d39882dffaaf4ef69a3561a3354b2ebc" sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.2" version: "3.0.3"
leak_tracker_testing: leak_tracker_testing:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker_testing name: leak_tracker_testing
sha256: fd3cd66cb2bcd7b50dcd3b413af49d78051f809c8b3f6e047962765c15a0d23d sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.0" version: "3.0.1"
lints: lints:
dependency: transitive dependency: transitive
description: description:
...@@ -127,10 +127,10 @@ packages: ...@@ -127,10 +127,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.11.0" version: "1.12.0"
path: path:
dependency: transitive dependency: transitive
description: description:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment