nan_common_utils 0.0.29 copy "nan_common_utils: ^0.0.29" to clipboard
nan_common_utils: ^0.0.29 copied to clipboard

outdated

A new Flutter project.

example/lib/main.dart

import 'dart:io';

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:nan_common_utils/nan_common_utils.dart';
import 'package:nan_common_utils/nan_map_widget.dart';
import 'package:nan_common_utils/nan_message_channel.dart';
import 'package:nan_common_utils/nan_util.dart';

const VIEW_TYPE = 'com.amap.flutter.map';
void main() {
  runApp(MyApp());
}

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  String address="地址";

  @override
  void initState() {
    super.initState();
    // initPlatformState();
    // messageChannel.setMessageHandler((message)async{
    //   // setState(() {
    //   //   address = message.address;
    //   // });
    //   // NanUtil.showUploadDialog(context,tipMsg: "正在加载中...");
    //   setState(() {
    //     address = message["address"];
    //   });
    // });
    NanMessageChannel.setMessageHandlerFun(result: (message){
      print(message);
    });
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  // Future<void> initPlatformState() async {
  //   String platformVersion;
  //   // Platform messages may fail, so we use a try/catch PlatformException.
  //   // We also handle the message potentially returning null.
  //   try {
  //     platformVersion =
  //         await NanCommonUtils.platformVersion ?? 'Unknown platform version';
  //   } on PlatformException {
  //     platformVersion = 'Failed to get platform version.';
  //   }

  //   // If the widget was removed from the tree while the asynchronous platform
  //   // message was in flight, we want to discard the reply rather than calling
  //   // setState to update our non-existent appearance.
  //   if (!mounted) return;

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
          actions: [
            new Builder(
              builder: (context){
                return InkWell(
                  child: Container(
                    margin: EdgeInsets.only(right: 10),
                    alignment: Alignment.center,
                    child: Text("确定"),
                  ),
                  onTap: (){
                    // messageChannel.send({"method":'haha'});
                    NanMessageChannel.returnResult();
                  },
                ); 
              },
            )
          ],
        ),
        // body: Center(
        //   child: Text('Running on: $_platformVersion\n'),
        // ),
        // body: Column(
        //   children: [
        //     Container(
        //       child: Text("$address",style: TextStyle(fontSize: 20),),
        //       width: NanUtil.kScreenWidth,
        //       constraints: BoxConstraints(
        //         minHeight: 20
        //       ),
        //     ),
        //     Expanded(child: SizedBox(
        //       width: NanUtil.kScreenWidth,
        //       height: 200,
        //       child: Platform.isIOS?UiKitView(
        //       viewType: VIEW_TYPE,
        //       // onPlatformViewCreated: onPlatformViewCreated,
        //       // gestureRecognizers: gestureRecognizers,
        //       creationParams: creationParams,
        //       creationParamsCodec: const StandardMessageCodec(),
        //     ):AndroidView(
        //       viewType: VIEW_TYPE,
        //       creationParams: creationParams,
        //       creationParamsCodec: const StandardMessageCodec(),
        //     ),
        //     ))
        //   ],
        // ),
        body: NanMapWidget(radius: 20,path: 'res',),
      ),
    );
  }

  final Map<String, dynamic> creationParams = <String, dynamic>{
      'apiKey': "您的appkey",
    };

}