Flutter plugin for scanning and generating QR codes using the ZXing library, supporting Android, iOS, and desktop platforms
flutterbarcode-generatorbarcode-scannergeneratorqrqrcodeqrcode-generatorqrcode-scannerscannerzxingbarcodezxscanner
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.5 KiB
64 lines
1.5 KiB
3 years ago
|
import 'package:flutter/material.dart';
|
||
3 years ago
|
|
||
|
extension LocaleParsing on String {
|
||
|
Locale parseLocale() {
|
||
|
assert(contains('_') == true);
|
||
|
var languageCode = split('_').first;
|
||
|
var countryCode = split('_').last;
|
||
|
return Locale.fromSubtags(
|
||
|
languageCode: languageCode, countryCode: countryCode);
|
||
|
}
|
||
|
|
||
|
String toLangIcon() {
|
||
|
assert(length == 2);
|
||
|
switch (toLowerCase()) {
|
||
|
case 'us':
|
||
|
case 'en':
|
||
|
return '🇺🇸';
|
||
|
case 'ru':
|
||
|
return '🇷🇺';
|
||
|
case 'am':
|
||
|
case 'hy':
|
||
|
return '🇦🇲';
|
||
|
default:
|
||
|
return '🇺🇸';
|
||
|
}
|
||
|
}
|
||
|
|
||
|
String toLangName() {
|
||
|
assert(length == 2);
|
||
|
switch (toLowerCase()) {
|
||
|
case 'us':
|
||
|
case 'en':
|
||
3 years ago
|
return '${toLangIcon()} English';
|
||
3 years ago
|
case 'ru':
|
||
3 years ago
|
return '${toLangIcon()} Русский';
|
||
3 years ago
|
case 'am':
|
||
|
case 'hy':
|
||
3 years ago
|
return '${toLangIcon()} Հայերեն';
|
||
3 years ago
|
default:
|
||
3 years ago
|
return '${toLangIcon()} English';
|
||
3 years ago
|
}
|
||
|
}
|
||
|
|
||
|
String toLangCode() {
|
||
|
assert(contains('_') == true);
|
||
|
return split('_').first;
|
||
|
}
|
||
|
}
|
||
3 years ago
|
|
||
|
// context extension to show a toast message
|
||
|
extension ContextExtension on BuildContext {
|
||
|
void showToast(String message) {
|
||
|
ScaffoldMessenger.of(this).hideCurrentSnackBar();
|
||
|
ScaffoldMessenger.of(this).showSnackBar(
|
||
|
SnackBar(
|
||
|
content: Padding(
|
||
|
padding: const EdgeInsets.only(bottom: 30.0),
|
||
|
child: Text(message, textAlign: TextAlign.center),
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|