class _MyHomePageState extends State<MyHomePage> {
static var _message = "ok.";
static var _value = 0.0;
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('App Name'),
),
body:
new Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Padding(
padding: EdgeInsets.all(20.0),
child: Text(
_message,
style: TextStyle(
fontSize: 32.0,
fontWeight: FontWeight.w400,
fontFamily:"Robot"),
),
),
Padding(
padding: EdgeInsets.all(10.0),
),
Slider (
onChanged: sliderChanged,
min: 0.0,
max: 100.0,
divisions: 20,
value:_value,
),
],
),
),
);
}
void sliderChanged(double value){
setState((){
_value = value.floorToDouble();
_message = 'set value: $_value';
});
}
}
class _MyHomePageState extends State<MyHomePage> {
static var _message = "ok.";
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('App Name'),
),
body:
new Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Padding(
padding: EdgeInsets.all(20.0),
child: Text(
_message,
style: TextStyle(
fontSize: 32.0,
fontWeight: FontWeight.w400,
fontFamily:"Robot"),
),
),
Padding(
padding: EdgeInsets.all(10.0),
),
Padding(
padding: EdgeInsets.all(10.0),
child: ElevatedButton(
onPressed:buttonPressed,
child: Text(
"tap me!",
style: TextStyle(fontSize:32.0,
color: const Color(0xff000000),
fontWeight: FontWeight.w400,
fontFamily: "Roboto"),
)
)
)
],
),
),
);
}
void buttonPressed(){
showDialog(
context: context,
builder: (BuildContext context) => AlertDialog(
title: Text("Hello!"),
content: Text("This is sample."),
actions: <Widget>[
TextButton(
child: const Text('Cancel'),
onPressed: () => Navigator.pop<String>(context, 'Cancel')
),
TextButton(
child: const Text('OK'),
onPressed: () => Navigator.pop<String>(context, 'OK')
),
]
),
).then<void>((value)=> resultAlert(value));
}
void resultAlert(String value){
setState((){
_message = 'selected: $value';
});
}
}
class _MyHomePageState extends State<MyHomePage> {
static var _message = "ok.";
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('App Name'),
),
body:
new Column(
children: <Widget>[
Text(
_message,
style: TextStyle(
fontSize: 32.0,
),
),
ListView(
shrinkWrap: true,
padding: const EdgeInsets.all(20.0),
children: <Widget>[
Text('First item',
style: TextStyle(fontSize: 24.0),
),
Text('Second item',
style: TextStyle(fontSize: 24.0),
),
Text('Third item',
style: TextStyle(fontSize: 24.0),
),
],
),
],
),
);
}
}
class _MyHomePageState extends State<MyHomePage> {
static var _message = "ok.";
static var _index = 0;
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('App Name'),
),
body:
new Column(
children: <Widget>[
Text(
_message,
style: TextStyle(
fontSize: 32.0,
),
),
ListView(
shrinkWrap: true,
padding: const EdgeInsets.all(20.0),
children: <Widget>[
ListTile(
leading: const Icon(Icons.android, size:32),
title: const Text('first item',
style: TextStyle(fontSize: 28)),
selected: _index == 1,
onTap:() {
_index = 1;
tapTile();
},
),
ListTile(
leading: const Icon(Icons.favorite, size:32),
title: const Text('second item',
style: TextStyle(fontSize: 28)),
selected: _index == 2,
onTap:() {
_index = 2;
tapTile();
},
),
ListTile(
leading: const Icon(Icons.home, size:32),
title: const Text('third item',
style: TextStyle(fontSize: 28)),
selected: _index == 3,
onTap:() {
_index = 3;
tapTile();
},
),
],
),
],
),
);
}
void tapTile() {
setState(() {
_message = 'you tapped: No, $_index.';
});
}
}
SingleChildScrollView
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('App Name'),
),
body: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Container(
color: Colors.blue,
height: 120.0,
child: const Center(
child: Text('one',
style: const TextStyle(fontSize:32.0)),
),
),
Container(
color: Colors.white,
height: 120.0,
child: const Center(
child: Text('two',
style: const TextStyle(fontSize:32.0)),
),
),
Container(
color: Colors.blue,
height: 120.0,
child: const Center(
child: Text('three',
style: const TextStyle(fontSize:32.0)),
),
),
Container(
color: Colors.white,
height: 120.0,
child: const Center(
child: Text('four',
style: const TextStyle(fontSize:32.0)),
),
),
Container(
color: Colors.blue,
height: 120.0,
child: const Center(
child: Text('five',
style: const TextStyle(fontSize:32.0)),
),
),
],
),
)
);
}
}