mqtt_page.dart
1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import 'package:appframe/bloc/mqtt_cubit.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class MqttPage extends StatelessWidget {
const MqttPage({super.key});
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => MqttCubit(),
child: BlocConsumer<MqttCubit, MqttState>(
builder: (context, state) {
return Scaffold(
appBar: AppBar(
title: Text('推送测试'),
centerTitle: true,
automaticallyImplyLeading: false,
leading: IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () {
context.read<MqttCubit>().goWeb();
},
),
),
body: ListView(
children: state.messages
.map((message) => ListTile(
title: Text(message),
))
.toList(),
));
},
listener: (context, state) {},
));
}
}