banners 0.1.0 copy "banners: ^0.1.0" to clipboard
banners: ^0.1.0 copied to clipboard

outdated

Package for dynamically displaying global banners at the top of the screen.

example/lib/main.dart

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

import 'banners.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return BannerBackend(
      child: MaterialApp(
        routes: {
          '/': (_) => FirstPage(),
          '/second': (_) => SecondPage(),
        },
      ),
    );
  }
}

class FirstPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Banners(
      child: Scaffold(
        appBar: AppBar(title: Text('First page')),
        body: Buttons(),
        floatingActionButton: FloatingActionButton(
          onPressed: () => Navigator.of(context).pushNamed('/second'),
          child: Icon(Icons.beach_access),
        ),
      ),
    );
  }
}

class SecondPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Banners(
      child: Scaffold(
        appBar: AppBar(title: Text('Second page')),
        body: Buttons(),
      ),
    );
  }
}

class Buttons extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          RaisedButton(
            onPressed: () => context.banners.add(DemoBanner()),
            child: Text('Sign in as demo'),
          ),
          RaisedButton(
            onPressed: () => context.banners.remove(DemoBanner()),
            child: Text('Sign out from demo'),
          ),
          RaisedButton(
            onPressed: () => context.banners.add(OfflineBanner()),
            child: Text('Go offline'),
          ),
          RaisedButton(
            onPressed: () => context.banners.remove(OfflineBanner()),
            child: Text('Go online'),
          ),
        ],
      ),
    );
  }
}
10
likes
0
pub points
80%
popularity

Publisher

unverified uploader

Package for dynamically displaying global banners at the top of the screen.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

collection, flutter

More

Packages that depend on banners