popover
a popover is a transient view that appears above other content onscreen when you tap a control or in an area. typically, a popover includes an arrow pointing to the location from which it emerged. popovers can be nonmodal or modal. a nonmodal popover is dismissed by tapping another part of the screen or a button on the popover. a modal popover is dismissed by tapping a cancel or other button on the popover.
requirements
- dart: 2.12.0+
- flutter : 2.0.0+
install
dependencies:
popover: ^0.2.4
example
see example/lib/main.dart
.
import 'package:flutter/material.dart';
import 'package:popover/popover.dart';
class popoverexample extends statelesswidget {
@override
widget build(buildcontext context) {
return materialapp(
home: scaffold(
appbar: appbar(title: const text('popover example')),
body: const safearea(
child: padding(
padding: edgeinsets.all(16),
child: button(),
),
),
),
);
}
}
class button extends statelesswidget {
const button({key key}) : super(key: key);
@override
widget build(buildcontext context) {
return container(
width: 80,
height: 40,
decoration: const boxdecoration(
color: colors.white,
borderradius: borderradius.all(radius.circular(5)),
boxshadow: [boxshadow(color: colors.black26, blurradius: 5)],
),
child: gesturedetector(
child: const center(child: text('click me')),
ontap: () {
showpopover(
context: context,
bodybuilder: (context) => const listitems(),
onpop: () => print('popover was popped!'),
direction: popoverdirection.top,
width: 200,
height: 400,
arrowheight: 15,
arrowwidth: 30,
);
},
),
);
}
}
class listitems extends statelesswidget {
const listitems({key key}) : super(key: key);
@override
widget build(buildcontext context) {
return scrollbar(
child: padding(
padding: const edgeinsets.symmetric(vertical: 8),
child: listview(
padding: const edgeinsets.all(8),
children: [
inkwell(
ontap: () {
print('gesturedetector was called on entry a');
navigator.of(context).pop();
},
child: container(
height: 50,
color: colors.amber[100],
child: const center(child: text('entry a')),
),
),
const divider(),
container(
height: 50,
color: colors.amber[200],
child: const center(child: text('entry b')),
),
],
),
),
);
}
}
to see examples of the following package on a device or simulator:
cd example && flutter run
Comments are closed.