huawei_iap 6.14.0+300 copy "huawei_iap: ^6.14.0+300" to clipboard
huawei_iap: ^6.14.0+300 copied to clipboard

PlatformAndroid

HUAWEI IAP Kit plugin for Flutter. Huawei's In-App Purchases (IAP) service allows you to offer in-app purchases and facilitates in-app payment.

example/lib/main.dart

/*
 * Copyright 2020-2024. Huawei Technologies Co., Ltd. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License")
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import 'package:flutter/material.dart';

import 'package:huawei_iap_example/controllers/main_screen_controller.dart';
import 'package:huawei_iap_example/theme/app_theme_data.dart';
import 'package:huawei_iap_example/constants/app_spacing.dart';
import 'package:huawei_iap_example/widgets/home/main_screen_content.dart';

void main() => runApp(
      MaterialApp(
        theme: AppThemeData.buildMainTheme(),
        home: MyApp(),
      ),
    );

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final MainScreenController _controller = MainScreenController();

  @override
  void initState() {
    super.initState();
    _controller.initialize();
  }

  Future<void> environmentCheck() async {
    setState(() {
      _controller.resetEnvironmentStatus();
    });
    await _controller.checkEnvironment();
    setState(() {});
  }

  Future<void> sandboxCheck() async {
    setState(() {
      _controller.resetSandboxStatus();
    });
    await _controller.checkSandbox();
    setState(() {});
  }

  void toggleHmsLogger() {
    setState(() {
      _controller.toggleLogger();
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppThemeData.buildDemoAppBar(),
      body: SingleChildScrollView(
        child: Padding(
          padding: AppSpacing.screenHorizontal,
          child: MainScreenContent(
            controller: _controller,
            onEnvironmentCheck: environmentCheck,
            onSandboxCheck: sandboxCheck,
            onLoggerToggle: toggleHmsLogger,
          ),
        ),
      ),
    );
  }
}
39
likes
160
points
9
downloads

Documentation

API reference

Publisher

verified publisherdeveloper.huawei.com

Weekly Downloads

HUAWEI IAP Kit plugin for Flutter. Huawei's In-App Purchases (IAP) service allows you to offer in-app purchases and facilitates in-app payment.

Homepage
Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

flutter

More

Packages that depend on huawei_iap

Packages that implement huawei_iap