flutterx_utils 1.0.3-dev flutterx_utils: ^1.0.3-dev copied to clipboard
A collection of Flutter utilities for any purpose. Check out the source code for documentation
import 'package:flutter/material.dart';
import 'package:flutterx_utils/flutterx_utils.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) => MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutterx Utils Demo',
theme: ThemeData(primarySwatch: Colors.orange),
home: const LoggableExample());
}
class LoggableExample extends StatefulWidget {
const LoggableExample({Key? key}) : super(key: key);
@override
State<LoggableExample> createState() => _LoggableExampleState();
}
class _LoggableExampleState extends State<LoggableExample> with Loggable {
final List<String> _logs = [];
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: const Text('Loggable example')),
body: Center(child: Text(_logs.join('\n'))),
floatingActionButton:
FloatingActionButton(onPressed: () => log('FAB pressed'), tooltip: 'Log', child: const Icon(Icons.add)));
@override
void logImpl(String message, [Object? error, StackTrace? stack]) => setState(() => _logs.add('$tag$indent$message'));
}