Dart Generate Random Number
Complete Code For Dart Generate Random Number In Flutter
Main.dart
import 'package:flutter/material.dart'; import 'dart:math'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { void generateRandomNumber() { var random = new Random(); print(random.nextInt(100)); } @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: Scaffold( backgroundColor: Colors.black, body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Container( margin: const EdgeInsets.fromLTRB(20, 10, 20, 10), child: RaisedButton( onPressed: () => generateRandomNumber(), child: Text('Generate Random Number '), textColor: Colors.white, color: Colors.orange, padding: EdgeInsets.fromLTRB(12, 12, 12, 12), ) ), ]) ) ) ); } }