Files
flame/packages/flame_devtools/lib/widgets/component_counter.dart
Lukas Klingsbo c92910c688 feat: Initial functionality of flame_devtools (#3061)
![image](https://github.com/flame-engine/flame/assets/744771/4ca93f5f-369e-4644-b7fb-1d7790b962e2)

This adds a structure and some basic functionality for the Flame
devtools extension.

Later I will add a pre/post-hook for publishing to Melos so that it can
build the devtools extension before publishing (and remove the directory
afterwards), since it isn't committed to this repository. For now one
has to run `melos devtools-build` before publishing.

---------

Co-authored-by: Renan <6718144+renancaraujo@users.noreply.github.com>
Co-authored-by: Erick <erickzanardoo@gmail.com>
2024-03-05 01:04:43 +01:00

44 lines
1.1 KiB
Dart

import 'package:flame_devtools/repository.dart';
import 'package:flutter/material.dart';
class ComponentCounter extends StatefulWidget {
const ComponentCounter({super.key});
@override
State<ComponentCounter> createState() => _ComponentCounterState();
}
class _ComponentCounterState extends State<ComponentCounter> {
Future<int>? _componentCount;
@override
void initState() {
_componentCount = Repository.getComponentCount();
super.initState();
}
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: _componentCount,
builder: (context, value) {
return Column(
children: [
Text(
value.hasData
? '${value.data} Components in the tree'
: 'Loading...',
),
ElevatedButton(
onPressed: () => setState(() {
_componentCount = Repository.getComponentCount();
}),
child: const Text('Update count'),
),
],
);
},
);
}
}