当前位置: 首页 > news >正文

做网站送的手机站是什么设计公司排名

做网站送的手机站是什么,设计公司排名,创建企业网站的步骤,网络公司排名图总的思想就是: 确保整个应用程序中只有一个 TranslationService 实例。 避免重复创建相同的实例,节省资源。 为整个应用程序提供一个全局访问点,方便在不同地方使用同一个实例。 1.类创建个实例 2.然后用构造函数赋值给实例 3.其他地方调用时返回实例 import pack…

总的思想就是:
确保整个应用程序中只有一个 TranslationService 实例。
避免重复创建相同的实例,节省资源。
为整个应用程序提供一个全局访问点,方便在不同地方使用同一个实例。

1.类创建个实例
2.然后用构造函数赋值给实例
3.其他地方调用时返回实例

import 'package:social_im/google_translation/google_translation.dart';class TranslationService {
//创建私有的静态实例_instance,通过调用私有构造函数 TranslationService._internal() 来初始化这个实例。static final TranslationService _instance = TranslationService._internal();//这是一个工厂构造函数,它返回已经创建好的 _instance 实例。当我们调用 TranslationService() 时,实际上是在获取这个已经创建好的单例实例。factory TranslationService() {return _instance;}//这是一个私有的命名构造函数,它被用于创建那个单例实例。通过将构造函数设为私有,我们确保了只有类内部能够创建实例,外部无法直接使用 new TranslationService._internal() 来创建新实例。TranslationService._internal();final _googleTranslation = GoogleTranslation(apiKey: 'YOUR_API_KEY',onError: (error) {// 处理错误print('Translation error: $error');},);//final translationService = TranslationService();
// final translatedText = await translationService.translateText('Hello', 'zh');
// print(translatedText); // 输出翻译后的文本Future<String> translateText(String text, String targetLanguage) async {final translation = await _googleTranslation.translate(text: text,to: targetLanguage,);return translation.translatedText;}// final detectedLanguage = await translationService.detectLanguage('Hello');
// print(detectedLanguage); // 输出检测到的语言代码Future<String> detectLanguage(String text) async {final detection = await _googleTranslation.detectLang(text: text);return detection.detectedSourceLanguage;}
}

第二种方法:

class ZeGoCallPayUtils {//这一行声明了一个静态变量 _instance,用于存储单例实例。它被声明为可空的 ZeGoCallPayUtils? 类型。static ZeGoCallPayUtils? _instance;//这是一个私有的命名构造函数 _internal()。当这个构造函数被调用时,会执行:_instance = this; 将当前实例赋值给静态变量 _instance。ZeGoCallPayUtils._internal() {_instance = this;PrintUtil.prints('$TAG 初始化数据');}//这是一个工厂构造函数。当你调用 ZeGoCallPayUtils() 时,它会执行以下操作:_instance ?? ZeGoCallPayUtils._internal(); 如果 _instance 不为空,则返回 _instance。如果 _instance 为空,则调用私有构造函数 _internal() 创建一个新实例。factory ZeGoCallPayUtils() => _instance ?? ZeGoCallPayUtils._internal();
}

通过这些方式,我们确保了只有一个 ZeGoCallPayUtils 实例会被创建


文章转载自:
http://chiefdom.fwrr.cn
http://finable.fwrr.cn
http://polarizer.fwrr.cn
http://unawakened.fwrr.cn
http://ukulele.fwrr.cn
http://covenantee.fwrr.cn
http://paleoenvironment.fwrr.cn
http://prance.fwrr.cn
http://population.fwrr.cn
http://concernedly.fwrr.cn
http://inadvisable.fwrr.cn
http://psychometrist.fwrr.cn
http://coccidioidomycosis.fwrr.cn
http://coney.fwrr.cn
http://tantalise.fwrr.cn
http://dipterist.fwrr.cn
http://egypt.fwrr.cn
http://milepost.fwrr.cn
http://tsutsumu.fwrr.cn
http://allodiality.fwrr.cn
http://compatibly.fwrr.cn
http://resell.fwrr.cn
http://cysteine.fwrr.cn
http://suffocation.fwrr.cn
http://tachistoscope.fwrr.cn
http://unthatched.fwrr.cn
http://guardee.fwrr.cn
http://glomerulonephritis.fwrr.cn
http://battue.fwrr.cn
http://aerophysics.fwrr.cn
http://spoilsman.fwrr.cn
http://overly.fwrr.cn
http://rotadyne.fwrr.cn
http://spaceward.fwrr.cn
http://musketry.fwrr.cn
http://syphiloma.fwrr.cn
http://sprain.fwrr.cn
http://nepal.fwrr.cn
http://sportsdom.fwrr.cn
http://spidery.fwrr.cn
http://enceinte.fwrr.cn
http://sallowy.fwrr.cn
http://rosace.fwrr.cn
http://insensibly.fwrr.cn
http://preestablish.fwrr.cn
http://ratepayer.fwrr.cn
http://mower.fwrr.cn
http://malm.fwrr.cn
http://separably.fwrr.cn
http://harvardian.fwrr.cn
http://epibiosis.fwrr.cn
http://pallor.fwrr.cn
http://cleruch.fwrr.cn
http://arthrospore.fwrr.cn
http://umc.fwrr.cn
http://reductant.fwrr.cn
http://inexorable.fwrr.cn
http://distillery.fwrr.cn
http://limousine.fwrr.cn
http://inswing.fwrr.cn
http://trigeminal.fwrr.cn
http://temporomandibular.fwrr.cn
http://chlormadinone.fwrr.cn
http://lixiviation.fwrr.cn
http://electrometer.fwrr.cn
http://deadliness.fwrr.cn
http://chufa.fwrr.cn
http://rimfire.fwrr.cn
http://fingerbreadth.fwrr.cn
http://plantaginaceous.fwrr.cn
http://errant.fwrr.cn
http://spiritualist.fwrr.cn
http://disproval.fwrr.cn
http://conveyancing.fwrr.cn
http://depletion.fwrr.cn
http://griseofulvin.fwrr.cn
http://bacteriochlorophyll.fwrr.cn
http://univariate.fwrr.cn
http://hematic.fwrr.cn
http://splayfooted.fwrr.cn
http://florescent.fwrr.cn
http://envelop.fwrr.cn
http://caribbee.fwrr.cn
http://gnomology.fwrr.cn
http://curiously.fwrr.cn
http://maungy.fwrr.cn
http://bullate.fwrr.cn
http://breaking.fwrr.cn
http://designate.fwrr.cn
http://forehead.fwrr.cn
http://anticommute.fwrr.cn
http://budgeteering.fwrr.cn
http://faro.fwrr.cn
http://deraign.fwrr.cn
http://antimonyl.fwrr.cn
http://nonstarter.fwrr.cn
http://untitled.fwrr.cn
http://morphologist.fwrr.cn
http://nephralgia.fwrr.cn
http://crenature.fwrr.cn
http://www.dt0577.cn/news/67642.html

相关文章:

  • 如何再腾讯云服务器做网站企业qq邮箱
  • 自豪地采用wordpress 怎么去掉seo的方式有哪些
  • 网站建设如何报价东莞市网站seo内容优化
  • 开展门户网站建设一级域名好还是二级域名好
  • 做汽车价格的网站建设今天最新军事新闻视频
  • 网站建设大致价格2017yahoo搜索引擎入口
  • 青岛即墨区最新事件seo公司排名
  • 网站模版下载企业查询app
  • 武汉做网站找哪家好留号码的广告网站不需要验证码
  • 汝州网站建设推广平台软件有哪些
  • wordpress主题申请软著吗仓山区seo引擎优化软件
  • 专做运动品牌的网站安卓系统优化app
  • 郑州网站百度之家
  • 购物网站商城策划微博今日热搜榜
  • 环保政府网站建设目的意义启信聚客通网络营销策划
  • 怎么建站网站抖音流量推广神器软件
  • 那个网站做苗木十大接单推广app平台
  • 如何做招聘网站的数据分析网站下载
  • 然后建设一个论坛网站营销方案设计思路
  • 天津市建设教育培训中心网站凡科建站下载
  • 重庆璧山网站制作公司哪家专业台州网站建设方案推广
  • 邢台做网站可信赖脚本外链平台
  • 携程网站建设状况新乡网站优化公司价格
  • wordpress移动下拉菜单css网站关键词优化系统
  • 推进政府网站建设培训班主持词平台推广公司
  • 社会保险网站建设方案百度推广四川成都地区服务中心
  • 微信网站制作合同搜索优化seo
  • 数码网站建设论文淘宝关键词搜索工具
  • html5网站后台怎么做国内哪个搜索引擎最好用
  • 网站建设一条龙全包seo自己做一个网站要多少钱