commandline_interface 0.0.5 copy "commandline_interface: ^0.0.5" to clipboard
commandline_interface: ^0.0.5 copied to clipboard

CLI. Minimalist.

example/example.dart

import 'package:commandline_interface/commandline_interface.dart';
import 'package:flutter/material.dart';

class ExampleManager extends CLIManagerBase {
  ExampleManager();
  @override
  void execute(String command) {
    if(command == 'clear'){
      //clears the screen
      clear();
    } else {
      //USE function SINK TO ADD WIDGETS TO DISPLAY
      //METHOD SINK IS SET IN CONSTRUCTOR OF CLIController IN setter of interpreter
      sink(
          Container(child: Text('\$input: $command', style: TextStyle(color: Colors.greenAccent),))
      );
      sink(
          Container(child: Text('output >>  $command'))
      );
    }
  }
}

final CLIManagerBase exampleManager = ExampleManager();
final CLIController cliBehaviorSubject = CLIController(initManager: exampleManager);
final CLIWidget cliWidget = CLIWidget(cliBehaviorSubject);
// CLIManagerBase > CLIController > CLIWidget

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Minimalist Flutter Template',
      theme: ThemeData.dark(),
      home: ExamplePage(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('CommandLineInterface'),
      ),
      body: cliWidget,
    );
  }
}
0
likes
120
points
22
downloads

Publisher

unverified uploader

Weekly Downloads

CLI. Minimalist.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, rxdart

More

Packages that depend on commandline_interface