platform_action_sheets 0.0.3 copy "platform_action_sheets: ^0.0.3" to clipboard
platform_action_sheets: ^0.0.3 copied to clipboard

ActionSheet for Cupertino and Android

Platform action sheets #

Platform Pub

This package is a fork of platform_action_sheet by Aidan Mc Evoy with added support for destructive actions on iOS

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

In your library add the following import:

import 'package:platform_action_sheet/platform_action_sheet.dart';

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,
                      isDestructiveAction: 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),
              ),
        ),
      ),
    );
  }
}
1
likes
20
pub points
0%
popularity

Publisher

unverified uploader

ActionSheet for Cupertino and Android

Repository (GitHub)
View/report issues

License

BSD-2-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on platform_action_sheets