refactor: show devtools only in debug mode
This commit is contained in:
@@ -18,78 +18,77 @@ class _FlQueryDevtoolsState extends State<FlQueryDevtools> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (kReleaseMode) {
|
if (kDebugMode) {
|
||||||
return SizedBox.shrink(child: widget.child);
|
return Navigator(
|
||||||
}
|
onPopPage: (route, result) {
|
||||||
|
return true;
|
||||||
return Navigator(
|
},
|
||||||
onPopPage: (route, result) {
|
pages: [
|
||||||
return true;
|
MaterialPage(
|
||||||
},
|
child: Scaffold(
|
||||||
pages: [
|
body: Stack(
|
||||||
MaterialPage(
|
children: [
|
||||||
child: Scaffold(
|
if (widget.child != null) widget.child!,
|
||||||
body: Stack(
|
if (_showDevtools) ...[
|
||||||
children: [
|
Positioned(
|
||||||
if (widget.child != null) widget.child!,
|
child: GestureDetector(
|
||||||
if (_showDevtools) ...[
|
onTap: () {
|
||||||
Positioned(
|
setState(() {
|
||||||
child: GestureDetector(
|
_showDevtools = false;
|
||||||
onTap: () {
|
});
|
||||||
setState(() {
|
},
|
||||||
_showDevtools = false;
|
child: const SizedBox.expand(
|
||||||
});
|
child: ColoredBox(
|
||||||
},
|
color: Colors.black38,
|
||||||
child: const SizedBox.expand(
|
),
|
||||||
child: ColoredBox(
|
|
||||||
color: Colors.black38,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
Positioned(
|
||||||
Positioned(
|
child: Align(
|
||||||
child: Align(
|
alignment: Alignment.bottomCenter,
|
||||||
alignment: Alignment.bottomCenter,
|
child: Container(
|
||||||
child: Container(
|
height: MediaQuery.of(context).size.height * 0.7,
|
||||||
height: MediaQuery.of(context).size.height * 0.7,
|
width: double.infinity,
|
||||||
width: double.infinity,
|
margin: const EdgeInsets.all(8.0),
|
||||||
margin: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
padding: const EdgeInsets.all(8.0),
|
decoration: BoxDecoration(
|
||||||
decoration: BoxDecoration(
|
color: Theme.of(context).colorScheme.surface,
|
||||||
color: Theme.of(context).colorScheme.surface,
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
borderRadius: BorderRadius.circular(8.0),
|
),
|
||||||
),
|
child: DevtoolsRoot(
|
||||||
child: DevtoolsRoot(
|
onClose: () {
|
||||||
onClose: () {
|
setState(() {
|
||||||
setState(() {
|
_showDevtools = false;
|
||||||
_showDevtools = false;
|
});
|
||||||
});
|
},
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
]
|
||||||
]
|
],
|
||||||
],
|
),
|
||||||
),
|
floatingActionButtonLocation:
|
||||||
floatingActionButtonLocation:
|
FloatingActionButtonLocation.startFloat,
|
||||||
FloatingActionButtonLocation.startFloat,
|
floatingActionButton: AnimatedScale(
|
||||||
floatingActionButton: AnimatedScale(
|
duration: const Duration(milliseconds: 100),
|
||||||
duration: const Duration(milliseconds: 100),
|
scale: _showDevtools ? 0 : 1,
|
||||||
scale: _showDevtools ? 0 : 1,
|
child: FloatingActionButton.extended(
|
||||||
child: FloatingActionButton.extended(
|
onPressed: () {
|
||||||
onPressed: () {
|
setState(() {
|
||||||
setState(() {
|
_showDevtools = !_showDevtools;
|
||||||
_showDevtools = !_showDevtools;
|
});
|
||||||
});
|
},
|
||||||
},
|
label: const Text("Fl-Query Devtools"),
|
||||||
label: const Text("Fl-Query Devtools"),
|
icon: const Icon(Icons.search_rounded),
|
||||||
icon: const Icon(Icons.search_rounded),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
);
|
||||||
);
|
}
|
||||||
|
return SizedBox.shrink(child: widget.child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user