void main() => runApp(const MyApp());
class _MyAppState extends State<MyApp> {
final TextEditingController _numberCtrl = TextEditingController();
bool _isLoading = false;
@override
void initState() {
super.initState();
_numberCtrl.text = "17752170152"; // 默认号码初始化
}
}
MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('phone_direct_caller')),
body: Column(
children: [
TextField(
controller: _numberCtrl,
keyboardType: TextInputType.number
),
_buildCallButton(context)
]
)
)
)
Future<void> _handleCall() async {
final status = await Permission.phone.request();
if (status.isGranted) {
final success = await FlutterPhoneDirectCaller.callNumber(_numberCtrl.text);
// 结果反馈处理
}
}
完整实现展示了 Flutter 应用开发的核心模式:状态管理、插件集成、Material Design 组件应用和异步操作处理。
name: phone_direct_caller
description: Demonstrates how to use the flutter_phone_direct_caller plugin.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.12.0 <4.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class foriOSstyleicons.
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: 1.0.4
# ForinformationonthegenericDartpartofthisfile, seethe
# followingpage: https://dart.dev/tools/pub/pubspec
dependency_overrides:
flutter_phone_direct_caller:
git:
url: "https://gitcode.com/openharmony-sig/fluttertpc_flutter_phone_direct_caller.git"
permission_handler:
git:
url: "https://gitcode.com/openharmony-sig/flutter_permission_handler.git"
path: "permission_handler/"
# ThefollowingsectionisspecifictoFlutter.
flutter:
坚果派由坚果等人创建,团队拥有若干华为 HDE,以及若干其他领域的三十余位万粉博主运营。专注于分享的技术包括 HarmonyOS/OpenHarmony,ArkUI-X,元服务,服务卡片,仓颉,BlueOS 操作系统、团队成员聚集在北京、上海、广州、深圳、南京、杭州、苏州、宁夏,天津,福建,武汉等地。 聚焦“鸿蒙原生应用”、“智能物联”和“AI 赋能”、“人工智能”四大业务领域,依托华为开发者专家等强大的技术团队,以及涵盖需求、开发、测试、运维于一体的综合服务体系,赋能文旅、媒体、社交、家居、消费电子等行业客户,满足社区客户数字化升级转型的需求,帮助客户实现价值提升。 目前上架鸿蒙原生应用 40 款,三方库 80 个。官网:https://www.nutpi.net/,