bytoast 1.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 53

ByToast #

pub package author

A Toast Widget for Flutter.

Feature #

  • 非调用原生Toast,Dart实现;
  • 交互和动效接近原生Toast,不触发遮罩点击事件,跨页仍显示;
  • 其他

Get Started #

Add Dependency #

dependencies:
  bytoast: ^1.1.0

Usage #

import 'package:toaster/toaster.dart';

/// Simple Toast
ByToast.short();

/// Toast with Icon
ByToast.withIcon();

/// Toast For Customize
ByToast.more();

Support or Contact #

1.1.0 - 2020/06/12 #

  • Export the Other Classes in bytoast.dart, so just import bytoast.dart is okay

1.0.2 - 2020/05/13 #

  • Slightly Adjust the UI

1.0.1 - 2020/05/10 #

  • Format Dart

1.0.0 - 2020/05/10 #

example/lib/main.dart

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

import 'base/page_widget.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Pandora Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.lightGreen,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends BasePageWidget {
  final String title;

  const MyHomePage({Key key, this.title}) : super(key: key);

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

class _MyHomePageState extends BasePageState<MyHomePage> {
  var _funcMap;
  var _gValue = ToastStyle.bottom;

  onItemClick(BuildContext context, int index) {
    switch (index) {
      case 0:
        toast(context, 'This is a Toast');
        break;
      case 1:
        toast(
          context,
          'This is a Long Long Long Long Long Long Long Long Long Long Long Long Long Toast',
        );
        break;
      case 2:
        ByToast.withIcon(
          context,
          'Success',
          Image.asset('images/ic_tips_ok.webp', alignment: Alignment.center),
          isOnTop: true,
        );
        break;
      case 3:
        ByToast.withIcon(context, 'U Got a new Msg', Icon(Icons.alarm, color: Colors.white));
        break;
      case 4:
        ByToast.more(
          context,
          msg: 'Customization Shown',
          gravity: _gValue,
          txtColor: Colors.lightGreen,
        );
        break;
    }
  }

  @override
  void initParams() {
    super.initParams();
    _funcMap = [
      'Toast:Normal',
      'Toast:Normal Wrap',
      'Toast:Succeed Tips',
      'Toast:With Img',
      'Toast:Customization',
    ];
  }

  @override
  String getTitle() {
    return "Toaster Demo";
  }

  _switchGravity(value) {
    setState(() {
      _gValue = value;
    });
  }

  @override
  buildBody() => Column(
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
          Expanded(
              child: ListView.builder(
            itemCount: _funcMap.length,
            padding: EdgeInsets.all(8),
            itemBuilder: (BuildContext context, int index) {
              return Card(
                child: ListTile(
                  title: Text(_funcMap[index]),
                  onTap: () {
                    onItemClick(context, index);
                  },
                ),
              );
            },
          )),
          SizedBox(height: 8.0),
          RadioListTile(
            value: ToastStyle.top,
            title: Text('Top'),
            groupValue: _gValue,
            onChanged: _switchGravity,
          ),
          RadioListTile(
            value: ToastStyle.center,
            title: Text('Center'),
            groupValue: _gValue,
            onChanged: _switchGravity,
          ),
          RadioListTile(
            value: ToastStyle.bottom,
            title: Text('Bottom'),
            groupValue: _gValue,
            onChanged: _switchGravity,
          )
        ],
      );
}

Use this package as a library

1. Depend on it

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


dependencies:
  bytoast: ^1.1.0

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:bytoast/bytoast.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
6
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]
53
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • bytoast that is a package requiring null.

Health suggestions

Format lib/bytoast.dart.

Run flutter format to format lib/bytoast.dart.

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.2
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