flutter_addtoapp_bridge 1.0.0 copy "flutter_addtoapp_bridge: ^1.0.0" to clipboard
flutter_addtoapp_bridge: ^1.0.0 copied to clipboard

flutter addtoapp bridge for flutter call android/ios. so code in flutter page can open native page by this bridge.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:flutter_addtoapp_bridge/flutter_addtoapp_bridge.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

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

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

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

  // 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 FlutterAddtoappBridge.getPlatformVersion() ?? 'Unknown platform version';
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    try {
      dynamic result = await FlutterAddtoappBridge.open("toast", "Hi, I am from flutter!");
      if (kDebugMode) {
        print("putPlatformValue result=$result");
      }
    } 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('flutter addtoapp bridge example'),
        ),
        body: Center(
          child: GestureDetector(
            onTap: () {
              initPlatformState();
            },
            child: Text('Running on: $_platformVersion\n'),
          ),
        ),
      ),
    );
  }
}
0
likes
0
pub points
0%
popularity

Publisher

verified publishercodesdancing.com

flutter addtoapp bridge for flutter call android/ios. so code in flutter page can open native page by this bridge.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_addtoapp_bridge