banners 0.2.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 75

Often, you want to be able to dynamically display banners at the top of the screen. This package offers this functionality.

How to use #

Create banners #

Create some banner Widgets. Use the BannerScaffold for automatically setting a color and respecting the status bar padding.

/// Indicates the user is using a demo account.
class DemoBanner extends StatelessWidget {
  Key get key => ValueKey('demo');

  @override
  Widget build(BuildContext context) {
    return BannerScaffold(
      backgroundColor: Colors.yellow,
      body: Padding(
        padding: EdgeInsets.all(8),
        child: Text('This is a demo account.'),
      ),
    );
  }
}

Use banners #

Wrap a widget with Bannered and provide the banner widgets. The MediaQuery's padding will be adjusted correctly.

return Bannered(
  banners: [
    // Some banner widgets.
  ],
  child: Scaffold(...),
);

0.2.0 - 2020-04-18 #

  • Make package more generic so it applies to more use-cases. Focus on the UI part and leave the service management to the developers. That makes it possible for them to use their existing service management solution.

0.1.1 - 2020-04-18 #

  • Loosen dependency on collections.

0.0.1 - 2020-04-18 #

  • Initial release.

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 MaterialApp(
      home: ThePage(),
    );
  }
}

class ThePage extends StatefulWidget {
  @override
  _ThePageState createState() => _ThePageState();
}

class _ThePageState extends State<ThePage> {
  final _banners = <Widget>[];

  @override
  Widget build(BuildContext context) {
    return Bannered(
      banners: _banners,
      child: Scaffold(
        appBar: AppBar(title: Text('First page')),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              RaisedButton(
                onPressed: () => setState(() => _banners.add(DemoBanner())),
                child: Text('Sign in as demo'),
              ),
              RaisedButton(
                onPressed: () => setState(() => _banners.remove(DemoBanner())),
                child: Text('Sign out from demo'),
              ),
              RaisedButton(
                onPressed: () => setState(() => _banners.add(OfflineBanner())),
                child: Text('Go offline'),
              ),
              RaisedButton(
                onPressed: () =>
                    setState(() => _banners.remove(OfflineBanner())),
                child: Text('Go online'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  banners: ^0.2.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:banners/banners.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
49
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]
75
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

because of import path [banners] that is in a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
collection >=1.0.0 <2.0.0 1.14.12 1.14.13
flutter 0.0.0
Transitive dependencies
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8