adaptive_action_sheet 1.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 80

Adaptive action sheet #

pub package

A action bottom sheet that adapts to the platform (Android/iOS).

iOSAndroid
n1n2

Getting Started #

Add the package to your pubspec.yaml:

 adaptive_action_sheet: ^1.0.3

In your dart file, import the library:

import 'package:adaptive_action_sheet/adaptive_action_sheet.dart';

Instead of using a showModalBottomSheet use showAdaptiveActionSheet Widget:

showAdaptiveActionSheet(
   context: context,
   actions: <BottomSheetAction>[
      BottomSheetAction(title: 'Item 1', onPressed: () {}),
      BottomSheetAction(title: 'Item 2', onPressed: () {}),
      BottomSheetAction(title: 'Item 3', onPressed: () {}),
   ],
   cancelAction: CancelAction(title: 'Cancel'),// onPressed parameter is optional by default will dismiss the ActionSheet
);

Parameters: #

showAdaptiveActionSheet:

  • actions: The Actions list that will appear on the ActionSheet. (required)
  • cancelAction: The optional cancel button that show under the actions (grouped separately on iOS).

BottomSheetAction:

  • title: The string that will appear in the title bar of the action item. (required)
  • onPressed: The callback that is called when the action item is tapped. (required)

CancelAction:

  • title: The string that will appear in the title bar of the cancel action. (required)
  • onPressed: The callback that is called when the action item is tapped. onPressed is optional by default will dismiss the Action Sheet.

[1.0.3] - 05 Jun 2020 #

  • Add required annotation for all the required parameters

[1.0.2] - 25 May 2020 #

  • Add options to customize cancel action.
  • UMake cancel action optional.

[1.0.1] - 20 May 2020 #

  • Update documentation.

[1.0.0] - 19 May 2020 #

  • Initial developers preview release.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:adaptive_action_sheet/adaptive_action_sheet.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Adaptive action sheet Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Adaptive action sheet example'),
      ),
      body: Center(
        child: RaisedButton(
          onPressed: () {
            showAdaptiveActionSheet(
              context: context,
              actions: <BottomSheetAction>[
                BottomSheetAction(title: 'Item 1', onPressed: () {}),
                BottomSheetAction(title: 'Item 2', onPressed: () {}),
                BottomSheetAction(title: 'Item 3', onPressed: () {}),
              ],
              cancelAction: CancelAction(title: 'Cancel'),
            );
          },
          child: const Text('Show action sheet'),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  adaptive_action_sheet: ^1.0.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:adaptive_action_sheet/adaptive_action_sheet.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
60
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
80
Learn more about scoring.

We analyzed this package on Jul 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

because of import path [adaptive_action_sheet] that is in a package requiring null.

Package not compatible with runtime flutter-web on web

Because of the import of dart:io via the import chain package:adaptive_action_sheet/adaptive_action_sheet.dartpackage:adaptive_action_sheet/src/bottom_sheet_alert.dartdart:io

Health issues and suggestions

Document public APIs. (-1 points)

10 out of 10 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test
lint ^1.2.0