ve_apm 3.0.4 copy "ve_apm: ^3.0.4" to clipboard
ve_apm: ^3.0.4 copied to clipboard

A flutter plugin for veMars APM.

example/lib/main.dart

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:ve_apm/ve_apm.dart';

import 'common/router.dart';
import 'pages/home_page.dart';

void main() {
  runTraceApp((observer) {
    HttpOverrides.global = ApmHttpOverrides();
    enableVeApmLog(true);
    return MyApp(observer);
  }, bindingInitHandler: CustomFlutterBinding.ensureInitialized);
}

mixin MixinFlutterBinding on ApmWidgetsFlutterBinding {
  @override
  void initInstances() {
    super.initInstances();
    print('MixinFlutterBinding initInstances');
  }

  @override
  void handleAppLifecycleStateChanged(AppLifecycleState state) {
    super.handleAppLifecycleStateChanged(state);
    print('MixinFlutterBinding handleAppLifecycleStateChanged');
  }
}

class CustomFlutterBinding extends ApmWidgetsFlutterBinding
    with MixinFlutterBinding {
  static WidgetsBinding? ensureInitialized() {
    // if (WidgetsBinding.instance == null) {
      CustomFlutterBinding();
    // }
    return WidgetsBinding.instance;
  }
}

class MyApp extends StatefulWidget {
  MyApp([this._navigatorObserver]);

  NavigatorObserver? _navigatorObserver;

  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: HomePage(),
      navigatorObservers: <NavigatorObserver>[
        widget._navigatorObserver ?? ApmNavigatorObserver.instance
      ],
      routes: generateRoutes(),
    );
  }
}
0
likes
0
pub points
43%
popularity

Publisher

verified publishervolcengine.com

A flutter plugin for veMars APM.

Homepage

License

unknown (license)

Dependencies

flutter, mockito

More

Packages that depend on ve_apm