Commit b8559ef1 authored by m-spi's avatar m-spi
parents 03a671c9 b3d7877e
......@@ -62,16 +62,16 @@ class _Exo6 extends State<Exo6> {
-1 + 2 * i.toDouble() / (colNb.toDouble() - 1))
);
Key k = UniqueKey();
tiles.add(
Flexible(child: Container(
Flexible(key: k, child: Container(
margin: EdgeInsets.all(10.0 / colNb),
child: InkWell(
child: tile.croppedImageTile(1 / colNb),
onTap: () {
setState(() {
print(indexcopy);
tiles.insert(emptyTileIndex, tiles.removeAt(indexcopy));
emptyTileIndex = indexcopy;
swapTiles(k);
});
}
)
......@@ -84,6 +84,13 @@ class _Exo6 extends State<Exo6> {
}
}
void swapTiles(Key k){
var t = tiles.singleWhere((element) => element.key == k);
tiles[emptyTileIndex] = t;
tiles[tiles.indexOf(t)] = Flexible(child: Container(margin: EdgeInsets.all(10.0 / colNb)));
emptyTileIndex = tiles.indexOf(t);
}
@override
Widget build(BuildContext context) {
return Scaffold(
......
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