From 4ba94f86f6a18f6d151281cccd0df627cc15d6e7 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 16 Mar 2022 15:21:30 +0300 Subject: [PATCH] add the basic single R --- lib/main.dart | 32 +++------------------ lib/utils/signalR_utils.dart | 29 +++++++++++++++++++ pubspec.lock | 56 ++++++++++++++++++++++++++++++++++++ pubspec.yaml | 4 +++ 4 files changed, 93 insertions(+), 28 deletions(-) create mode 100644 lib/utils/signalR_utils.dart diff --git a/lib/main.dart b/lib/main.dart index d819906..786f6d0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:queuing_system/utils/signalR_utils.dart'; import 'core/base/app_scaffold_widget.dart'; import 'core/base/project_view_model.dart'; @@ -49,14 +50,6 @@ class MyApp extends StatelessWidget { class MyHomePage extends StatefulWidget { - // This widget is the home page of your application. It is stateful, meaning - // that it has a State object (defined below) that contains fields that affect - // how it looks. - - // This class is the configuration for the state. It holds the values (in this - // case the title) provided by the parent (in this case the App widget) and - // used by the build method of the State. Fields in a Widget subclass are - // always marked "final". String title ="MyHomePage"; @@ -65,36 +58,19 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { - int _counter = 0; - - void _incrementCounter() { - setState(() { - // This call to setState tells the Flutter framework that something has - // changed in this State, which causes it to rerun the build method below - // so that the display can reflect the updated values. If we changed - // _counter without calling setState(), then the build method would not be - // called again, and so nothing would appear to happen. - _counter++; - }); - } - @override Widget build(BuildContext context) { + SignalRHelper signalRHelper= SignalRHelper(); return AppScaffold( appBar: AppBar( title: Text(widget.title), ), body: Center( - child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - const Text( - 'You have pushed the button this many times:', - ), - Text( - '$_counter', - style: Theme.of(context).textTheme.headline4, + Text( + signalRHelper.msg, ), ], ), diff --git a/lib/utils/signalR_utils.dart b/lib/utils/signalR_utils.dart new file mode 100644 index 0000000..7c10276 --- /dev/null +++ b/lib/utils/signalR_utils.dart @@ -0,0 +1,29 @@ +import 'package:flutter/material.dart'; +import 'package:signalr_core/signalr_core.dart'; + +class SignalRHelper{ + + String hubBaseURL =""; + String msg ="Elham"; + HubConnection connection; + SignalRHelper(){ + connection = HubConnectionBuilder() + .withUrl( + hubBaseURL, + HttpConnectionOptions( + logging: (level, message) { + msg = message; + print("$message"); + }, + ) + ).build(); + } + + + closeConnection(BuildContext context) async { + if(connection.state == HubConnectionState.connected) + { + await connection.stop(); + } + } +} \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 750a090..b88033d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -71,6 +71,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.1" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" + equatable: + dependency: transitive + description: + name: equatable + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.3" fake_async: dependency: transitive description: @@ -149,6 +163,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.1" + logging: + dependency: transitive + description: + name: logging + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" matcher: dependency: transitive description: @@ -212,6 +233,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "6.0.2" + quiver: + dependency: transitive + description: + name: quiver + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1+1" + signalr_core: + dependency: "direct main" + description: + name: signalr_core + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" sky_engine: dependency: transitive description: flutter @@ -224,6 +259,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.1" + sse_client: + dependency: transitive + description: + name: sse_client + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.0" stack_trace: dependency: transitive description: @@ -259,6 +301,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.4.3" + tuple: + dependency: transitive + description: + name: tuple + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" typed_data: dependency: transitive description: @@ -273,6 +322,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.1" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" xml: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 11c8771..f2656a8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -39,6 +39,10 @@ dependencies: flutter_svg: ^1.0.3 http: ^0.13.0 + #signalr core + signalr_core: ^1.1.1 + +