Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'dart:math';
- void main() {
- runApp(MaterialApp(
- home: new Home(),
- debugShowCheckedModeBanner: false,
- ));
- }
- class Home extends StatefulWidget {
- @override
- _HomeState createState() => _HomeState();
- }
- class _HomeState extends State<Home> {
- var _frases = [
- "Frase grandeeeeeeeeeeeeeeeeeeeeeeeeeeee 1",
- "Frase grandeeeeeeeeeeeeeeeeeeeeeeeeeeee 2",
- "Frase grandeeeeeeeeeeeeeeeeeeeeeeeeeeee 3",
- "Frase grandeeeeeeeeeeeeeeeeeeeeeeeeeeee 4"
- ];
- var _fraseGerada = "Clique abaixo para gerar uma frase!";
- void _gerarFrase() {
- var numeroSorteado = Random().nextInt(_frases.length);
- setState(() {
- _fraseGerada = _frases[ numeroSorteado ];
- });
- }
- @override
- Widget build(BuildContext context) {
- return new Scaffold(
- appBar: AppBar(
- title: new Text("Frases do dia"),
- backgroundColor: Colors.green,
- ),
- body: new Center(
- child: Container(
- padding: EdgeInsets.all(16),
- //width: double.infinity,
- /*decoration: BoxDecoration(
- border: new Border.all(width: 3, color: Colors.amber)
- ),*/
- child: Column(
- mainAxisAlignment: MainAxisAlignment.spaceEvenly,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: <Widget>[
- Image.asset("images/logo.png"),
- new Text(
- _fraseGerada,
- textAlign: TextAlign.justify,
- style: TextStyle(
- fontSize: 25,
- fontStyle: FontStyle.italic,
- color: Colors.black
- ),
- ),
- new RaisedButton(
- child: new Text(
- "Nova Frase",
- style: new TextStyle(
- fontSize: 25,
- color: Colors.white,
- fontWeight: FontWeight.bold
- ),
- ),
- color: Colors.green,
- onPressed: _gerarFrase,
- )
- ],
- ),
- )
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement