Files
kabukicho-vscode/demos/flutter.dart
T
Victoria Drake de4dcd5d21 Go, roboto! Launch!! 🤖
2020-02-02 11:03:57 -05:00

80 lines
1.5 KiB
Dart

import 'package:flutter/material.dart';
void main()
{
runApp
(
new MaterialApp
(
home: new MyButton(),
)
);
}
class MyButton extends StatefulWidget
{
@override
MyButtonState createState() => new MyButtonState();
}
class MyButtonState extends State<MyButton>
{
String flutterText = "";
List<String> collection = ['Flutter', 'is', 'great'];
int index = 0;
void changeText()
{
setState
(
()
{
flutterText = collection[index];
index++;
index = index % 3;
}
);
}
@override
Widget build(BuildContext context)
{
return new Scaffold
(
appBar: new AppBar
(
title: new Text("Stateful Widget"),
backgroundColor: Colors.orangeAccent,
),
body: Center
(
child: new Column
(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>
[
new Text
(
flutterText,
style: new TextStyle(fontSize: 40.0)
),
new Padding
(
padding: new EdgeInsets.all(10.0)
),
new RaisedButton
(
child: new Text
(
"Update",
style: new TextStyle(color: Colors.white)
),
color: Colors.blueAccent,
onPressed: changeText,
)
],
)
)
);
}
}