-
Notifications
You must be signed in to change notification settings - Fork 92
/
example2.dart
51 lines (48 loc) · 1.39 KB
/
example2.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
import 'package:flutter/material.dart';
import 'package:focused_menu/focused_menu.dart';
class Example2 extends StatefulWidget {
const Example2({Key? key}) : super(key: key);
@override
State<Example2> createState() => _Example2State();
}
class _Example2State extends State<Example2> {
FocusedMenuHolderController _avatarController = FocusedMenuHolderController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
title: Text('Using controller'),
actions: [
FocusedMenuHolder(
menuOffset: 0,
controller: _avatarController,
onPressed: () {},
menuItems: <FocusedMenuItem>[
FocusedMenuItem(
title: Text("This is a button"),
trailing: Icon(Icons.open_in_new),
onPressed: () {},
),
],
child: CircleAvatar(
child: Image.asset("assets/images/dp_default.png"),
),
),
SizedBox(width: 20)
],
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(
child: ElevatedButton(
onPressed: () => _avatarController.open(),
child: Text('Open avatar menu'),
),
),
],
),
);
}
}