node.js - 将文本从颤振发送到节点 js
问题描述
当我按下按钮时,我只想将一些文本从颤振发送到我的节点 js 应用程序。
我想使用 http.dart 将“text2”发送到节点 js 应用程序
当我按下我的凸起按钮时,我希望它将带有变量文本 2 的 http 字符串发送到节点 js 应用程序。
我想获得一个教程的链接,或者只是一些帮助,因为我在网上找不到任何东西,谢谢。
我的颤振代码:
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
void main() {
runApp(new MyApp());
}
var text2;
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Bot Discord App',
theme: new ThemeData(
primarySwatch: Colors.blue,
primaryColor: const Color(0xFF2196f3),
accentColor: const Color(0xFF2196f3),
canvasColor: const Color(0xFFfafafa),
),
home: new MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key}) : super(key: key);
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final myController = TextEditingController();
@override
void dispose() {
// Clean up the controller when the widget is disposed.
myController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Bot Discord App'),
),
body:
new Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
new SizedBox(
width: 100.0,
height: 100.0,
child:
new Padding(
child:
new Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
new Text(
"Precense",
style: new TextStyle(fontSize:19.0,
color: const Color(0xFF000000),
fontWeight: FontWeight.w200,
fontFamily: "Roboto"),
),
new TextField(
style: new TextStyle(fontSize:12.0,
color: const Color(0xFF000000),
fontWeight: FontWeight.w200,
fontFamily: "Roboto"),
)
]
),
padding: const EdgeInsets.all(10.0),
),
),
new SizedBox(
width: 100.0,
height: 50.0,
child:
new Padding(
child:
new RaisedButton(key:null,
onPressed: () {
return
text2 = Text(myController.text) as String;
},
color: const Color(0xFFe0e0e0),
child:
new Text(
"UPDATE",
style: new TextStyle(fontSize:23.0,
color: const Color(0xFF000000),
fontWeight: FontWeight.w200,
fontFamily: "Roboto"),
)
),
padding: const EdgeInsets.fromLTRB(6.0, 6.0, 7.0, 6.0),
),
)
]
),
);
}
void buttonPressed(){}
}
解决方案
我认为解决方案是在颤振中调用 JS 变量作为参数,并为它们分配你想要使用的值......有关更多详细信息,请查看给定的链接,希望这会对你有所帮助...... [1]:https ://fireship.io/snippets/using-js-with-flutter-web/
推荐阅读
- java - 模拟点击在其他程序中不起作用
- r - 在 R 中绘制主成分分析结果
- tensorflow - Tensorflow连接层无法识别输入列表
- c - 当 C 库静态链接时,整个库是否会添加到可执行文件中?
- kubernetes - 在 VSTS 中创建 Kubernetes Endpoint 会产生错误
- java - Bean单例,会话创建和初始化
- javascript - TypeError: $.ajax is not a function work fine in one page but not in another page
- spring - 必须在事务上下文之外调用方法 - Spring @Transactional
- python-3.x - AWS Lambda Python PIL/枕头导入错误
- android - 返回到 SslErrorHandler 上的上一个屏幕