Last updated:
0 purchases
platform action sheet
Platform action sheet #
This package is a simple platform specific actionSheet for Cupertino and Android with the following options:
Text - (Required) String to display
onPressed - (Required) Function to be executed on the option item being pressed
hasArrow - Not visible on IOS, indicating more options will appear
isCancel
defaultAction
Getting started #
In the pubspec.yaml of your flutter project, add the following dependency:
dependencies:
...
platform_action_sheet: ^0.0.3
copied to clipboard
In your library add the following import:
import 'package:platform_action_sheet/platform_action_sheet.dart';
copied to clipboard
For help getting started with Flutter, view the online documentation.
Example #
import 'package:flutter/material.dart';
import 'package:platform_action_sheet/platform_action_sheet.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Example App',
home: new Home(),
);
}
}
class Home extends StatelessWidget {
const Home({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Example App'),
),
body: Center(
child: FlatButton(
color: Colors.blue,
onPressed: () => PlatformActionSheet().displaySheet(
context: context,
title: Row(
children: <Widget>[
Text("Hello Mum"),
Icon(
Icons.beach_access,
color: Colors.blue,
size: 36.0,
),
],
),
message: Text("I'm in London"),
actions: [
ActionSheetAction(
text: "Option 1",
onPressed: () => Navigator.pop(context),
hasArrow: true,
),
ActionSheetAction(
text: "Option 2",
onPressed: () => Navigator.pop(context),
),
ActionSheetAction(
text: "Cancel",
onPressed: () => Navigator.pop(context),
isCancel: true,
defaultAction: true,
)
]),
child: Text(
'Display ActionSheet',
textScaleFactor: 1.2,
style: TextStyle(color: Colors.white),
),
),
),
);
}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.