Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'dart:async';
- import 'dart:io';
- import 'dart:typed_data';
- import 'package:audioplayers/audioplayers.dart';
- import 'package:avatar_glow/avatar_glow.dart';
- import 'package:connectivity/connectivity.dart';
- import 'package:flutter_audio_recorder2/flutter_audio_recorder2.dart';
- import 'package:http/http.dart';
- // import 'package:just_audio/just_audio.dart';
- import 'package:nlp/data/model/response/report_model.dart';
- import 'package:nlp/helper/route_helper.dart';
- import 'package:nlp/provider/auth_provider.dart';
- import 'package:nlp/provider/sentence_provider.dart';
- import 'package:nlp/provider/sql_provider.dart';
- import 'package:nlp/utill/images.dart';
- import 'package:nlp/view/base/custom_app_bar.dart';
- import 'package:nlp/view/base/custom_snackbar.dart';
- import 'package:nlp/view/screens/home/home_screen.dart';
- import 'package:flutter/material.dart';
- import 'package:nlp/utill/color_resources.dart';
- import 'package:nlp/utill/dimensions.dart';
- import 'package:nlp/utill/styles.dart';
- import 'package:path_provider/path_provider.dart';
- import 'package:provider/provider.dart';
- import 'package:shared_preferences/shared_preferences.dart';
- class RecordScreen extends StatefulWidget {
- final Function onSaved;
- const RecordScreen({Key key, @required this.onSaved}) : super(key: key);
- @override
- _RecordScreenState createState() => _RecordScreenState();
- }
- enum RecordingState {
- UnSet,
- Set,
- Recording,
- Stopped,
- }
- class _RecordScreenState extends State<RecordScreen> {
- IconData _recordIcon = Icons.mic_none;
- RecordingState _recordingState = RecordingState.UnSet;
- // Recorder properties
- FlutterAudioRecorder2 audioRecorder;
- final PageController _pageController = PageController();
- StreamSubscription<ConnectivityResult> _onConnectivityChanged;
- bool isNotConnected = false;
- List<Map<String, dynamic>> _localdb = [];
- List<Map<String, dynamic>> _sentencedb = [];
- Directory appDirectory;
- List<String> records = [];
- //
- AudioPlayer audioPlayer = AudioPlayer();
- AudioCache audioCache;
- @override
- void initState() {
- super.initState();
- FlutterAudioRecorder2.hasPermissions.then((hasPermision) {
- if (hasPermision) {
- _recordingState = RecordingState.Set;
- _recordIcon = Icons.mic;
- }
- });
- //
- _onConnectivityChanged = Connectivity()
- .onConnectivityChanged
- .listen((ConnectivityResult result) {
- setState(() {
- isNotConnected = true;
- });
- isNotConnected = result != ConnectivityResult.wifi &&
- result != ConnectivityResult.mobile;
- print('-----------------${isNotConnected ? 'Not' : 'Yes'}');
- isNotConnected
- ? SizedBox()
- : ScaffoldMessenger.of(context).hideCurrentSnackBar();
- ScaffoldMessenger.of(context).showSnackBar(SnackBar(
- backgroundColor: isNotConnected ? Colors.red : Colors.green,
- duration: Duration(seconds: isNotConnected ? 6000 : 3),
- content: Text(
- isNotConnected ? 'no connection' : 'connected',
- textAlign: TextAlign.center,
- ),
- ));
- setState(() {
- isNotConnected = false;
- });
- });
- print('==========');
- print(_localdb);
- print('============');
- _refreshJournals();
- _getsentences();
- getApplicationDocumentsDirectory().then((value) {
- appDirectory = value;
- appDirectory.list().listen((onData) {
- if (onData.path.contains('.wav')) records.add(onData.path);
- }).onDone(() {
- records = records.reversed.toList();
- setState(() {});
- });
- });
- print('=======');
- print(records.length);
- print('=======');
- }
- void _refreshJournals() async {
- final data = await SQLHelper.getItems();
- setState(() {
- _localdb = data;
- });
- }
- void _getsentences() async {
- final data = await SQLHelper.getsentence();
- setState(() {
- _sentencedb = data;
- });
- print('====sentences===');
- print(_sentencedb.length);
- print('=======');
- }
- final GlobalKey<ScaffoldState> _scaffoldkey = new GlobalKey<ScaffoldState>();
- String _convertToString(int number) {
- switch (number) {
- case 0:
- return '1';
- case 1:
- return '2';
- case 2:
- return '3';
- case 3:
- return '4';
- case 4:
- return '5';
- }
- assert(false, 'invalid: $number');
- return '';
- }
- @override
- Widget build(BuildContext context) {
- final ScrollController _scrollController = ScrollController();
- return Consumer<SentenceProvider>(
- builder: (context, sentence, child) => Scaffold(
- key: _scaffoldkey,
- appBar: CustomAppBar(
- title: 'Speak',
- onBackPressed: () {
- Navigator.of(context).pushReplacementNamed(RouteHelper.home,
- arguments: HomeScreen());
- },
- ),
- backgroundColor: Colors.white,
- body: SafeArea(
- child: _sentencedb.length != 0
- ? Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 20, vertical: 5),
- child: Container(
- width: double.infinity,
- padding: EdgeInsets.all(
- Dimensions.PADDING_SIZE_DEFAULT),
- margin: EdgeInsets.only(
- bottom: Dimensions.PADDING_SIZE_SMALL),
- height:
- MediaQuery.of(context).size.height * .3,
- child: Column(
- crossAxisAlignment:
- CrossAxisAlignment.center,
- mainAxisAlignment:
- MainAxisAlignment.spaceEvenly,
- children: [
- SizedBox(height: 10),
- Text(
- '${_sentencedb[sentence.sentenceNumber]['text']}',
- textAlign: TextAlign.center,
- style: poppinsSemiBold.copyWith(
- fontSize: Dimensions
- .FONT_SIZE_DEFAULT,
- color:
- ColorResources.getTextColor(
- context)))
- ]),
- )),
- Container(
- height: 60,
- child: new GridView.builder(
- gridDelegate:
- SliverGridDelegateWithFixedCrossAxisCount(
- crossAxisSpacing: 2,
- mainAxisSpacing: 2,
- childAspectRatio: 2,
- crossAxisCount: 5),
- itemCount: _sentencedb.length < 6
- ? _sentencedb.length
- : 5,
- padding: EdgeInsets.symmetric(
- horizontal:
- Dimensions.PADDING_SIZE_DEFAULT),
- physics: NeverScrollableScrollPhysics(),
- shrinkWrap: true,
- itemBuilder: (_, i) {
- return Container(
- height: 50,
- width: 50,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- boxShadow: [
- BoxShadow(
- color:
- ColorResources.getGreyColor(
- context)
- .withOpacity(0.8),
- spreadRadius: 3,
- blurRadius: 8,
- offset: Offset(0,
- 3), // changes position of shadow
- ),
- ],
- color: sentence.sentenceNumber != i
- ? ColorResources
- .getBackgroundColor(context)
- : ColorResources
- .getSecondaryColor(context)),
- child: Center(
- child: Text(_convertToString(i),
- textAlign: TextAlign.center,
- style: poppinsSemiBold.copyWith(
- fontSize: Dimensions
- .FONT_SIZE_DEFAULT,
- color:
- sentence.sentenceNumber != i
- ? Colors.black
- : Colors.white)),
- ),
- );
- }),
- ),
- Padding(
- padding:
- const EdgeInsets.symmetric(horizontal: 20),
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Expanded(
- child: Padding(
- padding: EdgeInsets.only(
- left: Dimensions.PADDING_SIZE_SMALL,
- ),
- child: Column(
- crossAxisAlignment:
- CrossAxisAlignment.start,
- mainAxisAlignment:
- MainAxisAlignment.start,
- children: [
- Row(
- children: [
- Flexible(
- child: Text(
- '"Click the record button then read the sentence aloud"',
- maxLines: 4,
- softWrap: true,
- textAlign:
- TextAlign.center,
- overflow: TextOverflow
- .ellipsis,
- style: poppinsMedium.copyWith(
- fontSize: Dimensions
- .FONT_SIZE_SMALL,
- color: ColorResources
- .getTextColor(
- context))),
- ),
- ],
- ),
- ]),
- ),
- ),
- ]),
- ),
- _sentencedb.length != 0
- ? Align(
- alignment: Alignment.center,
- child: Container(
- alignment: Alignment.center,
- width: double.infinity,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment:
- CrossAxisAlignment.center,
- children: <Widget>[
- AvatarGlow(
- animate: true,
- glowColor: Colors.blueAccent,
- endRadius: 80.0,
- duration: const Duration(
- milliseconds: 2000),
- repeatPauseDuration:
- const Duration(
- milliseconds: 100),
- repeat: true,
- child: InkWell(
- onTap: () async {
- _localdb.length == 0
- ? await _onRecordButtonPressed(
- _sentencedb[sentence
- .sentenceNumber]
- ['id'],
- _sentencedb[sentence
- .sentenceNumber]
- ['text'])
- : showCustomSnackBar(
- 'Please submit your saved recordings',
- context,
- isError: true);
- },
- child: Container(
- height: 60,
- width: 60,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: ColorResources
- .getBackgroundColor(
- context),
- boxShadow: [
- BoxShadow(
- color: ColorResources
- .getGreyColor(
- context)
- .withOpacity(0.8),
- spreadRadius: 3,
- blurRadius: 8,
- offset: Offset(0,
- 3), // changes position of shadow
- ),
- ],
- ),
- child: Icon(
- _recordIcon,
- color: ColorResources
- .getPrimaryColor(
- context),
- ),
- ),
- )),
- Container(height: 5),
- Padding(
- padding: const EdgeInsets.all(15.0),
- child: Row(
- crossAxisAlignment:
- CrossAxisAlignment.start,
- mainAxisAlignment:
- MainAxisAlignment
- .spaceBetween,
- children: [
- InkWell(
- onTap: () async {
- await showDialog(
- context: context,
- builder: (_) {
- return ReportDialog(
- sentenceid: _sentencedb[
- sentence
- .sentenceNumber]['id']
- .toString(),
- sentences:
- _sentencedb
- .length,
- );
- });
- // ignore: await_only_futures
- await _getsentences();
- },
- child: Container(
- height: 48,
- width:
- MediaQuery.of(context)
- .size
- .width *
- .4,
- decoration: BoxDecoration(
- border: Border.all(
- width: 1,
- style:
- BorderStyle.solid,
- color: ColorResources
- .getPrimaryColor(
- context),
- ),
- borderRadius:
- const BorderRadius
- .all(
- Radius.circular(5.0),
- ),
- ),
- child: Row(
- crossAxisAlignment:
- CrossAxisAlignment
- .center,
- mainAxisAlignment:
- MainAxisAlignment
- .center,
- children: [
- Icon(Icons.flag,
- color:
- Colors.black),
- SizedBox(
- width: 5,
- ),
- Text(
- 'Report',
- textAlign:
- TextAlign.left,
- style: poppinsLight.copyWith(
- fontSize: Dimensions
- .FONT_SIZE_LARGE,
- color: ColorResources
- .getPrimaryColor(
- context)),
- ),
- ],
- ),
- )),
- InkWell(
- onTap: () async {
- // if (_sentencedb.length <
- // 5) {
- // setState(() {
- // _getsentences();
- // });
- // sentence.nextSentence();
- // } else {
- await sentence.skipsentence(
- _sentencedb[sentence
- .sentenceNumber]
- ['id'],
- context);
- // ignore: await_only_futures
- // await _getsentences();
- // }
- setState(() {
- _getsentences();
- });
- },
- child: Container(
- height: 48,
- width:
- MediaQuery.of(context)
- .size
- .width *
- .4,
- decoration: BoxDecoration(
- border: Border.all(
- width: 1,
- style:
- BorderStyle.solid,
- color: ColorResources
- .getPrimaryColor(
- context),
- ),
- borderRadius:
- const BorderRadius
- .all(
- Radius.circular(5.0),
- ),
- ),
- child: !sentence.isLoading
- ? Row(
- crossAxisAlignment:
- CrossAxisAlignment
- .center,
- mainAxisAlignment:
- MainAxisAlignment
- .center,
- children: [
- Icon(
- Icons
- .forward,
- color: Colors
- .black),
- SizedBox(
- width: 5,
- ),
- Text(
- 'Skip',
- textAlign:
- TextAlign
- .left,
- style: poppinsLight.copyWith(
- fontSize:
- Dimensions
- .FONT_SIZE_LARGE,
- color: ColorResources
- .getPrimaryColor(
- context)),
- ),
- ],
- )
- : Center(
- child:
- CircularProgressIndicator(
- valueColor: AlwaysStoppedAnimation<
- Color>(Theme.of(
- context)
- .primaryColor),
- )),
- ))
- ],
- ),
- ),
- ],
- ),
- ),
- )
- : SizedBox()
- ])
- : Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Align(
- alignment: Alignment.center,
- child: Container(
- color: Colors.white,
- alignment: Alignment.center,
- width: double.infinity,
- height: MediaQuery.of(context).size.height * .5,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: <Widget>[
- Image.asset(
- Images.empty,
- scale: 8,
- color: ColorResources.getHintColor(context),
- ),
- Container(height: 5),
- Padding(
- padding: const EdgeInsets.all(15.0),
- child: Text('Oops!!',
- textAlign: TextAlign.center,
- style: poppinsBold.copyWith(
- fontSize: 14, color: Colors.black)),
- ),
- Padding(
- padding: const EdgeInsets.all(15.0),
- child: Text(
- 'There are no sentences, Please try again later',
- textAlign: TextAlign.center,
- style: poppinsRegular.copyWith(
- fontSize: 14,
- color: ColorResources.getHintColor(
- context)),
- )),
- ],
- ),
- ),
- )
- ],
- ),
- ),
- ));
- }
- //
- processingDialog(message) {
- return showDialog(
- barrierDismissible: false,
- context: context,
- builder: (context) {
- return AlertDialog(
- content: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- CircularProgressIndicator(
- strokeWidth: 2,
- ),
- SizedBox(
- width: 10,
- ),
- Expanded(
- child: Text(
- message,
- style: poppinsRegular.copyWith(
- fontSize: Dimensions.FONT_SIZE_SMALL,
- color: ColorResources.getHintColor(context)),
- ),
- )
- ],
- ),
- );
- });
- }
- //
- Future<void> _onRecordButtonPressed(int sentenceid, String sentence) async {
- switch (_recordingState) {
- case RecordingState.Set:
- await _recordVoice(sentenceid, sentence);
- break;
- case RecordingState.Recording:
- await _stopRecording(sentenceid, sentence);
- _recordingState = RecordingState.Stopped;
- _recordIcon = Icons.mic;
- break;
- case RecordingState.Stopped:
- await _recordVoice(sentenceid, sentence);
- break;
- case RecordingState.UnSet:
- ScaffoldMessenger.of(context).hideCurrentSnackBar();
- ScaffoldMessenger.of(context).showSnackBar(SnackBar(
- content: Text('Please allow recording from settings.'),
- ));
- break;
- }
- }
- String audiopathurl;
- _initRecorder(int id, String sentence) async {
- SharedPreferences preferences = await SharedPreferences.getInstance();
- String lan = preferences.getString('lang');
- print('======');
- print(lan);
- print('======');
- Directory appDirectory = await getApplicationDocumentsDirectory();
- String filePath =
- appDirectory.path + '/' + lan + '_' + id.toString() + '.wav';
- audioRecorder =
- FlutterAudioRecorder2(filePath, audioFormat: AudioFormat.WAV);
- await audioRecorder.initialized;
- setState(() {
- audiopathurl = filePath;
- });
- print(audiopathurl);
- }
- _startRecording() async {
- await audioRecorder.start();
- }
- // ignore: missing_return
- Future<int> deleteFile(String filepath) async {
- try {
- final file = File(filepath);
- await file.delete();
- } catch (e) {
- return 0;
- }
- }
- _stopRecording(int id, String sentence) async {
- SharedPreferences preferences = await SharedPreferences.getInstance();
- int currentindex = preferences.setInt('currentindex', id) as int;
- print('======');
- print(currentindex);
- print('======');
- var result = await audioRecorder.stop();
- var p = result.duration.inSeconds;
- print("Stop recording: $p");
- print('=======seconds=========');
- if (result.duration.inSeconds < 1) {
- showCustomSnackBar('Try recording again!', context);
- deleteFile(audiopathurl);
- } else {
- SQLHelper.createItem(id, sentence, audiopathurl);
- print('=================');
- print(audiopathurl);
- print('=============');
- if (Provider.of<SentenceProvider>(context, listen: false).sentenceNumber <
- _sentencedb.length - 1) {
- // ignore: unnecessary_statements
- Provider.of<SentenceProvider>(context, listen: false).sentenceNumber +
- 1;
- Provider.of<SentenceProvider>(context, listen: false).nextSentence();
- } else if (isNotConnected == true) {
- print(
- '${Provider.of<SentenceProvider>(context, listen: false).sentenceNumber}');
- processingDialog('Please wait while submitting clips');
- setState(() {
- _refreshJournals();
- });
- Provider.of<SentenceProvider>(context, listen: false)
- .sendAudios(
- _localdb,
- Provider.of<AuthProvider>(context, listen: false).getUserToken(),
- )
- .then((value) => SQLHelper.deleteItems().then((value) => showDialog(
- context: context,
- builder: (_) {
- return Dialog(
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(10),
- ),
- elevation: 0,
- backgroundColor: Colors.transparent,
- child: Stack(
- children: <Widget>[
- Container(
- padding: EdgeInsets.only(
- left: 20, top: 40, right: 20, bottom: 20),
- margin: EdgeInsets.only(top: 20),
- decoration: BoxDecoration(
- shape: BoxShape.rectangle,
- color: Colors.white,
- borderRadius: BorderRadius.circular(10),
- boxShadow: [
- BoxShadow(
- color: Colors.black,
- offset: Offset(0, 10),
- blurRadius: 10),
- ]),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: <Widget>[
- Text(
- 'Success',
- style: TextStyle(
- fontSize: 22, fontWeight: FontWeight.w600),
- ),
- SizedBox(
- height: 15,
- ),
- Text(
- 'Thank you for contributing ,your clips have been captured',
- textAlign: TextAlign.center,
- style: poppinsRegular.copyWith(
- fontSize: Dimensions.FONT_SIZE_SMALL,
- color: ColorResources.getHintColor(
- context))),
- SizedBox(
- height: 22,
- ),
- InkWell(
- onTap: () {
- Navigator.of(context).pushReplacementNamed(
- RouteHelper.home,
- arguments: HomeScreen());
- },
- child: Align(
- alignment: Alignment.center,
- child: Container(
- width: MediaQuery.of(context).size.width *
- .5,
- height: 50,
- decoration: new BoxDecoration(
- color: Theme.of(context).primaryColor,
- shape: BoxShape.rectangle,
- borderRadius: BorderRadius.circular(5),
- ),
- child: Center(
- child: Text(
- 'ok',
- style: poppinsMedium.copyWith(
- fontSize:
- Dimensions.FONT_SIZE_DEFAULT,
- color: Colors.white),
- ),
- ),
- )),
- ),
- ],
- ),
- ),
- Positioned(
- left: 20,
- right: 20,
- child: CircleAvatar(
- backgroundColor: Theme.of(context).primaryColor,
- radius: 30,
- child: ClipRRect(
- borderRadius:
- BorderRadius.all(Radius.circular(20)),
- child: Icon(Icons.check,
- size: 30, color: Colors.white)),
- ),
- ),
- ],
- ),
- );
- })));
- } else {
- Navigator.pushNamedAndRemoveUntil(
- context, RouteHelper.getRecordingsRoute(), (route) => false);
- }
- }
- }
- Future<void> _recordVoice(int id, String sentence) async {
- final hasPermission = await FlutterAudioRecorder2.hasPermissions;
- if (hasPermission ?? false) {
- await _initRecorder(id, sentence);
- await _startRecording();
- _recordingState = RecordingState.Recording;
- _recordIcon = Icons.stop;
- } else {
- // ScaffoldMessenger.of(context).hideCurrentSnackBar();
- // ScaffoldMessenger.of(context).showSnackBar(SnackBar(
- // content: Text('Please allow recording from settings.'),
- // ));
- showCustomSnackBar('Please allow recording from settings', context);
- }
- }
- }
- class ReportDialog extends StatefulWidget {
- final String sentenceid;
- final int sentences;
- const ReportDialog({Key key, this.sentenceid, this.sentences})
- : super(key: key);
- @override
- State<ReportDialog> createState() => _ReportDialogState();
- }
- class _ReportDialogState extends State<ReportDialog> {
- List<String> titledata = [
- "Offensive language",
- "Grammatical / spelling error",
- "Different language",
- "Difficult to pronounce",
- "Others"
- ];
- List<String> subtitledata = [
- "The sentence has disrespectful or offensive language.",
- "The sentence has a grammatical or spelling error.",
- "It is written in a language different than what I’m speaking.",
- "It contains words or phrases that are hard to read or pronounce.",
- " "
- ];
- List userChecked = [];
- //
- void _onSelected(bool selected, String dataName) {
- if (selected == true) {
- setState(() {
- userChecked.add(dataName);
- });
- } else {
- setState(() {
- userChecked.remove(dataName);
- });
- }
- }
- // test stepper
- @override
- Widget build(BuildContext context) {
- return Consumer<SentenceProvider>(
- builder: (_, sentenceProvider, child) => Dialog(
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(10),
- ),
- elevation: 0,
- backgroundColor: Colors.transparent,
- child: Container(
- height: MediaQuery.of(context).size.height * .8,
- padding: EdgeInsets.only(left: 20, top: 40, right: 20, bottom: 20),
- margin: EdgeInsets.only(top: 20),
- decoration: BoxDecoration(
- shape: BoxShape.rectangle,
- color: Colors.white,
- borderRadius: BorderRadius.circular(10),
- boxShadow: [
- BoxShadow(
- color: Colors.black,
- offset: Offset(0, 10),
- blurRadius: 10),
- ]),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: <Widget>[
- Text(
- 'Submit a report',
- style: TextStyle(fontSize: 22, fontWeight: FontWeight.w600),
- ),
- SizedBox(
- height: 15,
- ),
- Text('What issues are you experiencing with this sentence?',
- textAlign: TextAlign.center,
- style: poppinsRegular.copyWith(
- fontSize: Dimensions.FONT_SIZE_SMALL,
- color: ColorResources.getHintColor(context))),
- SizedBox(height: Dimensions.FONT_SIZE_EXTRA_SMALL),
- Divider(),
- SizedBox(height: Dimensions.FONT_SIZE_EXTRA_SMALL),
- Container(
- height: MediaQuery.of(context).size.height * .4,
- child: new ListView.builder(
- itemCount: titledata.length,
- itemBuilder: (context, i) {
- return ListTile(
- title: Text(titledata[i],
- style: poppinsSemiBold.copyWith(
- fontSize: Dimensions.FONT_SIZE_SMALL,
- color: ColorResources.getHintColor(
- context))),
- subtitle: Text(subtitledata[i],
- style: poppinsRegular.copyWith(
- fontSize:
- Dimensions.FONT_SIZE_EXTRA_SMALL,
- color: ColorResources.getHintColor(
- context))),
- trailing: Checkbox(
- value: userChecked.contains(titledata[i]),
- activeColor:
- ColorResources.getSecondaryColor(context),
- onChanged: (val) {
- setState(() {
- _onSelected(val, titledata[i]);
- });
- print(titledata[i]);
- },
- ));
- })),
- SizedBox(height: Dimensions.FONT_SIZE_LARGE),
- !sentenceProvider.isLoading
- ? InkWell(
- onTap: () async {
- String commaSeparated = userChecked.join(', ');
- if (userChecked.isEmpty) {
- showCustomSnackBar(
- 'Select atleast one issue', context);
- } else {
- ReportModel reportModel = ReportModel(
- id: widget.sentenceid, report: commaSeparated);
- print('=====issues====');
- print(reportModel.toJson());
- await sentenceProvider
- .hasIssue(
- reportModel,
- Provider.of<AuthProvider>(context,
- listen: false)
- .getUserToken(),
- context)
- .then((value) {
- Navigator.pop(context);
- setState(() {});
- });
- }
- },
- child: Align(
- alignment: Alignment.center,
- child: Container(
- width: MediaQuery.of(context).size.width * .4,
- height: 40,
- decoration: new BoxDecoration(
- color: userChecked.isEmpty
- ? Colors.grey
- : Theme.of(context).primaryColor,
- shape: BoxShape.rectangle,
- borderRadius: BorderRadius.circular(5),
- ),
- child: Center(
- child: Text(
- 'Report',
- style: poppinsMedium.copyWith(
- fontSize: Dimensions.FONT_SIZE_DEFAULT,
- color: Colors.white),
- ),
- ),
- )),
- )
- : Center(
- child: CircularProgressIndicator(
- valueColor: new AlwaysStoppedAnimation<Color>(
- Theme.of(context).primaryColor),
- )),
- ],
- ),
- )),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement