/
builder.dart
63 lines (60 loc) · 1.75 KB
/
builder.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import 'package:flutter/material.dart';
import '../Code.dart';
import '../CodeScreen.dart';
import '../utils.dart';
class BuilderWidget extends StatefulWidget {
@override
_BuilderWidgetState createState() => _BuilderWidgetState();
}
class _BuilderWidgetState extends State<BuilderWidget> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text(
'Builder Widget',
style: TextStyle(
fontSize: 20.0, fontWeight: FontWeight.bold, fontFamily: Utils.ubuntuRegularFont),
),
actions: <Widget>[
IconButton(
icon: Icon(Icons.code),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CodeScreen(code: Code.builderCode),
),
),
)
],
),
body: Center(
child: Builder(
builder: (BuildContext context) {
return RaisedButton(
color: Colors.blue,
textColor: Colors.white,
child: Text("Click me"),
onPressed: () {
Scaffold.of(context).showSnackBar(
SnackBar(
content:
Text("I was created using context of a builder and not a scaffold key"),
action: SnackBarAction(
textColor: Colors.yellow,
label: 'OK',
onPressed: () {
Scaffold.of(context).hideCurrentSnackBar();
},
),
),
);
},
);
},
),
),
);
}
}