исправь код: import 'package:flutter/material.dart'; import 'dart:math'; void main() {…
- User
исправь код: import 'package:flutter/material.dart'; import 'dart:math';
void main() { runApp(MyApp()); }
class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Двойной кубик', theme: ThemeData.dark(), home: DiceRollerHome(), ); } }
class DiceRollerHome extends StatefulWidget { @override _DiceRollerHomeState createState() => _DiceRollerHomeState(); }
class _DiceRollerHomeState extends State { int leftResult = 0; int rightResult = 0;
void rollLeftDice() { setState(() { leftResult = Random().nextInt(6) + 1; }); }
void rollRightDice() { setState(() { rightResult = Random().nextInt(6) + 1; }); }
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Двойной кубик')), body: Center( child: Column(children: [ ElevatedButton( onPressed: rollLeftDice, child: Text('Подбросить левый кубик'), ), SizedBox(height: 20), Text("Левый кубик: rightResult"), ], ), ); } }
Assistant
import 'package:flutter/material.dart';
void main() { runApp(MyApp()); }
class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Double Dice', theme: ThemeData.dark(), home: DiceRollerHome(), ); } }
class DiceRollerHome extends StatefulWidget { @override _DiceRollerHomeState createState() => _DiceRollerHomeState(); }
class _DiceRollerHomeState extends State { int leftResult = 0; int rightResult = 0;
void rollLeftDice() { setState(() { leftResult = Random().nextInt(6) + 1; }); }
void rollRightDice() { setState(() { rightResult = Random().nextInt(6) + 1; }); }
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Double Dice')), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ ElevatedButton( onPressed: rollLeftDice, child: Text('Roll Left Dice'), ), SizedBox(height: 20), Text("Left Dice: rightResult"), ], ), ), ); } }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.