o_popup 0.1.0
o_popup: ^0.1.0 copied to clipboard
An overlaid content, which closes itself into opening place (on back button) or into the position where the pointer contacted the screen.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:o_popup/o_popup.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'o_popup demo app',
routes: {
'/': (BuildContext context) => MyHomePage(),
},
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) => Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
_withHeaderContentAndActionRowDismissible(context),
SizedBox(height: 10.0),
_withHeaderContentAndActionRow(context),
SizedBox(height: 10.0),
_withGraphicalContent(context),
],
),
),
);
OPopupTrigger _withHeaderContentAndActionRowDismissible(
BuildContext context) =>
OPopupTrigger(
triggerWidget: Container(
padding: EdgeInsets.all(10.0),
color: Colors.amber,
child: Text('Dismissible popup with header, content and action row'),
),
popupHeader: OPopupContent.standardizedHeader('Some header'),
popupContent: OPopupContent.standardizedText(
'Click anywhere to close the popup. If you press back button, popup '
'closes itself into opening place',
),
popupActionRow: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
OutlineButton(
textColor: Colors.white,
child: Text('Yes'),
onPressed: () => Navigator.of(context).pop(),
),
OutlineButton(
textColor: Colors.white,
child: Text('No'),
onPressed: () => Navigator.of(context).pop(),
),
],
),
);
OPopupTrigger _withHeaderContentAndActionRow(BuildContext context) =>
OPopupTrigger(
barrierDismissible: false,
triggerWidget: Container(
padding: EdgeInsets.all(10.0),
color: Colors.amber,
child: Text('Popup with header, content and action row'),
),
popupHeader: OPopupContent.standardizedHeader('Some header'),
popupContent: OPopupContent.standardizedText(
'You can close this popup only by clicking one of actions in the '
'action row. If you press back button, popup closes itself '
'into opening place',
),
popupActionRow: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
OutlineButton(
textColor: Colors.white,
child: Text('Yes'),
onPressed: () => Navigator.of(context).pop(),
),
OutlineButton(
textColor: Colors.white,
child: Text('No'),
onPressed: () => Navigator.of(context).pop(),
),
],
),
);
OPopupTrigger _withGraphicalContent(BuildContext context) => OPopupTrigger(
triggerWidget: Container(
padding: EdgeInsets.all(10.0),
color: Colors.amber,
child: Text('Popup with graphical content and action row'),
),
popupContent: Container(
width: 50.0,
height: 50.0,
color: Colors.amber,
),
popupActionRow: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
OutlineButton(
textColor: Colors.white,
child: Text('Like'),
onPressed: () => Navigator.of(context).pop(),
),
OutlineButton(
textColor: Colors.white,
child: Text('Dislike'),
onPressed: () => Navigator.of(context).pop(),
),
],
),
);
}