inspectable 0.1.1 copy "inspectable: ^0.1.1" to clipboard
inspectable: ^0.1.1 copied to clipboard

Inspectable visualizes the widget tree on running devices for debugging or research purpose.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:inspectable/inspectable.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Inspectable Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Inspectable(
        child: MyHomePage(),
        colors: {
          Text: Colors.blue,
          Stack: Colors.teal,
          TextButton: Colors.brown,
          Material: Colors.red,
        },
      ),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Inspectable Sample'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
            const SizedBox(height: 60),
            Inspectable(
              child: InspectButton(
                key: ValueKey('InspectTestKey'),
              ),
              verbose: true,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}

class InspectButton extends StatelessWidget {
  const InspectButton({
    Key? key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return TextButton(
      onPressed: () {
        Inspectable.of(context).inspect();
      },
      child: Text(
        'INSPECT',
        style: TextStyle(fontSize: 24),
      ),
    );
  }
}
8
likes
150
points
25
downloads

Publisher

unverified uploader

Weekly Downloads

Inspectable visualizes the widget tree on running devices for debugging or research purpose.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter

More

Packages that depend on inspectable