finotescoreplugin 8.0.1 copy "finotescoreplugin: ^8.0.1" to clipboard
finotescoreplugin: ^8.0.1 copied to clipboard

Detect and report bugs in Flutter based mobile apps. Reports issues like memory leaks, crashes, ANR and exceptions. Plugin has low memory and size footprint.

example/lib/main.dart

import 'dart:async';
import 'dart:convert';

import 'package:finotescoreplugin/finotescoreplugin.dart';
import 'package:finotescoreplugin/fn_client.dart';
import 'package:finotescoreplugin/state_custom.dart';
import 'package:finotescoreplugin/observe.dart';
import 'package:flutter/material.dart';


void main() {
  runApp(const MyRootApp());

  WidgetsFlutterBinding
      .ensureInitialized(); //Make sure to execute 'ensureInitialized' before executing Fn.init().

  Fn.logMe();
  Fn.init(); //Need to call this function to activate plugin.
  Observe().setMaskedHeaders(["connection"]);
  Observe().setWhiteListedDomain(["jsonplaceholder.typicode.com"]);
  Observe().setBaseUrlTimeouts({
    "jsonplaceholder.typicode.com": 1000
  }); //Timeout value(s) should be greater than or equal to 1000.
}

class MyRootApp extends StatelessWidget {
  const MyRootApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: const MyScreenApp(),
    );
  }
}

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

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

class _MyAppState extends FnInitialState<MyScreenApp> {
  //Replace 'State' class with 'FnState' to allow finotescore plugin to track lifecycle methods.
  int _counter = 0;

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

  }

  void fetchTodoWithHttpClient() async {
    var client = FnClient(); //Replace your http client with finotescore client.
    
    try {
      var response = await client
          .get(Uri.https('jsonplaceholder.typicode.com', 'todos/1'));
      var decodedResponse = jsonDecode(utf8.decode(response.bodyBytes)) as Map;
      print(decodedResponse);
    } finally {
      client.close();
    }
  }


  void _incrementCounter(BuildContext context) {
    Fn.test();
    if(_counter <= 0){
      fetchTodoWithHttpClient();
    }

    setState(() {
      _counter++;
    });
    Fn.setActivityMarkerAt("Main",
        "User tapped on increment counter"); //Set actvivity markers to get context on issues.

    runZonedGuarded(() async {
      throw Exception(); //Line with exception.
    }, (error, stackTrace) {
      Fn.reportError(
          error, stackTrace); //Single line API to report guarded errors.
    });
  }

  @override
  Widget build(BuildContext context) {
    super.build(context);
    return Scaffold(
      appBar: AppBar(
        title: const Text('Plugin example app'),
      ),
      body: Center(
        child: Text('Run $_counter'),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          _incrementCounter(context);
        },
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
0
likes
130
pub points
52%
popularity

Publisher

unverified uploader

Detect and report bugs in Flutter based mobile apps. Reports issues like memory leaks, crashes, ANR and exceptions. Plugin has low memory and size footprint.

Homepage

Documentation

API reference

License

unknown (license)

Dependencies

flutter, http, plugin_platform_interface, stack_trace, uuid

More

Packages that depend on finotescoreplugin