PrintStream class abstract
An abstract interface representing a stream for formatted text output.
This is analogous to Javaβs PrintStream
, and provides utility methods
for printing values with or without newlines, flushing buffered content,
and closing the stream.
Implementations of this interface can print to stdout
, files, memory,
or any other sink that supports basic text streaming.
π¦ Example Usage:
class ConsolePrintStream implements PrintStream {
@override
void print(Object? obj) => stdout.print(obj ?? 'null');
@override
void println(Object? obj) => stdout.println(obj ?? 'null');
@override
void newline() => stdout.println();
@override
void flush() {} // No-op for stdout
@override
Future<void> close() async {} // Nothing to close
}
final stream = ConsolePrintStream();
stream.print('Hello');
stream.println(' World');
stream.newline();
await stream.close();
- Implementers
Constructors
Properties
- hashCode β int
-
The hash code for this object.
no setterinherited
- runtimeType β Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
close(
) β Future< void> - An abstract interface representing a stream for formatted text output.
-
flush(
) β void - An abstract interface representing a stream for formatted text output.
-
newline(
) β void - An abstract interface representing a stream for formatted text output.
-
noSuchMethod(
Invocation invocation) β dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
print(
Object? obj) β void - An abstract interface representing a stream for formatted text output.
-
println(
[Object? obj]) β void - An abstract interface representing a stream for formatted text output.
-
toString(
) β String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) β bool -
The equality operator.
inherited