Skip to content

Commit

Permalink
Merge pull request #14 from LunaGao/develop
Browse files Browse the repository at this point in the history
using `Flag` widget to instead of `Flags.getFlag`
  • Loading branch information
Luna Gao authored May 14, 2020
2 parents b2e9760 + 3b5df8a commit 0d4aadb
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 17 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [3.0.0] - Release Flags
* using `Flag` widget to instead of `Flags.getFlag`

## [2.0.4] - Release Flags
* fixed Slovakian flag can not show up error.
* update flutter version to 1.17.1
Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# flag
![Pub Version](https://img.shields.io/pub/v/flag?style=flat-square)
[![Bless](https://img.shields.io/badge/bless-God-brightgreen?style=flat-square)](http://lunagao.github.io/BlessYourCodeTag/)

A flag Flutter package for Android and iOS. Based by https://github.com/dnfield/flutter_svg

Expand All @@ -13,6 +15,9 @@ fetch data :python file is `fetch_data/main.py`

> Update time: 2020-04-21 23:22:58
## Marge from 2.0.X to 3
Replace `Flags.getFlag(country:` to `Flag(`. :)

## Flag list

List is [un_members.txt](./un_members.txt)
Expand All @@ -22,12 +27,12 @@ Organisations

## How to use

`Flags.getFlag(country: COUNTRY_CODE, height: HEIGHT, width: WIDTH),`
`Flag(COUNTRY_CODE, height: HEIGHT, width: WIDTH),`

Such as
* `Flags.getFlag(country: 'AD', height: 100, width: null)`
* `Flags.getFlag(country: 'AD', height: null, width: null)`
* `Flags.getFlag(country: 'AD', height: 10, width: 100, fit: BoxFit.fill)`
* `Flag('AD', height: 100, width: null)`
* `Flag('AD', height: null, width: null)`
* `Flag('AD', height: 10, width: 100, fit: BoxFit.fill)`

## Bugs
* `brazilian` (br) flag, you can see that the letters are still a bit abnormal.
13 changes: 10 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,19 @@ class _MyHomePageState extends State<MyHomePage> {
child: Center(
child: Column(
children: <Widget>[
Flags.getFlag(country: 'AD', height: 100, width: null),
Flag(
'AD',
height: 100,
),
SizedBox(
height: 100,
),
Flags.getFlag(
country: 'AD', height: 10, width: 100, fit: BoxFit.fill),
Flag(
'AD',
height: 10,
width: 100,
fit: BoxFit.fill,
),
],
),
),
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.0.4"
version: "3.0.0"
flutter:
dependency: "direct main"
description: flutter
Expand Down
46 changes: 38 additions & 8 deletions lib/flag.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,44 @@ library flag;
import 'package:flutter/widgets.dart';
import 'package:flutter_svg/flutter_svg.dart';

/// A Flags.
class Flags {
/// get flag
static Widget getFlag(
{@required String country,
@required double height,
@required double width,
BoxFit fit = BoxFit.contain}) {
/// A run of Flag.
class Flag extends StatelessWidget {

/// The flag to display.
///
/// This value listed in https://github.com/LunaGao/flag_flutter/blob/master/un_members.txt.
final String country;

/// If non-null, requires the child to have exactly this height.
final double height;

/// If non-null, requires the child to have exactly this width.
final double width;

/// How to inscribe the flag into the space allocated during layout.
///
/// The default value is [BoxFit.contain].
final BoxFit fit;

/// Creates a flag widget.
///
/// If the [fit] argument is null, the text will use the [BoxFit.contain].
///
/// The [country] parameter must not be null.
Flag(
this.country, {
Key key,
this.height,
this.width,
this.fit = BoxFit.contain,
}) : assert(
country != null,
'The Country must be provided.',
),
super(key: key);

@override
Widget build(BuildContext context) {
String countryName = country.toLowerCase();
String assetName = 'packages/flag/res/flag/' + countryName + '.svg';
return Container(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flag
description: A flag Flutter package. Use for showing flags. All flags came from https://www.un.org/en/member-states/index.html .
version: 2.0.4
version: 3.0.0
homepage: https://github.com/LunaGao/flag_flutter

environment:
Expand Down

0 comments on commit 0d4aadb

Please sign in to comment.