I'm trying to generate two different random numbers and add those together, but Flutter doesn't seem to like my math. I keep getting the message that '+' isn't defined for the class Random.
import 'package:flutter/material.dart';
import 'dart:math';
void main() => runApp(MaterialApp(
title: 'Random Numbers',
theme: ThemeData(primarySwatch: Colors.orange),
home: MyHome(),
));
class MyHome extends StatefulWidget {
@override
_MyHomeState createState() => _MyHomeState();
}
class _MyHomeState extends State<MyHome> {
@override
Widget build(BuildContext context) {
var num1 = new Random();
for (var i = 0; i < 10; i++) {
print(num1.nextInt(10));
}
var num2 = new Random();
for (var i = 0; i < 10; i++) {
print(num2.nextInt(10));
}
//var sum = num1 + num2;
return Container();
}
}
My goal is to display it something like this: "2 + 5 = " where the user will fill in the answer. If correct do this else do that.
Aucun commentaire:
Enregistrer un commentaire