version_banner 0.2.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 68

Version Banner #

An app Banner Widget that shows the current app version. Can be used with App Flavors to show what flavor of the app is currently being used.

Getting Started #

This widget should wrap MaterialApp or CupertinoApp.

Example

VersionBanner(
          text: "Yay!",
          packageExtensions: [".dev"],
          child: MaterialApp(
                       debugShowCheckedModeBanner: false,
                       title: 'Flutter Demo',
                       theme: ThemeData(
                         primarySwatch: Colors.blue,
                       ),
                       home: MyHomePage(title: 'Flutter Demo Home Page'),
                     )
      );

packageExtensions will check the app's package name with the given array. If the package name contains part of the String in the array, then the banner is visible.

The following properties can be changed:

  • color - Banner's color
  • textStyle - Banner's text style
  • text - The text to appear. If set to null will show the pubspec version
  • location - the banner's location on the screen, based on the class BannerLocation
  • packageExtensions - will check the app's package name with the given array. If the package name contains part of the String in the array, then the banner is visible.
  • visible - decides if the banner is visible or not. If set to false, it overrides the packageExtensions attribute

[0.2.0]

  • Added visibility, and validation with package name, given an array of strings, to check if the banner is visible or not.

[0.1.0]

  • Initial release

example/README.md

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

void main() {
  bool isDevVersion = true;
  runApp(MyApp(isDevVersion));
}

class MyApp extends StatelessWidget {
  bool isDevVersion;


  MyApp(this.isDevVersion);

  @override
  Widget build(BuildContext context) {
    var materialApp = MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );

    if (isDevVersion) {
      return VersionBanner(
        packageExtensions: ["example"],
          child: materialApp
      );
    }

    return materialApp;
  }
}

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

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

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.display1,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}


Use this package as a library

1. Depend on it

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


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

We analyzed this package on Oct 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/version_banner.dart. (-0.50 points)

Analysis of lib/version_banner.dart reported 1 hint:

line 27 col 7: This class (or a class which this class inherits from) is marked as '@immutable', but one or more of its instance fields are not final: VersionBanner.child, VersionBanner.location, VersionBanner.textStyle, VersionBanner.text, VersionBanner.color, VersionBanner.visible, VersionBanner.packageExtensions

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
package_info ^0.4.0+4 0.4.0+9
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test