flavorbanner 0.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 58

flavorbanner #

Flavor Banner is a package that make easy to configure flavors and add a banner to show info about device.

ScreenShots #

Alt screenshot-1 Alt screenshot-2

Usage #

  • install

Add to yaml

dependencies:
  flavorbanner: $latest_version
  • create mains

You have to create different mains for your flavors, for example:

main_test.dart

main_development.dart

main_staging.dart

main_production.dart

  • import
import 'package:flavorbanner/flavor_config.dart';
  • create mains

Each one of your mains have to look like this:

void main() {
  FlavorConfig(
    flavor: Flavor.DEV,
    color: Colors.grey,
    values: FlavorValues(
      baseUrl: "https://dev.com/",
      showBanner: true,
    ),
  );
  runApp(MyApp());
}

The allowed flavor types are TEST, DEV, STAGING, PROD

enum Flavor { TEST, DEV, STAGING, PROD }

You usually does not want to show banner in production so you can set showbanner value to false.

void main() {
  FlavorConfig(
    flavor: Flavor.PROD,
    color: Colors.grey,
    values: FlavorValues(
      baseUrl: "https://dev.com/",
      showBanner: false,
    ),
  );
  runApp(MyApp());
}
  • wrap app in FlavorBanner

In order to show your banner in all pages you have to update your materialApp builder like this

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: FirstPage(),
      builder: (context, child) => FlavorBanner(
        child: child,
      ),
    );
  }
}
  • use values

By default, you can only set baseUrl and showbanner per flavor. You can get this configuration in any place of your app using this:

Text(FlavorConfig.instance.values.baseUrl)
  • extend values

You can use your own config values, for example:

import 'package:flavorbanner/flavor_config.dart';

class CustomValues extends FlavorValues {
  CustomValues({
    this.baseUrl,
    this.showBanner = false,
    this.mapsApiKey,
  }) ;

  final String baseUrl, mapsApiKey;
  final bool showBanner;
}

Then you can use this in your main:

void main() {
  FlavorConfig(
    flavor: Flavor.PROD,
    color: Colors.red,
    values: CustomValues(
      baseUrl: "https://prod.com/",
      mapsApiKey: 'mapsApiKey',
    ),
  );
  runApp(MyApp());
}

[0.0.2] #

Fix minor bugs.

[0.0.1] #

example/README.md

example #

A new Flutter project.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

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


dependencies:
  flavorbanner: ^0.0.2

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:flavorbanner/enums/build_modes.dart';
import 'package:flavorbanner/flavor_config.dart';
import 'package:flavorbanner/utils/device_utils.dart';
import 'package:flavorbanner/utils/string_utils.dart';
import 'package:flavorbanner/widgets/device_info_dialog.dart';
import 'package:flavorbanner/widgets/flavor_banner.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
28
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
58
Learn more about scoring.

We analyzed this package on Jul 7, 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 does not support Flutter platform linux

Because of import path [package:flavorbanner/utils/device_utils.dart, package:device_info/device_info.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:flavorbanner/utils/device_utils.dart, package:device_info/device_info.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:flavorbanner/utils/device_utils.dart, package:device_info/device_info.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:flavorbanner/utils/device_utils.dart, package:device_info/device_info.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

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

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
device_info ^0.4.2+4 0.4.2+4
flutter 0.0.0
package_info ^0.4.0+18 0.4.1
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test