utopic_toast 0.1.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 79

utopic_toast #

Toast Flutter package.

You are free to correct my English!

Overview #

  • In the true sense of Toast, you can call it whenever you need it, without any restrictions.

  • Showing multiple dismissible toasts at the same time with showing and hiding animation.

  • Pure flutter implementation, it is not easy to bring compatibility problems

Preview #

ezgif com-resize

Getting started #

1. add dependencies into you project pubspec.yaml file

dependencies:
     utopic_toast: ^0.1.3

2. import BotToast lib

import 'package:utopic_toast/utopic_toast.dart';

3. initialization ToastOverlay

// wrap MaterialApp builder's child with ToastOverlay and set your custom params
MaterialApp(
  ...
  builder: (context, child) {
    return ToastOverlay(child: child);
  },
  ...
);

4. use ToastManager

var toastFuture = ToastManager().showToast(
  'YOUR MESSAGE TO USER',
  type: ToastType.error, // set toast type to change presetted theme color 
  action: ToastAction(
    label: 'HAY',
    onPressed: (hideToastFn) {
      print('yay');
      hideToastFn();
    },
  ),
  duration: Duration(seconds: 3),
);
toastFuture.dismiss(); // to hide toast

Changelog #

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[0.1.3] - 21.04.2020 #

Changed #

  • update rxdart version to ^0.24.0
  • update provider version to ^4.0.5

[0.1.2] - 27.03.2020 #

Changed #

  • make _toastsController initialized only once

[0.1.1] - 25.03.2020 #

Changed #

  • Update README.MD
  • Add enableTapToHide param to ToastOverlay

[0.1.0] - 21.03.2020 #

Changed #

  • In ToastAction onPressed passed function to hide toast

Fixed #

  • ToastManager().showToast now returns ToastFuture

[0.0.1] - initial release: 19.03.2020 #

example/lib/main.dart

import 'dart:math';

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Utopic Toast Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      builder: (context, child) {
        return ToastOverlay(
          child: child,
        );
      },
      home: MyHomePage(title: 'Utopic Toast Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  void _showRandomToast() {
    var rand = Random();
    final randomStringLength = rand.nextInt(200);
    List<int> charCodes = List<int>.generate(randomStringLength, (_) {
      return rand.nextInt(33) + 89;
    });
    ToastManager().showToast(
      String.fromCharCodes(charCodes),
      type: ToastType.values[rand.nextInt(ToastType.values.length)],
      action: rand.nextBool()
          ? ToastAction(
              label: 'HAY',
              onPressed: (hideToast) {
                print('yay');
                hideToast();
              },
            )
          : null,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'Push the FAB to show random toast',
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _showRandomToast,
        tooltip: 'Show Random Toast',
        child: Icon(Icons.message),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  utopic_toast: ^0.1.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:utopic_toast/utopic_toast.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
57
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
79
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • utopic_toast that is a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
provider ^4.0.5 4.3.1
rxdart ^0.24.0 0.24.1
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
nested 0.0.4
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test