0
I am creating an application in flutter to train but this presenting the following error:
Launching lib main.Dart on Motorola one Vision in debug mode... Running Gradle task 'assembleDebug'... Error: Cannot run with sound null Safety, because the following dependencies don’t support null Safety:
- package:path_provider
- package:path_provider_linux
- package:path_provider_windows
- package:path_provider_platform_interface
- package:xdg_directories
- package:plugin_platform_interface
For Solutions, see https://dart.dev/go/unsound-null-safety
FAILURE: Build failed with an Exception.
Where: Script 'C: src flutter Packages flutter_tools Gradle flutter.Gradle' line: 1035
What Went Wrong: Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command 'C: src flutter bin flutter.bat'' finished with non-zero Exit value 1
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED IN 34s Exception: Gradle task assembleDebug failed with Exit code 1
the code is this:
import 'dart:convert';
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// ignore: import_of_legacy_library_into_null_safe
import "package:path_provider/path_provider.dart";
import 'dart:async';
void main() {
runApp(MaterialApp(
home: Home(),
));
}
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
List _toDoList= ["daniel","Marcos"];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Lista de Tarefas"),
backgroundColor: Colors.blueAccent,
centerTitle: true,
),
body: Column(
children: <Widget>[
Container(
padding: EdgeInsets.fromLTRB(17.0, 1.0, 7.0, 1.0),
child: Row(
children: <Widget>[
Expanded
(child: TextField(
decoration: InputDecoration(
labelText: "Nova Tarefe",
labelStyle: TextStyle(color: Colors.blueAccent),
),
),
),
RaisedButton(
color: Colors.blueAccent,
child: Text("ADD"),
textColor: Colors.white,
onPressed: (){},
),
],
),
),
Expanded(
child: ListView.builder(
padding: EdgeInsets.only(top: 10.0),
itemCount: _toDoList.length,
itemBuilder: (context, index){
return ListTile(
title: Text(_toDoList[index]),
);
},
),
),
],
),
);
}
Future<File> _getFile() async{
final directory = await getApplicationDocumentsDirectory();
return File("${directory.path}/data.json");
}
Future<File> _saveData() async{
String data = json.encode(_toDoList);
final file = await _getFile();
return file.writeAsString(data);
}
Future<String> _readData() async{
try{
final file = await _getFile();
return file.readAsString();
}catch (e){
return null;
}
}
}