개발/플루터(flutter)

커플게임 앱 - 3

개복치 개발자 2020. 4. 9. 18:03

import 'dart:math';

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
      ),
      home: Hello(),
    );
  }
}

class Hello extends StatefulWidget {
  @override
  _HelloState createState() => _HelloState();
}

class _HelloState extends State<Hello> {

  String change_Text = "change";

  var list = ["머리 꺠물기",
    "첫인상 이야기하기",
    "인생이란 무엇일까요",
    "먹고놀면서 돈 벌고싶다",
    "아 인생"];

  final _random = new Random();
  
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: FloatingActionButton(
        child: Text("눌러 boy", textAlign: TextAlign.center,),
        onPressed: change_msg,
      ),
      appBar: AppBar(
        title: Text('커플게임 가즈앙'),
      ),
      body: Center(
        child: Text(change_Text),
      ),
    );
  }

  void change_msg() {
    print(list);
    print(list[_random.nextInt(list.length)]);

    var result_text = list[_random.nextInt(list.length)];

    setState(() {
      change_Text = result_text;
    });

  }
}

'개발 > 플루터(flutter)' 카테고리의 다른 글

flutter adb exited with exit code 1  (0) 2020.04.21
bottom tabBar  (0) 2020.04.12
커플게임 앱 - 2  (0) 2020.04.09
커플게임 앱 - 1  (0) 2020.04.09
플루터 Stateful Stateless  (0) 2020.04.01