logger_console 3.0.2 copy "logger_console: ^3.0.2" to clipboard
logger_console: ^3.0.2 copied to clipboard

A logger project to show log in flutter. It's easy to read your log the same javascript.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:logger_console/logger_console.dart';
import 'test_data.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

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

  void onLogPress() {
    Console.host = "10.10.50.113";
    Console.log("%c Hello World", "color: red; font-size: 20px");
    Console.log("%cTodoList", 'color: green; font-weight: bold;', todos);
  }

  void onLogInfoPress() {
    Console.info("%cLog Info::", 'color: green; font-weight: bold;', todos,
        StackTrace.current);
  }

  void onLogWarnPress() {
    Console.warn("Not Found");
  }

  void onLogErrorPress() {
    Console.error("Server Error");
  }

  void onLogGroupPress() {
    Console.group("TodoList");
    Console.log("todos", todos);
    Console.count("count call");
    Console.groupEnd();
  }

  void onLogGroupCollapsedPress() {
    Console.groupCollapsed("%cTodoList:::", "color: green; font-weight: bold");
    Console.log("todos", todos);
    Console.count("count call");
    Console.groupEnd();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Flutter Demo Home Page'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            ElevatedButton(
              onPressed: onLogPress,
              child: const Text("Console.log"),
            ),
            const SizedBox(height: 16),
            ElevatedButton(
              onPressed: onLogInfoPress,
              child: const Text("Console.info"),
            ),
            const SizedBox(height: 16),
            ElevatedButton(
              onPressed: onLogWarnPress,
              child: const Text("Console.warn"),
            ),
            const SizedBox(height: 16),
            ElevatedButton(
              onPressed: onLogErrorPress,
              child: const Text("Console.error"),
            ),
            const SizedBox(height: 16),
            ElevatedButton(
              onPressed: onLogGroupPress,
              child: const Text("Console.group"),
            ),
            const SizedBox(height: 16),
            ElevatedButton(
              onPressed: onLogGroupCollapsedPress,
              child: const Text("Console.groupCollapsed"),
            ),
          ],
        ),
      ),
    );
  }
}
5
likes
120
pub points
41%
popularity

Publisher

unverified uploader

A logger project to show log in flutter. It's easy to read your log the same javascript.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, nghinv_device_info, socket_channel

More

Packages that depend on logger_console