Read data from Flutter via Bluetooth - flutter

I am trying to get the data from my bluetooth device. My problem is with the Flutter code to get such data.
services/sensor.dart
import 'dart:async';
import 'dart:convert' show utf8;
import 'package:flutter/material.dart';
import 'package:flutter_blue/flutter_blue.dart';
import 'package:minertti/main.dart';
class SensorPage extends StatefulWidget {
const SensorPage({Key? key, required this.device}) : super(key: key);
final BluetoothDevice device;
#override
_SensorPageState createState() => _SensorPageState();
}
class _SensorPageState extends State<SensorPage> {
String service_uuid = "6E400001-B5A3-F393-E0A9-E50E24DCCA9E";
String charaCteristic_uuid = "6E400003-B5A3-F393-E0A9-E50E24DCCA9E";
late bool isReady;
late Stream<List<int>> stream;
late List _temphumidata;
double _charge = 0;
double _data_1 = 0;
double _data_2 = 0;
#override
void initState() {
super.initState();
super.initState();
isReady = false;
connectToDevice();
}
void dispose() {
widget.device.disconnect();
super.dispose();
}
connectToDevice() async {
if (widget.device == null) {
_pop();
return;
}
new Timer(const Duration(seconds: 15), () {
if (!isReady) {
disconnectFromDevice();
_pop();
}
});
await widget.device.connect();
discoverServices();
}
disconnectFromDevice() {
if (widget.device == null) {
_pop();
return;
}
widget.device.disconnect();
}
discoverServices() async {
if (widget.device == null) {
_pop();
return;
}
List<BluetoothService> services = await widget.device.discoverServices();
services.forEach((service) {
if (service.uuid.toString().isNotEmpty) {
service.characteristics.forEach((characteristic) {
if (characteristic.uuid.toString().isNotEmpty) {
characteristic.setNotifyValue(!characteristic.isNotifying);
stream = characteristic.value;
setState(() {
isReady = true;
});
}
});
}
});
if (!isReady) {
_pop();
}
}
_pop() {
Navigator.of(context).pop(true);
}
String _dataParser(List<int> dataFromDevice) {
return utf8.decode(dataFromDevice);
}
#override
Widget build(BuildContext context) {
return Scaffold(
// appBar: AppBar(
// title: Text('dht11 Sensor'),
// ),
body: Container(
child: !isReady
? Center(
child: Text(
"Waiting...",
style: TextStyle(
fontSize: 24, color: Color.fromARGB(255, 0, 0, 0)),
),
)
: Container(
child: StreamBuilder<List<int>>(
stream: stream,
builder: (BuildContext context,
AsyncSnapshot<List<int>> snapshot) {
if (snapshot.hasError)
return Text('Error: ${snapshot.error}');
if (snapshot.connectionState == ConnectionState.active) {
var data = snapshot.data as List<int>;
var currentValue = _dataParser(data);
print("REALDATA: $data");
_temphumidata = currentValue.split(",");
//_charge = double.parse('${_temphumidata[0]}');
//_data_1 = double.parse('${_temphumidata[1]}');
//_data_2 = _temphumidata[2];
return DeviceScreen1(
device: widget.device,
//charge: _charge,
//data_2: _data_2,
//data_1: _data_1,
charge: 90,
data_1: "Data 1",
data_2: "Data 2");
} else {
return Text('Check the stream');
}
},
),
)),
);
}
}
var data = snapshot.data as List;
var currentValue = _dataParser(data);
They do not show values. But, from my Arduino I know that it does send/notify data. That is, my problem is with reading and obtaining said data.

Related

WebView showing ERR_CONNECTION_REFUSED (using flutter)

I got this error while using webview in flutter.
error: ERR_CONNECTION_REFUSED
Here is my code:
import 'dart:async'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:webview_flutter/webview_flutter.dart'; import 'package:flutter/services.dart'; import 'package:mime/mime.dart'; import 'package:provider/provider.dart';
import 'package:num_plus_plus/src/backend/mathmodel.dart'; import 'package:num_plus_plus/src/pages/settingpage.dart';
class Server { class from inAppBrowser
late HttpServer _server;
int _port = 8080;
Server({int port = 8080}) { this._port = port; }
///Closes the server. Future<void> close() async { if (this._server != null) { await this._server.close(force: true); print('Server running on http://localhost:$_port closed'); this._server = null as HttpServer;
} }
Future<void> start() async { if (this._server != null) { throw Exception('Server already started on http://localhost:$_port');
}
var completer = new Completer(); runZoned(() { HttpServer.bind('127.0.0.1', _port, shared: true).then((server) { print('Server running on http://localhost:' + _port.toString());
this._server = server;
server.listen((HttpRequest request) async { var body = <int>[]; var path = request.requestedUri.path; path = (path.startsWith('/')) ? path.substring(1) : path; path += (path.endsWith('/')) ? 'index.html' : '';
try { body = (await rootBundle.load(path)).buffer.asUint8List(); catch (e) { print(e.toString()); request.response.close(); return;
}
var contentType = ['text', 'html']; if (!request.requestedUri.path.endsWith('/') && request.requestedUri.pathSegments.isNotEmpty) { var mimeType = lookupMimeType(request.requestedUri.path, headerBytes: body); if (mimeType != null) { contentType = mimeType.split('/');
}
}
request.response.headers.contentType = new ContentType(contentType[0], contentType[1], charset: 'utf-8'); request.response.add(body); request.response.close();
});
completer.complete();
}); onError: (e, stackTrace) => print('Error: $e $stackTrace'));
return completer.future; } }
class MathBox extends StatelessWidget { #override Widget build(BuildContext context) { final mathBoxController = Provider.of<MathBoxController>(context, listen: false); final mathModel = Provider.of<MathModel>(context, listen: false); final matrixModel = Provider.of<MatrixModel>(context, listen: false); final functionModel = Provider.of<FunctionModel>(context, listen: false); final mode = Provider.of<CalculationMode>(context, listen: false); return Stack( children: <Widget>[ WebView( onWebViewCreated: (controller) { controller.loadUrl("http://localhost:8080/assets/html/homepage.html"); mathBoxController.webViewController = controller;
}, onPageFinished: (s) { final setting = Provider.of<SettingModel>(context, listen: false); if (setting.initPage == 1) { mathBoxController.addExpression('\\\\bmatrix');
}
}, javascriptMode: JavascriptMode.unrestricted, javascriptChannels: Set.from([ JavascriptChannel( name: 'latexString', onMessageReceived: (JavascriptMessage message) { if (mode.value == Mode.Matrix) { matrixModel.updateExpression(message.message); else { if (message.message.contains(RegExp('x|y'))) { mode.changeMode(Mode.Function); functionModel.updateExpression(message.message); else { mode.changeMode(Mode.Basic); mathModel.updateExpression(message.message); mathModel.calcNumber();
}
}
}
), JavascriptChannel( name: 'clearable', onMessageReceived: (JavascriptMessage message) { mathModel.changeClearable(message.message == 'false'?false:true);
}
),
]),
), ClearAnimation(),
],
); } }
class ClearAnimation extends StatefulWidget { #override
_ClearAnimationState createState() => _ClearAnimationState(); }
class _ClearAnimationState extends State<ClearAnimation> with TickerProviderStateMixin {
late AnimationController animationController; late Animation animation;
#override void initState() { super.initState(); animationController = AnimationController(duration: const Duration(milliseconds: 500),vsync: this); final curve = CurvedAnimation(parent: animationController, curve: Curves.easeInOutCubic); animation = Tween<double>(begin: 0, end: 2000).animate(curve); Provider.of<MathBoxController>(context, listen: false).clearAnimationController = animationController; }
#override void dispose() { animationController.dispose(); super.dispose(); }
Widget _buildAnimation(BuildContext context, Widget? child) { return Positioned( top: 10-animation.value/2 as double, right: -animation.value/2, child: ClipOval( child: Container( height: animation.value, width: animation.value, color: Colors.blue[100],
),
),
); }
#override Widget build(BuildContext context) { return AnimatedBuilder( builder: _buildAnimation, animation: animation,
); } }
class MathBoxController {
late WebViewController _webViewController; late AnimationController clearAnimationController;
set webViewController(WebViewController controller) { this._webViewController = controller; }
void addExpression(String msg, {bool isOperator = false}) { assert(_webViewController != null);
_webViewController.evaluateJavascript("addCmd('$msg', {isOperator: ${isOperator.toString()}})"); }
void addString(String msg) { assert(_webViewController != null);
_webViewController.evaluateJavascript("addString('$msg')"); }
void equal() { assert(_webViewController != null);
_webViewController.evaluateJavascript("equal()"); }
void addKey(String key) { assert(_webViewController != null);
_webViewController.evaluateJavascript("simulateKey('$key')"); }
void deleteExpression() { assert(_webViewController != null);
_webViewController.evaluateJavascript("delString()"); }
void deleteAllExpression() { assert(_webViewController != null);
_webViewController.evaluateJavascript("delAll()"); }
}

how to automatically trigger record

I have a audio recording page which starts when I tap in the button and stop when i tap the button once again
import 'package:flutter_sound/flutter_sound.dart';
import 'package:permission_handler/permission_handler.dart';
class AudioWidget extends StatefulWidget {
#override
State<AudioWidget> createState() => _AudioWidgetState();
}
``class _AudioWidgetState extends State<AudioWidget> {
final FirebaseAuth _auth = FirebaseAuth.instance;
String AudioUrl = '';
final recorder = FlutterSoundRecorder();
bool isRecorderReady = false;
#override
void initState() {
super.initState();
initRecorder();
record();
}
#override
void dispose() {
recorder.closeRecorder();
super.dispose();
}
Future initRecorder() async {
final status = await Permission.microphone.request();
if (status != PermissionStatus.granted) {
throw 'Microphone permission not granted';
}
await recorder.openRecorder();
isRecorderReady = true;
recorder.setSubscriptionDuration(const Duration(milliseconds: 500));
}
Future record() async {
if (!isRecorderReady) {
return;
}
await recorder.startRecorder(toFile: 'audio');
}
Future stop() async {
if (!isRecorderReady) {
return;
}
final path = await recorder.stopRecorder();
final audioFile = File(path!);
print('Recorder audio: $audioFile');
final ref = FirebaseStorage.instance
.ref()
.child('Audio')
.child(DateTime.now().toIso8601String() + ".mp3");
await ref.putData(audioFile.readAsBytesSync());
AudioUrl = await ref.getDownloadURL();
FirebaseFirestore.instance.collection('Audio').add({
'AudioUrl': AudioUrl,
'userId': _auth.currentUser!.email,
'createdAt': DateTime.now(),
});
}
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text("Audio"),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
StreamBuilder<RecordingDisposition>(
stream: recorder.onProgress,
builder: (context, snapshot) {
final duration = snapshot.hasData
? snapshot.data!.duration
: Duration.zero;
String twoDigits(int n) => n.toString().padLeft(2, '0');
final twoDigitMinutes =
twoDigits(duration.inMinutes.remainder(60));
final twoDigitSeconds =
twoDigits(duration.inSeconds.remainder(60));
if (twoDigitSeconds ==
FFAppState().AudioMaxDuration.toString()) {
stop();
}
return Text('$twoDigitMinutes:$twoDigitSeconds',
style: const TextStyle(
fontSize: 80,
fontWeight: FontWeight.bold,
));
}),
const SizedBox(height: 32),
ElevatedButton(
child: Icon(
recorder.isRecording ? Icons.stop : Icons.mic,
size: 80,
),
onPressed: () async {
if (recorder.isRecording) {
await stop();
context.pop();
} else {
await record();
}
setState(() {});
},
),
],
)),
),
);
}
}
how can I automatically start recording once I open the audio recording page and tap it to stop and tap again to start?
I tried to put the record function in initstate but it didn't work
void initState() {
super.initState();
initRecorder();
record();
}

How to read identifier number nfc card with nfc_manager

I can´t to read identifier nfc card with nfc_manager package. I think i need decoded the tag identifier number. My code...
'''ValueNotifier<dynamic> result = ValueNotifier(null);'''
void _tagRead() async{
bool isAvailable = await NfcManager.instance.isAvailable();
NfcManager.instance.startSession(onDiscovered: (NfcTag tag) async {
result.value = tag.data;
MifareClassic? nfca = MifareClassic.from(tag);
var read = nfca?.identifier;
}
It´s returning: identifier[xxx, xx, xxx, xx] (four int numbers).
I used the nfc_manager package and I also didn't get the expected result in my project, so I started using the flutter_nfc_kit package. Only with 'tag.id' has access to the identifier.
Below is a snippet of code taken from the example available at https://github.com/nfcim/flutter_nfc_kit
import 'dart:async';
import 'dart:io' show Platform, sleep;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_nfc_kit/flutter_nfc_kit.dart';
import 'package:logging/logging.dart';
import 'package:ndef/ndef.dart' as ndef;
class Sensors extends StatefulWidget {
#override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<Sensors> with SingleTickerProviderStateMixin {
String _platformVersion = '';
NFCAvailability _availability = NFCAvailability.not_supported;
NFCTag? _tag;
String? _result, _writeResult;
late TabController _tabController;
List<ndef.NDEFRecord>? _records;
#override
void dispose() {
_tabController.dispose();
super.dispose();
}
#override
void initState() {
super.initState();
if (!kIsWeb)
_platformVersion =
'${Platform.operatingSystem} ${Platform.operatingSystemVersion}';
else
_platformVersion = 'Web';
initPlatformState();
_tabController = new TabController(length: 2, vsync: this);
_records = [];
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
NFCAvailability availability;
try {
availability = await FlutterNfcKit.nfcAvailability;
} on PlatformException {
availability = NFCAvailability.not_supported;
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
// _platformVersion = platformVersion;
_availability = availability;
});
}
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('NFC Flutter Kit Example App'),
),
body: Scrollbar(
child: SingleChildScrollView(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const SizedBox(height: 20),
Text('Running on: $_platformVersion\nNFC: $_availability'),
const SizedBox(height: 10),
ElevatedButton(
onPressed: () async {
try {
NFCTag tag = await FlutterNfcKit.poll();
setState(() {
_tag = tag;
});
await FlutterNfcKit.setIosAlertMessage("Working on it...");
if (tag.standard == "ISO 14443-4 (Type B)") {
String result1 =
await FlutterNfcKit.transceive("00B0950000");
String result2 = await FlutterNfcKit.transceive(
"00A4040009A00000000386980701");
setState(() {
_result = '1: $result1\n2: $result2\n';
});
} else if (tag.type == NFCTagType.iso18092) {
String result1 =
await FlutterNfcKit.transceive("060080080100");
setState(() {
_result = '1: $result1\n';
});
} else if (tag.type == NFCTagType.mifare_ultralight ||
tag.type == NFCTagType.mifare_classic ||
tag.type == NFCTagType.iso15693) {
var ndefRecords = await FlutterNfcKit.readNDEFRecords();
var ndefString = '';
for (int i = 0; i < ndefRecords.length; i++) {
ndefString += '${i + 1}: ${ndefRecords[i]}\n';
}
setState(() {
_result = ndefString;
});
} else if (tag.type == NFCTagType.webusb) {
var r = await FlutterNfcKit.transceive(
"00A4040006D27600012401");
print(r);
}
} catch (e) {
setState(() {
_result = 'error: $e';
});
}
// Pretend that we are working
if (!kIsWeb) sleep(new Duration(seconds: 1));
await FlutterNfcKit.finish(iosAlertMessage: "Finished!");
},
child: Text('Start polling'),
),
const SizedBox(height: 10),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: _tag != null
? Text(
'ID: ${_tag!.id}\nStandard: ${_tag!.standard}\nType: ${_tag!.type}\nATQA: ${_tag!.atqa}\nSAK: ${_tag!.sak}\nHistorical Bytes: ${_tag!.historicalBytes}\nProtocol Info: ${_tag!.protocolInfo}\nApplication Data: ${_tag!.applicationData}\nHigher Layer Response: ${_tag!.hiLayerResponse}\nManufacturer: ${_tag!.manufacturer}\nSystem Code: ${_tag!.systemCode}\nDSF ID: ${_tag!.dsfId}\nNDEF Available: ${_tag!.ndefAvailable}\nNDEF Type: ${_tag!.ndefType}\nNDEF Writable: ${_tag!.ndefWritable}\nNDEF Can Make Read Only: ${_tag!.ndefCanMakeReadOnly}\nNDEF Capacity: ${_tag!.ndefCapacity}\n\n Transceive Result:\n$_result')
: const Text('No tag polled yet.')),
])))),
),
);
}
}

Stop listening to a stream

This program works okay on first build.When I disconnect my device and reconnects it,it is showing, bad state:stream has already been listened to,
Probably error is generated by stream that listening to Bluetooth characteristic.Whats the work around?
import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_blue/flutter_blue.dart';
import 'package:vibration/vibration.dart';
StreamSubscription _scanSubscription;
StreamSubscription _deviceConnection;
Stream<List<int>> stream;
List<double> traceDust = List();
const String CHAR_UUID = "AA:48:F8:CC:07:12";
const String Device_Name = "myDevice";
const String CHARACTERISTIC_UUID = "00000000-0111-1000-4000-000000000000";
BluetoothDeviceState _state;
Map<DeviceIdentifier, ScanResult> scanResults = new Map();
List<BluetoothService> services = new List();
BluetoothCharacteristic characteristic;
FlutterBlue flutterBlue = FlutterBlue.instance;
BluetoothDevice device;
class SearchScreen extends StatefulWidget {
#override
_SearchScreenState createState() => _SearchScreenState();
}
class _SearchScreenState extends State<SearchScreen> {
#override
void initState() {
super.initState();
_startScan();
}
#override
void dispose() {
super.dispose();
_stopScan();
_deviceConnection?.cancel();
_deviceConnection = null;
device.disconnect();
}
_startScan() {
_scanSubscription =
flutterBlue.scan(timeout: Duration(seconds: 4)).listen((scanResult) {
if (CHAR_UUID == scanResult.device.id.toString()) {
_stopScan();
_connect(scanResult.device);
print('connected');
}
}, onDone: _stopScan());
}
_stopScan() {
_scanSubscription?.cancel();
_scanSubscription = null;
}
_connect(BluetoothDevice d) async {
device = d;
await device.connect(autoConnect: true);
await device.discoverServices().then((value) {
setState(() {
services = value;
});
});
_turnOnCharacterService(services);
}
_turnOnCharacterService(List<BluetoothService> ser) async {
ser.forEach((service) {
service.characteristics.forEach((character) {
if (character.uuid.toString() == CHARACTERISTIC_UUID) {
character.setNotifyValue(!character.isNotifying);
setState(() {
stream = character.value;
});
}
});
});
}
String _dataParser(List<int> dataFromDevice) {
return utf8.decode(dataFromDevice);
}
vibrateOnAlert() async {
if (await Vibration.hasVibrator()) {
Vibration.vibrate(duration: 1000);
}
}
#override
Widget build(BuildContext context) {
return Container(
child: StreamBuilder<BluetoothDeviceState>(
stream: device.state,
initialData: BluetoothDeviceState.connecting,
builder: (context, snapshot) {
if (snapshot.data == BluetoothDeviceState.connected) {
return StreamBuilder<List<int>>(
stream: stream,
builder: (context, snapshot) {
var currentValue;
if (snapshot.hasError) {
return Text('Error');
}
if (snapshot.connectionState == ConnectionState.active) {
currentValue = _dataParser(snapshot.data);
traceDust.add(double.tryParse(currentValue) ?? 0);
if (currentValue.toString().compareTo('vibrate') == 0) {
vibrateOnAlert();
}
} else {
return Text('disconnected');
}
print('$currentValue');
return Text('connected');
});
}
return FlatButton(
color: Colors.white,
child: Text('reconnecct'),
onPressed: () {
setState(() {
flutterBlue.startScan(timeout: Duration(seconds: 2));
});
},
);
},
));
}
}
PS: Here flat button does nothing.Since connection state is a streambuilder it automatically reconnects and shows error.

Flutter avoid multiple running FutureBuilder

in my simple code as new screen, unfortunately FutureBuilder work and get data from method twice!!
i'm not sure whats problem and how can i avoid that
class LessonDetail extends StatefulWidget {
final String monthKey;
final String lessonFileKey;
LessonDetail({#required this.monthKey, #required this.lessonFileKey});
#override
State<StatefulWidget> createState() {
return _LessonDetailState(monthKey, lessonFileKey);
}
}
class _LessonDetailState extends BaseState<LessonDetail> {
String monthKey;
String lessonFileKey;
_LessonDetailState(this.monthKey, this.lessonFileKey);
#override
Widget build(BuildContext context) {
return Directionality(
textDirection: TextDirection.rtl,
child: Scaffold(
body: FutureBuilder(
future: _getLessonDetail(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
PlayLessonResponse response = snapshot.data;
print(response);
}
return Center(
child: CircularProgressIndicator(),
);
}),
),
);
}
Future<PlayLessonResponse> _getLessonDetail() async {
AudioList audioList = AudioList(
'http://www.sample.com',
'aaaaa'
);
List<AudioList> lst = [audioList,audioList,audioList];
PlayLessonResponse response = PlayLessonResponse(
2,
'',
'http://www.sample.com',
'2',
lst,
1,
'ssss'
);
print('++++++++++++++++++++');
return response;
}
}
BaseState class content:
abstract class BaseState<T extends StatefulWidget> extends State {
final Connectivity _connectivity = Connectivity();
StreamSubscription<ConnectivityResult> _connectivitySubscription;
bool isOnline = true;
Future<void> initConnectivity() async {
try {
await _connectivity.checkConnectivity();
} on PlatformException catch (e) {
print(e.toString());
}
if (!mounted) {
return;
}
await _updateConnectionStatus().then((bool isConnected){
if(mounted){
setState(() {
isOnline = isConnected;
});
}
});
}
#override
void initState() {
super.initState();
initConnectivity();
_connectivitySubscription = Connectivity()
.onConnectivityChanged
.listen((ConnectivityResult result) async {
await _updateConnectionStatus().then((bool isConnected){
if(mounted){
setState(() {
isOnline = isConnected;
});
}
});
});
}
#override
void dispose() {
_connectivitySubscription.cancel();
super.dispose();
}
Future<bool> _updateConnectionStatus() async {
bool isConnected;
try {
final List<InternetAddress> result =
await InternetAddress.lookup('google.com');
if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
isConnected = true;
}
} on SocketException catch (_) {
isConnected = false;
return false;
}
return isConnected;
}
}
output:
I/flutter (32289): ++++++++++++++++++++
I/flutter (32289): ++++++++++++++++++++
Just like what #Ricardo said, you shouldn't call the function directly inside the FutureBuilder's future method.
Instead, you should 1st run your function in init state, and store the response in a new variable. Only then assign variable to the future of FutureBuilder.
Code Example:
class LessonDetail extends StatefulWidget {
final String monthKey;
final String lessonFileKey;
LessonDetail({#required this.monthKey, #required this.lessonFileKey});
#override
State<StatefulWidget> createState() {
return _LessonDetailState(monthKey, lessonFileKey);
}
}
class _LessonDetailState extends BaseState<LessonDetail> {
String monthKey;
String lessonFileKey;
Future<PlayLesssonResponse> _myResponse; //added this line
_LessonDetailState(this.monthKey, this.lessonFileKey);
#override
void initState() {
_myResponse = _getLessonDetail(); // added this line
super.initState();
}
#override
Widget build(BuildContext context) {
return Directionality(
textDirection: TextDirection.rtl,
child: Scaffold(
body: FutureBuilder(
future: _myResponse, //use _myResponse variable here
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
PlayLessonResponse response = snapshot.data;
print(response);
}
return Center(
child: CircularProgressIndicator(),
);
}),
),
);
}
Future<PlayLessonResponse> _getLessonDetail() async {
AudioList audioList = AudioList(
'http://www.sample.com',
'aaaaa'
);
List<AudioList> lst = [audioList,audioList,audioList];
PlayLessonResponse response = PlayLessonResponse(
2,
'',
'http://www.sample.com',
'2',
lst,
1,
'ssss'
);
print('++++++++++++++++++++');
return response;
}
}