인프런 - 강의/플루터로 앱 만들기 고고(입문)

5 - 기본 위젯 알아보기

개복치 개발자 2020. 4. 20. 14:29

 

 

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(

        primarySwatch: Colors.blue,
      ),
      home: Test(),
    );
  }
}

class Test extends StatefulWidget {
  @override
  _TestState createState() => _TestState();
}

class _TestState extends State<Test> {

  int count = 0;

  void plueNumber() {
    setState(() {
      count = count + 1;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("title"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text("You have pushed the button this many times"),
            Text('$count', style: TextStyle(fontSize: 30.0),),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.add),
        onPressed: plueNumber,
      ),
    );
  }
}

'인프런 - 강의 > 플루터로 앱 만들기 고고(입문)' 카테고리의 다른 글

8 - 369 게임  (0) 2020.04.20
7 - Image insert  (0) 2020.04.20
6 - show hide  (0) 2020.04.20
4 - 상태변화 알아보기  (0) 2020.04.20
3 - 가장 기초 알아보기  (0) 2020.04.19