Skip to content

Commit c0a9dc6

Browse files
committed
add demo
1 parent 1559f90 commit c0a9dc6

17 files changed

+630
-5
lines changed

.github/workflows/deploy_demo.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Simple workflow for deploying static content to GitHub Pages
2+
name: Deploy static content to Pages
3+
4+
on:
5+
# Runs on pushes targeting the default branch
6+
push:
7+
branches: ["main"]
8+
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20+
concurrency:
21+
group: "pages"
22+
cancel-in-progress: false
23+
24+
jobs:
25+
# Single deploy job since we're just deploying
26+
deploy:
27+
environment:
28+
name: github-pages
29+
url: ${{ steps.deployment.outputs.page_url }}
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
- uses: subosito/flutter-action@v2
35+
- name: Install deps
36+
run: flutter pub get
37+
working-directory: ./demo
38+
- name: build
39+
run: flutter build web --base-href "/phone_numbers_parser/"
40+
working-directory: ./demo
41+
- name: Setup Pages
42+
uses: actions/configure-pages@v4
43+
- name: Upload artifact
44+
uses: actions/upload-pages-artifact@v3
45+
with:
46+
path: ./demo/build/web
47+
- name: Deploy to GitHub Pages
48+
id: deployment
49+
uses: actions/deploy-pages@v4

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
# You can specify other versions if desired, see documentation here:
2323
# https://github.com/dart-lang/setup-dart/blob/main/README.md
2424
# - uses: dart-lang/setup-dart@v1
25-
- uses: dart-lang/setup-dart
25+
- uses: dart-lang/setup-dart@v1
2626

2727
- name: Install dependencies
2828
run: dart pub get

README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ The advantage of this lib instead of libphonenumber is that it instantly support
66

77
## Features
88

9+
- Validation: Validate based on type (mobile, fixed line, voip)
10+
- Formatting: Format phone number for a specific country
11+
- Phone ranges: find all phone numbers in a range of phone numbers
912
- Find phone numbers in a text
10-
- Validate a phone number
11-
- A light parser for size aware applications
12-
- Formatter
13-
- Phone ranges
1413
- Supports eastern arabic digits
1514
- Uses best-in-class metadata from Google's libPhoneNumber project.
1615

demo/.gitignore

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
**/doc/api/
26+
**/ios/Flutter/.last_build_id
27+
.dart_tool/
28+
.flutter-plugins
29+
.flutter-plugins-dependencies
30+
.pub-cache/
31+
.pub/
32+
/build/
33+
34+
# Symbolication related
35+
app.*.symbols
36+
37+
# Obfuscation related
38+
app.*.map.json
39+
40+
# Android Studio will place build artifacts here
41+
/android/app/debug
42+
/android/app/profile
43+
/android/app/release

demo/.metadata

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: "abb292a07e20d696c4568099f918f6c5f330e6b0"
8+
channel: "stable"
9+
10+
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: abb292a07e20d696c4568099f918f6c5f330e6b0
17+
base_revision: abb292a07e20d696c4568099f918f6c5f330e6b0
18+
- platform: android
19+
create_revision: abb292a07e20d696c4568099f918f6c5f330e6b0
20+
base_revision: abb292a07e20d696c4568099f918f6c5f330e6b0
21+
- platform: ios
22+
create_revision: abb292a07e20d696c4568099f918f6c5f330e6b0
23+
base_revision: abb292a07e20d696c4568099f918f6c5f330e6b0
24+
- platform: linux
25+
create_revision: abb292a07e20d696c4568099f918f6c5f330e6b0
26+
base_revision: abb292a07e20d696c4568099f918f6c5f330e6b0
27+
- platform: macos
28+
create_revision: abb292a07e20d696c4568099f918f6c5f330e6b0
29+
base_revision: abb292a07e20d696c4568099f918f6c5f330e6b0
30+
- platform: web
31+
create_revision: abb292a07e20d696c4568099f918f6c5f330e6b0
32+
base_revision: abb292a07e20d696c4568099f918f6c5f330e6b0
33+
- platform: windows
34+
create_revision: abb292a07e20d696c4568099f918f6c5f330e6b0
35+
base_revision: abb292a07e20d696c4568099f918f6c5f330e6b0
36+
37+
# User provided section
38+
39+
# List of Local paths (relative to this file) that should be
40+
# ignored by the migrate tool.
41+
#
42+
# Files that are not part of the templates will be ignored by default.
43+
unmanaged_files:
44+
- 'lib/main.dart'
45+
- 'ios/Runner.xcodeproj/project.pbxproj'

demo/README.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# demo
2+
3+
A new Flutter project.
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Flutter application.
8+
9+
A few resources to get you started if this is your first Flutter project:
10+
11+
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
12+
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
13+
14+
For help getting started with Flutter development, view the
15+
[online documentation](https://docs.flutter.dev/), which offers tutorials,
16+
samples, guidance on mobile development, and a full API reference.

demo/analysis_options.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
3+
#
4+
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+
# invoked from the command line by running `flutter analyze`.
7+
8+
# The following line activates a set of recommended lints for Flutter apps,
9+
# packages, and plugins designed to encourage good coding practices.
10+
include: package:flutter_lints/flutter.yaml
11+
12+
linter:
13+
# The lint rules applied to this project can be customized in the
14+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15+
# included above or to enable additional rules. A list of all available lints
16+
# and their documentation is published at https://dart.dev/lints.
17+
#
18+
# Instead of disabling a lint rule for the entire project in the
19+
# section below, it can also be suppressed for a single line of code
20+
# or a specific dart file by using the `// ignore: name_of_lint` and
21+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
22+
# producing the lint.
23+
rules:
24+
# avoid_print: false # Uncomment to disable the `avoid_print` rule
25+
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
26+
27+
# Additional information about this file can be found at
28+
# https://dart.dev/guides/language/analysis-options

demo/lib/main.dart

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:phone_numbers_parser/phone_numbers_parser.dart';
3+
4+
void main() {
5+
runApp(const MyApp());
6+
}
7+
8+
class MyApp extends StatelessWidget {
9+
const MyApp({super.key});
10+
11+
@override
12+
Widget build(BuildContext context) {
13+
return MaterialApp(
14+
title: 'Flutter Demo',
15+
theme: ThemeData(
16+
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
17+
useMaterial3: true,
18+
),
19+
home: const MyHomePage(),
20+
);
21+
}
22+
}
23+
24+
class MyHomePage extends StatefulWidget {
25+
const MyHomePage({super.key});
26+
27+
@override
28+
State<MyHomePage> createState() => _MyHomePageState();
29+
}
30+
31+
class _MyHomePageState extends State<MyHomePage> {
32+
PhoneNumber? phoneNumber = PhoneNumber.parse('+16505551234');
33+
34+
@override
35+
Widget build(BuildContext context) {
36+
final phoneNumber = this.phoneNumber;
37+
return Scaffold(
38+
body: Center(
39+
child: ConstrainedBox(
40+
constraints: const BoxConstraints(maxWidth: 600),
41+
child: Column(
42+
children: [
43+
const SizedBox(height: 48),
44+
Text(
45+
'Try a phone number to see the parsing result below',
46+
style: Theme.of(context).textTheme.titleMedium,
47+
),
48+
const SizedBox(height: 12),
49+
TextFormField(
50+
initialValue: phoneNumber?.international,
51+
decoration: const InputDecoration(
52+
label: Text('Phone number'),
53+
),
54+
onChanged: (value) {
55+
setState(() => this.phoneNumber = PhoneNumber.parse(value));
56+
},
57+
),
58+
const SizedBox(height: 12),
59+
ListTile(
60+
title: const Text('international'),
61+
trailing: phoneNumber != null
62+
? Text(phoneNumber.international)
63+
: const Text('-'),
64+
),
65+
ListTile(
66+
title: const Text('Formatted national'),
67+
trailing: phoneNumber != null
68+
? Text(phoneNumber.formatNsn())
69+
: const Text('-'),
70+
),
71+
ListTile(
72+
title: const Text('Iso code'),
73+
trailing: phoneNumber != null
74+
? Text(phoneNumber.isoCode.name)
75+
: const Text('-'),
76+
),
77+
ListTile(
78+
title: const Text('Country Dial Code'),
79+
trailing: phoneNumber != null
80+
? Text(phoneNumber.countryCode)
81+
: const Text('-'),
82+
),
83+
ListTile(
84+
title: const Text('Is Valid'),
85+
trailing: phoneNumber != null
86+
? Text(phoneNumber.isValid().toString())
87+
: const Text('-'),
88+
),
89+
ListTile(
90+
title: const Text('Is Valid Mobile'),
91+
trailing: phoneNumber != null
92+
? Text(phoneNumber
93+
.isValid(type: PhoneNumberType.mobile)
94+
.toString())
95+
: const Text('-'),
96+
),
97+
ListTile(
98+
title: const Text('Is Valid Fixed Line'),
99+
trailing: phoneNumber != null
100+
? Text(phoneNumber
101+
.isValid(type: PhoneNumberType.fixedLine)
102+
.toString())
103+
: const Text('-'),
104+
),
105+
ListTile(
106+
title: const Text('Is Valid Voip'),
107+
trailing: phoneNumber != null
108+
? Text(phoneNumber
109+
.isValid(type: PhoneNumberType.voip)
110+
.toString())
111+
: const Text('-'),
112+
),
113+
],
114+
),
115+
)),
116+
);
117+
}
118+
}

0 commit comments

Comments
 (0)