om_console 1.0.4 copy "om_console: ^1.0.4" to clipboard
om_console: ^1.0.4 copied to clipboard

A flutter console widget showing in the ui like vscode console

example/lib/main.dart

import 'dart:math';
import 'package:flutter/material.dart';
import 'package:om_console/om_console.dart';

void main() {
  Console.consoleLisitener(() {
    runApp(const MyApp());
  });
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return ConsoleWrapper(
      showConsole: true,
      child: MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
            colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
            useMaterial3: true,
          ),
          home: const MyHomePage(title: "My Flutter HomePage")),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  void logPress() {
    // normal print example
    for (int i = 0; i < 100; i++) {
      print(generateRandomString(100));
    }
    // sql example log
    Console.logSql(
      dbName: "Quick",
      params: {
        "Operation": "Get Left-Right Side Group",
        "User": "a.abdelghafar",
        "LastChatID": 2003305,
        "local": false,
        "UnreadList": "0",
        "version": "1.0.0.0",
        "firebaseToken": "",
        "iosVersion": "",
        "androidVersion": "",
        "webVersion": ""
      },
      spName: "[GRP].[APIGroupOperation]",
    );
    // http log example
    Console.logHttp(
      url: "www.example.com",
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "Authorization": "Bearer wawXHzQw35NTwyJ9CSLVWKKd4vv4pNq2lFKrEZPp9EG",
        "X-API-Key": "12345",
        "X-Version": "1.0.0",
        "X-Platform": "flutter",
        "X-Locale": "en_US",
        "X-Screen-Width": "${MediaQuery.of(context).size.width}",
        "X-Screen-Height": "${5000}",
      },
      body: {
        "device_id": "device_id_123",
        "app_version": "1.0.0",
        "locale": "en_US",
        "platform": "flutter",
      },
      textColor: Colors.black,
      statusCode: 200,
      response: {
        "message": "Success",
        "message1": "Success",
        "message2": "Success",
        "message3": "Success",
        "message4": "Success",
        "message5": "Success",
        "message6": "Success",
        "message7": "Success",
        "message8": "Success",
      },
      bodyType: BodyType.raw,
    );
  }

  String generateRandomString(int length) {
    const characters =
        'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
    final random = Random();
    return List.generate(
            length, (index) => characters[random.nextInt(characters.length)])
        .join();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            SizedBox(
              width: 200,
              height: 50,
              child: MaterialButton(
                onPressed: () {
                  logPress();
                },
                color: Colors.purple,
                child: const Text(
                  "Log To Console",
                  style: TextStyle(color: Colors.white),
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
3
likes
160
points
97
downloads

Publisher

unverified uploader

Weekly Downloads

A flutter console widget showing in the ui like vscode console

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_localizations, localization, scrollable_positioned_list

More

Packages that depend on om_console