createPrinter

Create a KlutterPrinter instance which generates a Flutter Producer Widget.

Example
Given input:

  • channel.name: com.example.awesome.my_awesome_app

  • event.name: greeting

  • extension.className: GreetingEvent

  • request.type: String

  • response.type: String

  • method.name: getGreeting

Will generate:

import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:klutter_ui/klutter_ui.dart';

const MethodChannel _channel =
MethodChannel('com.example.awesome.my_awesome_app');

extension GreetingEvent on State {
void getGreeting({
required String message,
void Function(String)? onSuccess,
void Function(Exception)? onFailure,
void Function()? onNullValue,
void Function(AdapterResponse<String>)? onComplete,
}) => doEvent<String>(
state: this,
event: "greeting",
message: message,
channel: _channel,
onSuccess: onSuccess,
onFailure: onFailure,
onNullValue: onNullValue,
onComplete: onComplete,
);
}

void getGreeting({
required String message,
State? state,
void Function(String)? onSuccess,
void Function(Exception)? onFailure,
void Function()? onNullValue,
void Function(AdapterResponse<String>)? onComplete,
}) => doEvent<String>(
state: state,
event: "greeting",
message: message,
channel: _channel,
onSuccess: onSuccess,
onFailure: onFailure,
onNullValue: onNullValue,
onComplete: onComplete,
);