initTerminal method

Future<void> initTerminal()

Implementation

Future<void> initTerminal() async {
  setState(() => this.title =
      "${widget.device.addr}:${widget.device.port}@${widget.device.runId}");
  terminal.write('Connecting...\r\n');
  TextEditingController usernameController =
      TextEditingController.fromValue(TextEditingValue(text: ""));
  TextEditingController passwordController =
      TextEditingController.fromValue(TextEditingValue(text: ""));
  showGeneralDialog(
    context: context,
    pageBuilder: (BuildContext buildContext, Animation<double> animation,
        Animation<double> secondaryAnimation) {
      return TDAlertDialog(
        title: OpenIoTHubPluginLocalizations.of(context)
            .please_input_ssh_username_password,
        contentWidget: Column(children: <Widget>[
          TDInput(
            leftLabel: OpenIoTHubPluginLocalizations.of(context).username,
            leftLabelSpace: 0,
            hintText: "",
            backgroundColor: Colors.white,
            textAlign: TextAlign.left,
            showBottomDivider: true,
            controller: usernameController,
            inputType: TextInputType.text,
            maxLines: 1,
            needClear: true,
          ),
          TDInput(
            leftLabel: OpenIoTHubPluginLocalizations.of(context).password,
            leftLabelSpace: 0,
            hintText: "",
            backgroundColor: Colors.white,
            textAlign: TextAlign.left,
            showBottomDivider: true,
            controller: passwordController,
            inputType: TextInputType.text,
            maxLines: 1,
            needClear: true,
            obscureText: true,
          )
          // 是否自动添加网关主机
        ]),
        titleColor: Colors.black,
        contentColor: Colors.redAccent,
        // backgroundColor: AppTheme.blockBgColor,
        leftBtn: TDDialogButtonOptions(
          title: OpenIoTHubPluginLocalizations.of(context).cancel,
          // titleColor: AppTheme.color999,
          style: TDButtonStyle(
            backgroundColor: Colors.grey,
          ),
          action: () {
            Navigator.of(context).pop();
          },
        ),
        rightBtn: TDDialogButtonOptions(
          title: OpenIoTHubPluginLocalizations.of(context).ok,
          style: TDButtonStyle(
            backgroundColor: Colors.blue,
          ),
          action: () {
            Navigator.of(context).pop();
            // 弹窗获取用户名密码
            _connect_ssh(
                username: usernameController.text,
                password: passwordController.text);
          },
        ),
      );
    },
  );
}