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

discontinued
PlatformAndroidiOS

Flipper (Extensible mobile app debugger) for flutter.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_flipperkit/flutter_flipperkit.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:uuid/uuid.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  FlipperClient flipperClient = FlipperClient.getDefault();

  flipperClient.addPlugin(new FlipperNetworkPlugin());
  flipperClient.addPlugin(new FlipperSharedPreferencesPlugin());
  // flipperClient.addPlugin(new FlipperDatabaseBrowserPlugin());
  flipperClient.addPlugin(new FlipperReduxInspectorPlugin());
  flipperClient.start();

  runApp(MyApp());
}

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

class _MyAppState extends State<MyApp> {
  void _testNetwork() {
    FlipperNetworkPlugin flipperNetworkPlugin =
        FlipperClient.getDefault().getPlugin("Network") as FlipperNetworkPlugin;

    String uniqueId = new Uuid().v4();
    RequestInfo requestInfo = new RequestInfo(
      requestId: uniqueId,
      timeStamp: new DateTime.now().millisecondsSinceEpoch,
      uri: 'https://example.com/account/login',
      headers: new Map()..putIfAbsent("Content-Type", () => "application/json"),
      method: 'POST',
      body: new Map()
        ..putIfAbsent("username", () => "example")
        ..putIfAbsent("password", () => "123456"),
    );

    flipperNetworkPlugin.reportRequest(requestInfo);

    ResponseInfo responseInfo = new ResponseInfo(
      requestId: uniqueId,
      timeStamp: new DateTime.now().millisecondsSinceEpoch,
      statusCode: 200,
      headers: new Map()..putIfAbsent("Content-Type", () => "application/json"),
      body: new Map()
        ..putIfAbsent("username", () => "lijy91")
        ..putIfAbsent("age", () => 28)
        ..putIfAbsent("name", () => "LiJianying"),
    );

    flipperNetworkPlugin.reportResponse(responseInfo);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          children: <Widget>[
            ListTile(
              title: Text("Preferences"),
              onTap: () async {
                SharedPreferences prefs = await SharedPreferences.getInstance();
                int counter = (prefs.getInt('counter') ?? 0) + 1;
                await prefs.setInt('counter', counter);
              },
            ),
            ListTile(
              title: Text("Network"),
              onTap: this._testNetwork,
            ),
            ListTile(
              title: Text("ReduxInspector"),
              onTap: () {
                FlipperReduxInspectorPlugin flipperReduxInspectorPlugin =
                    FlipperClient.getDefault()
                            .getPlugin("flipper-plugin-reduxinspector")
                        as FlipperReduxInspectorPlugin;

                ActionInfo actionInfo = ActionInfo(
                  uniqueId: new Uuid().v4(),
                  actionType: 'LoginSuccess',
                  timeStamp: new DateTime.now().millisecondsSinceEpoch,
                  payload: new Map()
                    ..putIfAbsent("username", () => "lijy91@foxmail.com")
                    ..putIfAbsent("password", () => "123456"),
                  nextState: new Map()
                    ..putIfAbsent("user", () => {"name": "LiJianying"}),
                );
                flipperReduxInspectorPlugin.report(actionInfo);
              },
            ),
          ],
        ),
      ),
    );
  }
}
37
likes
130
points
427
downloads

Publisher

verified publisherlearn-flutter.dev

Weekly Downloads

Flipper (Extensible mobile app debugger) for flutter.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, uuid

More

Packages that depend on flutter_flipperkit