mohoflutterplugin 0.1.1 copy "mohoflutterplugin: ^0.1.1" to clipboard
mohoflutterplugin: ^0.1.1 copied to clipboard

This is a moho advertisement SDK

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:mohoflutterplugin/mohoflutterplugin.dart';
import 'package:mohoflutterplugin_example/AppConfig.dart';
import 'package:mohoflutterplugin_example/BannerAdPage.dart';
import 'package:mohoflutterplugin_example/DialogAdPage.dart';
import 'package:mohoflutterplugin_example/DrawAdPage.dart';
import 'package:mohoflutterplugin_example/RewardAdPage.dart';
import 'package:mohoflutterplugin_example/SplashAdPage.dart';
import 'package:mohoflutterplugin_example/TemplateFlowAdPage.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(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const HomePage(),
    );
  }
}



class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _MyAppState();
}

class _MyAppState extends State<HomePage> {
  String _platformVersion = 'Unknown';
  final _mohoflutterpluginPlugin = Mohoflutterplugin();

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  Future<void> initPlatformState() async {
    String platformVersion;
    try {
      platformVersion =
          await _mohoflutterpluginPlugin.getMohoNativeSDKVersion() ?? 'Unknown platform version';
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text('Plugin moho example app'),
        ),
        body:Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            TextButton(onPressed: (){
              _mohoflutterpluginPlugin.initMohoSDk(AppConfig.appID, AppConfig.appToken);

            }, child: const Text("Moho初始化")),


            TextButton(onPressed: (){
              Navigator.push(
                context,
                MaterialPageRoute(builder: (context) => const SplashAdPage()),
              );
            }, child: const Text("开屏")),


            TextButton(onPressed: (){
              Navigator.push(
                context,
                MaterialPageRoute(builder: (context) => const BannerAdPage()),
              );
            }, child: const Text("Banner广告位")),
            TextButton(onPressed: (){
              Navigator.push(
                context,
                MaterialPageRoute(builder: (context) => const TemplateFlowAdPage()),
              );
            }, child: const Text("模板信息流广告位")),


            TextButton(onPressed: (){
              Navigator.push(
                context,
                MaterialPageRoute(builder: (context) => const DialogAdPage()),
              );
            }, child: const Text("插屏")),

            TextButton(onPressed: (){
              Navigator.push(
                context,
                MaterialPageRoute(builder: (context) => const RewardAdPage()),
              );
            }, child: const Text("激励视频")),
            TextButton(onPressed: (){
              Navigator.push(
                context,
                MaterialPageRoute(builder: (context) => const DrawAdPage()),
              );
            }, child: const Text("Draw视频流广告")),

            

            Align(alignment: Alignment.center,child: Text('魔盒版本号: $_platformVersion\n'),)

          ],
        )



    );
  }
}
2
likes
130
points
32
downloads

Publisher

unverified uploader

Weekly Downloads

This is a moho advertisement SDK

Homepage

Documentation

API reference

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on mohoflutterplugin