Posts

Showing posts with the label dart

How to return Response.ok with socket data?

How to return Response.ok with socket data? I can connect my aqueduct to close network socket (listener and get the data) Problem is I can't return new Response.ok. It shows null... I am using Aqueduct 3.0. The most of the documentation looks like Snippets. I had difficulty to apply dart socket. But now I can get text from socket and I cannot sent the data over internet from my aqueduct web api. class LoginController extends Controller { String _xCustomerToken; String _xCustomerName; var list = ; @override Future handle(Request request) async { String reply; Socket.connect('192.168.1.22’, 1024).then((socket) async { socket.listen((data) async { reply = await new String.fromCharCodes(data).trim(); print("reply: $reply"); var list = reply.split(":_:"); print(list); _xCustomerToken = list[2]; _xCustomerName = list[3]; // CAN PRINT THE SOCKET DATA // EXAMPLE: ”Customer Token: 998877, CustomerName: NIYAZI TOROS” print( "Cu...

Dart March 30 days

Dart March 30 days Small question : I calculate the number of days in a given month like so : new DateTime(2018, month+1, 1).difference(new DateTime(2018,month,1)).inDays All is working fine, februari gives me 28 days, all months are correctly 30/31 days except for March , which gives me 30 days instead of 31 . februari 28 30/31 March 30 31 Has anyone seen this before and perhaps an explanation? Thanks. Probably DST. Stupid DST. We need to get rid of DST. Edit: probably if you use UTC instead of local timezone, it'd work right. – Randal Schwartz Jul 2 at 1:45 1 Answer 1 I believe it's because of daylight-saving, try new DateTime.utc() , the below code outputs the correct values for(int month = 1; month < 13; mont...

what is `dart.js` in chartjs.dart example

what is `dart.js` in chartjs.dart example I am learning [package:js][1] and reading the example here. [package:js][1] I am curious what is dart.js here https://github.com/google/chartjs.dart/blob/master/example/index.html#L7 and what it is used for? dart.js Any hints welcomed. Thanks 2 Answers 2 That looks like it's using the older interface. Things have changed a lot since then. The modern angular rewrites everything on the fly so that those things are no longer needed in your source HTML. It is the JavaScript output generated by dart2js when you build a Dart web project using pub build (Dart 1). dart2js pub build For Dart 2 build is used instead and the browser and dart_to_js_script_rewriter packages are no longer necessary. build browser dart_to_js_script_rewriter See also - https://pub.dartlang.org/packages/build_runner - https://pub.dartlang.org/packages/build ...

Adding tab labels to TabView in Flutter

Adding tab labels to TabView in Flutter I'm trying to extend the TabView proposed as an answer here. Specifically, instead of the grey dots, I would like to have category labels, and load as a tab content a widget corresponding to that category. I tried following the docs, but if I change something in the AppBar it just gives me a reendering error. 2 Answers 2 You can achieve what you wanted via TabController widget. I found a simple example of TabBar here. You can achieve what you wanted via DefaultTabController widget. You can see the example here with only the icons. And here is the modified version of it with titles. TabBar part is for the tab and it's specifications. TabBarView is for the interior view. DefaultTabController TabBar TabBarView class TabBarDemo extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: DefaultTabCon...