flutter_toastr 1.0.3 copy "flutter_toastr: ^1.0.3" to clipboard
flutter_toastr: ^1.0.3 copied to clipboard

Flutter Toastr is a Flutter package for non-blocking notifications. You can show toast message at any position of your app and at any duration length.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

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

  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyHomePage> {
  _showToast(String msg, {int? duration, int? position}) {
    FlutterToastr.show(msg, context, duration: duration, position: position);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Flutter Toastr for non-blocking notifications'),
        ),
        body: Center(
          child: Column(
            children: <Widget>[
              Padding(
                padding: const EdgeInsets.all(10.0),
                child: ElevatedButton(
                    child: Text('Show Short Toastr'),
                    onPressed: () => _showToast("Show Short Toastr")),
              ),
              Padding(
                padding: const EdgeInsets.all(10.0),
                child: ElevatedButton(
                    child: Text('Show Long Toastr'),
                    onPressed: () => _showToast("Show Long Toastr",
                        duration: FlutterToastr.lengthLong)),
              ),
              Padding(
                padding: const EdgeInsets.all(10.0),
                child: ElevatedButton(
                    child: Text('Show Bottom Toastr'),
                    onPressed: () => _showToast("Show Bottom Toastr",
                        position: FlutterToastr.bottom)),
              ),
              Padding(
                padding: const EdgeInsets.all(10.0),
                child: ElevatedButton(
                    child: Text('Show Center Toastr'),
                    onPressed: () => _showToast("Show Center Toastr",
                        position: FlutterToastr.center)),
              ),
              Padding(
                padding: const EdgeInsets.all(10.0),
                child: ElevatedButton(
                    child: Text('Show Top Toastr'),
                    onPressed: () => _showToast("Show Top Toastr",
                        position: FlutterToastr.top)),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
13
likes
140
pub points
91%
popularity

Publisher

unverified uploader

Flutter Toastr is a Flutter package for non-blocking notifications. You can show toast message at any position of your app and at any duration length.

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (license)

Dependencies

flutter

More

Packages that depend on flutter_toastr