Hangi dili kullanıyorsun?
Muhtemelen kodlarında bir sorun vardır, kodları paylaşabilirsen yardımcı olmak isterim.
Flutter (dart) zar kodu böyle . 3 sayfa daha var ama onlarda hatada vermiyor zaten.import 'package:flutter/material.dart';
import 'dart:math';
final randomizer = Random();
class DiceRoller extends StatefulWidget{
DiceRoller({super.key});
@override
State<DiceRoller> createState() {
return _DiceRollerState();
}
}
class _DiceRollerState extends State<DiceRoller>{
var currentDiceRoll = 2;
var activeDiceImage ='assets/images/dice-2.png' ;
void rollDice() {
var diceRoll = Random().nextInt(6) +1;
setState(() {
currentDiceRoll = diceRoll ;
});
activeDiceImage = 'assets/images/dice-$currentDiceRoll.png';
}
Widget build(context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset( activeDiceImage ,
width: 200,
),
SizedBox(height: 40,),
TextButton(
onPressed: rollDice,
style: TextButton.styleFrom(
foregroundColor: const Color.fromARGB(255, 195, 12, 12),textStyle:const TextStyle(fontSize: 28),backgroundColor: Colors.blueGrey),
child: const Text('ROLL DİCE'),)
],
);
}
}
Bu kod sabah ne yaptım bilmiyorum ama önceden calisiyordu
Flutter (dart) zar kodu böyle. 3 sayfa daha var ama onlarda hatada vermiyor zaten. İmport 'package:flutter/material.dart';
İmport 'dart: Math';
Final randomizer = Random();
Class DiceRoller extends StatefulWidget{
DiceRoller({super. Key});
@Override
State<DiceRoller> createState() {
Return _DiceRollerState();
}
}
Class _DiceRollerState extends State<DiceRoller>{
Var currentDiceRoll = 2;
Var activeDiceImage ='assets/images/dice-2.png';
Void rollDice() {
Var diceRoll = Random().nextInt(6) +1;
setState(() {
CurrentDiceRoll = diceRoll;
});
ActiveDiceImage = 'assets/images/dice-$currentDiceRoll.png';
}
Widget Build(context) {
Return Column(
MainAxisSize: MainAxisSize. Min,
Children: [
Image.asset( activeDiceImage ,
width: 200,
),
SizedBox(height: 40,),
TextButton(
onPressed: rollDice,
style: TextButton.styleFrom(
foregroundColor: const Color.fromARGB(255, 195, 12, 12),textStyle:const TextStyle(fontSize: 28),backgroundColor: Colors.blueGrey),
child: const Text('ROLL DİCE'),)
],
);
}
}
Bu kod sabah ne yaptım bilmiyorum ama önceden calisiyordu.
Sabah terminalde bir yazıyı kodumun izine sürükledim gibi oldu sonra CTRL Z yaptım bu hata ondan beri var.