I want to create flutter app which speak my text and also save it into the storage. below is my code when I add tts package and path_provider then it show me this error
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/container.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter_tts/flutter_tts.dart';
import 'package:path_provider/path_provider.dart';
class MyPage extends StatefulWidget {
const MyPage({super.key});
@override
State<MyPage> createState() => _MyPageState();
}
class _MyPageState extends State<MyPage> {
@override
final _textController = TextEditingController();
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Input Page'),
),
body: Column(
children: [
Padding(
padding: EdgeInsets.all(8.0),
child: TextField(
controller: _textController,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ElevatedButton(
onPressed: () {
// Add code to perform speech here
},
child: Text('Speak'),
),
ElevatedButton(
onPressed: () {
// Add code to save data here
},
child: Text('Save'),
),
],
),
],
),
);
}
}
it show me this error Flutter Fix
│ The plugin flutter_tts requires a higher Android SDK version.
│
│ Fix this issue by adding the following to the file C:\flutter all project\3\master flutter
│
│ course\delete this file\flutter_application_1\android\app\build.gradle:
│
│ android {
│
│ defaultConfig {
│
│ minSdkVersion 21
│
│ }
│
│ }
│
│ │
│ Note that your app won't be available to users running Android SDKs below 21.
Alternatively, try to find a version of this plugin that supports these lower versions of the
│
│ Android SDK.
│
│ For more information, see:
│
│ https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration
│
CodePudding user response:
Go to android/app/build.gradle file of your project and change you minSdkVersion to 21.
defaultConfig {
//...
minSdkVersion 21
//...
}