• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2019 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import 'package:flutter/material.dart';
6import 'package:flutter/widgets.dart';
7
8void main() {
9  runApp(const MaterialApp(
10    title: 'Hover Demo',
11    home: HoverDemo(),
12  ));
13}
14
15class DemoButton extends StatelessWidget {
16  const DemoButton({this.name});
17
18  final String name;
19
20  void _handleOnPressed() {
21    print('Button $name pressed.');
22  }
23
24  @override
25  Widget build(BuildContext context) {
26    return FlatButton(
27      onPressed: () => _handleOnPressed(),
28      child: Text(name),
29    );
30  }
31}
32
33class HoverDemo extends StatefulWidget {
34  const HoverDemo({Key key}) : super(key: key);
35
36  @override
37  _HoverDemoState createState() => _HoverDemoState();
38}
39
40class _HoverDemoState extends State<HoverDemo> {
41  @override
42  Widget build(BuildContext context) {
43    final TextTheme textTheme = Theme.of(context).textTheme;
44
45    return DefaultTextStyle(
46      style: textTheme.display1,
47      child: Scaffold(
48        appBar: AppBar(
49          title: const Text('Hover Demo'),
50        ),
51        floatingActionButton: FloatingActionButton(
52          child: const Text('+'),
53          onPressed: () {},
54        ),
55        body: Center(
56          child: Builder(builder: (BuildContext context) {
57            return Column(
58              mainAxisAlignment: MainAxisAlignment.center,
59              children: <Widget>[
60                Row(
61                  children: <Widget>[
62                    RaisedButton(
63                      onPressed: () => print('Button pressed.'),
64                      child: const Text('Button'),
65                      focusColor: Colors.deepOrangeAccent,
66                    ),
67                    FlatButton(
68                      onPressed: () => print('Button pressed.'),
69                      child: const Text('Button'),
70                      focusColor: Colors.deepOrangeAccent,
71                    ),
72                    IconButton(
73                      onPressed: () => print('Button pressed'),
74                      icon: const Icon(Icons.access_alarm),
75                      focusColor: Colors.deepOrangeAccent,
76                    ),
77                  ],
78                ),
79                const Padding(
80                  padding: EdgeInsets.all(8.0),
81                  child: TextField(
82                    decoration: InputDecoration(labelText: 'Enter Text', filled: true),
83                  ),
84                ),
85                Padding(
86                  padding: const EdgeInsets.all(8.0),
87                  child: TextField(
88                    autofocus: false,
89                    decoration: InputDecoration(
90                      border: OutlineInputBorder(),
91                      labelText: 'Enter Text',
92                      filled: false,
93                    ),
94                  ),
95                ),
96              ],
97            );
98          }),
99        ),
100      ),
101    );
102  }
103}
104