This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ... | |
import 'package:flutter_mqtt/thermometer_widget.dart'; | |
... | |
class _MyHomePageState extends State<MyHomePage> { | |
... | |
@override | |
Widget build(BuildContext context) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void _onMessage(List<mqtt.MqttReceivedMessage> event) { | |
final mqtt.MqttPublishMessage recMess = | |
event[0].payload as mqtt.MqttPublishMessage; | |
final String message = | |
mqtt.MqttPublishPayload.bytesToStringAsString(recMess.payload.message); | |
setState(() { | |
_temp = double.parse(message); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void _subscribeToTopic(String topic) { | |
if (connectionState == mqtt.MqttConnectionState.connected) { | |
client.subscribe(topic, mqtt.MqttQos.exactlyOnce); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void _connect() async { | |
client = mqtt.MqttClient(broker, ''); | |
client.port = port; | |
client.logging(on: true); | |
client.keepAlivePeriod = 30; | |
client.onDisconnected = _onDisconnected; | |
final mqtt.MqttConnectMessage connMess = mqtt.MqttConnectMessage() | |
.withClientIdentifier(clientIdentifier) | |
.startClean() // Non persistent session for testing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String broker = abc.cloudmqtt.com'; | |
int port = 13372; | |
String username = 'seu_username'; | |
String passwd = 'seu_password'; | |
String clientIdentifier = 'android'; | |
double _temp = 20; | |
mqtt.MqttClient client; | |
mqtt.MqttConnectionState connectionState; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'dart:async'; | |
import 'package:mqtt_client/mqtt_client.dart' as mqtt; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies: | |
flutter: | |
sdk: flutter | |
# The following adds the Cupertino Icons font to your application. | |
# Use with the CupertinoIcons class for iOS style icons. | |
cupertino_icons: ^0.1.2 | |
mqtt_client: ^5.5.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies: | |
flutter: | |
sdk: flutter | |
# The following adds the Cupertino Icons font to your application. | |
# Use with the CupertinoIcons class for iOS style icons. | |
cupertino_icons: ^0.1.2 | |
mqtt_client: ^5.5.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/services.dart'; | |
import 'package:google_maps_flutter/google_maps_flutter.dart'; | |
import 'package:firebase_auth/firebase_auth.dart'; | |
import 'package:flutter/material.dart'; | |
import 'dart:async'; | |
import 'HomeScreenPage.dart'; | |
import 'package:location/location.dart' as LocationMgr; | |
class HomeScreenState extends State<HomeScreenPage> { | |
static const platformChannelGeolocator = const MethodChannel('geolocator'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity: FlutterActivity() { | |
private val CHANNEL_GEOLOCATOR = "geolocator" | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
GeneratedPluginRegistrant.registerWith(this) | |
MethodChannel(flutterView, CHANNEL_GEOLOCATOR).setMethodCallHandler( | |
object : MethodCallHandler { |