搜尋套件、儲存庫與 APP 分類

套件詳情v1.0.4

ccp_dialog

CCP Dialog 套件用於在對話框和底端表單中顯示國家代碼、旗幟、貨幣和貨幣ISO。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
80
喜歡數
28
Pub 分數
140

安裝套件

flutter pub add ccp_dialog

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

CCP Dialog 是一個 Flutter 套件,專門用於以對話框或底部彈出面板的形式顯示國家資訊,例如國家代碼、國旗、貨幣及貨幣 ISO。它簡化了在應用程式中整合國家選擇功能的過程,為使用者提供乾淨且可自訂的介面來選擇國家。適用於需要地區特定資料輸入的國際化應用,支援 Android、iOS、Web、macOS、Windows 與 Linux 等多個平台。此套件透過在選擇過程中提供旗幟與貨幣細節等視覺提示,提升使用者體驗。

適用情境

  • 國際應用入門
  • 帶國家選擇的電話號碼輸入
  • 貨幣感知表單輸入
  • 多區域電子商務應用
  • 旅行和物流應用

主要特色

  • 顯示國家旗幟和代碼
  • 顯示貨幣和貨幣ISO
  • 支援對話框與底部彈出式面板模式
  • 跨平台相容性
  • 可自訂的 UI 元素
  • 透過 pub add 輕鬆整合

適合對象

  • 開發全球應用的開發者
  • 需要國家選擇的應用
  • 需要區域資料的表單建構器
  • 具有本地化需求的行動與Web應用
  • 以使用者體驗為導向的介面

使用建議

  • 需要互聯網以取得完整的國家資料(若為動態)
  • 可能需要針對非英文地區進行自訂
  • 限於預定義的國家清單
  • 大資料集的效能影響
  • 不適合用於僅離線使用的案例

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Flutter CCP dialog

Features

Flexible CCP dialog for getting Country code, Calling code, isoCode and Currency in Dialog and Bottom sheet.


# Installation
  1. Add the latest version of package to your pubspec.yaml (and dart pub get):
dart
  dependencies:
    flutter:
      sdk: flutter
    ccp_dialog: any
  1. Import the package and use it in your App.

Usage Example

import 'package:ccp_dialog/country_picker/flutter_country_picker.dart';

Example

import 'package:ccp_dialog/country_picker/flutter_country_picker.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Country Piker Dialog'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String countryCode ="+91";
  Country selectedCountry = Country.IN;

  _updateCountry(Country country){
    selectedCountry = country;
    countryCode = "+${country.dialingCode}";
    setState(() {

    });
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'Select Country',
            ),
            Container(
                height: 45,
                 width: MediaQuery.of(context).size.width/2,
                decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(30),
                    color: Colors.white),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                   CountryPicker(
                      selectedCountry: selectedCountry,
                      dense: true ,
                       //displays arrow, true by default
                      showLine: true,
                       //displays line, false by default If dense true Line not show
                      showFlag: false,
                       //displays flag, true by default
                         showFlagCircle: true,
                       //displays flagCircle, false by default
                      dialingCodeTextStyle:const TextStyle(fontSize: 18),
                      showDialingCode: true,
                      //displays dialing code, false by default
                      showName: false,
                       //displays Name, true by default
                      withBottomSheet: true,
                      //displays country name, true by default
                      showCurrency: false,
                      //eg. 'British pound'
                      showCurrencyISO: false,
                      onChanged:_updateCountry
                   ),
                   const Text('9876541230',style: TextStyle(fontSize: 20),),
                ]))
          ],
        ),
      ),
    );
  }
}

Using Getx

Example:-

  Rx<Country> selectedCountry = Country.IN.obs;
  var countryCode = "+91".obs;
  updateCountry(Country country)
  {
      selectedCountry.value = country;
      countryCode.value = "+" + country.dialingCode.toString();
  }
  Obx(
  () => CountryPicker(
  selectedCountry: _controller.selectedCountry.value,
  dense: false,
  showFlag: false,
  showFlagCircle: true,
  showDialingCode: true,                                      
  showName: false,
  showCurrency: false,                                         
  showCurrencyISO: false,
  onChanged: _controller.updateCountry
  ),
 )

How to get Default Country

Country? country =  await getCountryByCountryCode(Get.context!, '+91');

Future<Country?> getCountryByCountryCode(BuildContext context, String countryCode) async {
const list = Country.ALL;
return list.firstWhere((element) => element.dialingCode == countryCode);
}

simulator_screenshot_24795F01-DE84-46B5-977D-C23CED7D1EE1

Simulator Screen Shot - iPhone 14 - 2023-05-31 at 15 11 38

Simulator Screen Shot - iPhone 14 - 2023-05-31 at 15 12 12

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。