post_office 0.1.0+1 copy "post_office: ^0.1.0+1" to clipboard
post_office: ^0.1.0+1 copied to clipboard

discontinued

Simply post messages from anywhere in your app to PostBox widgets and display them.

example/main.dart

import 'package:flutter/material.dart';
import 'package:post_office/post_box.dart';
import 'package:post_office/post_office.dart';

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

class PostOfficeApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return PostOffice(
      child: MaterialApp(
        home: LoginPage(),
      ),
    );
  }
}

class LoginPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Login"),
      ),
      body: PostBox(
        child: Center(
          child: RaisedButton(
            child: Text("Start registration"),
            onPressed: () {
              Navigator.push(context,
                  MaterialPageRoute(builder: (context) => RegisterPage()));
            },
          ),
        ),
      ),
    );
  }
}

class RegisterPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Registration"),
      ),
      body: PostBox(
        child: Center(
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: <Widget>[
              RaisedButton(
                child: Text("Invalid Registration"),
                onPressed: () => PostOffice.of(context)
                    .send("Invalid Registration", type: MessageType.error),
              ),
              RaisedButton(
                child: Text("Valid Registration"),
                onPressed: () {
                  Navigator.pop(context);
                  PostOffice.of(context)
                      .send("Valid Registration", type: MessageType.success);
                },
              )
            ],
          ),
        ),
      ),
    );
  }
}
4
likes
30
pub points
0%
popularity

Publisher

verified publisherstefangaller.at

Simply post messages from anywhere in your app to PostBox widgets and display them.

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on post_office