wmc_plugin 2.0.4 copy "wmc_plugin: ^2.0.4" to clipboard
wmc_plugin: ^2.0.4 copied to clipboard

A new flutter plugin project.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:typed_data';
import 'package:flutter/services.dart';
import 'package:wmc_plugin/wmc_plugin.dart';

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

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

class _MyAppState extends State<MyApp> {
  String _result = 'Unknown';

  @override
  void initState() {
    super.initState();
    /*
     Haber solicitado permiso de READ_PHONE_STATE para el caso de 
     Android ya que por default se envia el codigo de identificador en null en 
     ios no es necesario
     */
    initializeWmc();
    sendRequest();
    //sendPost();
    //sendPut();
    //sendResource();
  }
 
  Future<void> initializeWmc() async {
    String initializeWmc; 
    try {
      initializeWmc = await WmcPlugin.initialize("API_KEY");
    } on PlatformException {
      initializeWmc = 'Failed to initialize WMC.';
    }

    setState(() {
      _result = initializeWmc;
    });
  }

  Future<void> sendRequest() async{ 
    Map result;
    try {
      result = await WmcPlugin.request(
         "http://dummy.restapiexample.com/api/v1/employees",
        "GET",
        { 'content-type': 'application/json' },
        {'abc': '123'},
      );
    } on PlatformException {
      print("Ocurrió un error");
    } catch (e) {
      print("Llegó a este error: ${e.toString()}");
    }
 
    print(result);
    setState(() {
      _result = result.toString();
    }); 
  }

  Future<void> sendResource() async{ 
    Uint8List result;  

    try { 
        result = await WmcPlugin.resource("https://worldmobileconnection.com/wp-content/uploads/2018/03/LOGO-WORLD-MOBILE.png");
    } on PlatformException { 

    } 
    setState(() {
      _result = result.toString();
    }); 
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('Running on: $_result\n'),
        ),
      ),
    );
  }
}
0
likes
110
pub points
36%
popularity

Publisher

unverified uploader

A new flutter plugin project.

Homepage

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on wmc_plugin