initState called after build drawer menu - flutter

I have a drawer menu in my scaffold, and I want to show some information from Flutter secure storage.
class DrawerMenu extends StatefulWidget {
final Translations translations;
final PageController controller;
const DrawerMenu({
Key? key,
required this.translations,
required this.controller,
}) : super(key: key);
#override
State<DrawerMenu> createState() => _DrawerMenuState();
}
String? name;
String? email;
final FlutterSecureStorage storage = FlutterSecureStorage();
class _DrawerMenuState extends State<DrawerMenu> {
#override
void initState() {
getInfo();
super.initState();
}
getInfo() async {
name = await storage.read(key: 'name');
email = await storage.read(key: 'email');
}
#override
Widget build(BuildContext context) {
Translations translations = Translations.of(context);
return Drawer(
backgroundColor: AppColors.secondaryColor,
child: SafeArea(
bottom: false,
child: Column(
children: [
ClipOval(
child: Container(
color: AppColors.primaryColor,
height: 60.0,
width: 60.0,
child: Center(
child: Text(
name![0],
style: TextStyle(
color: AppColors.secondaryColor,
fontSize: 30,
fontWeight: FontWeight.bold),
),
),
),
),
);
}
}
The first time I have this error: _CastError (Null check operator used on a null value)
But if I try to go next and re open drawer, so done!
I want to see the name in my drawer menu.

You have to set the state after setting the value in getInfo(). Also, you have to check if the name is null or not before accessing it.
getInfo() async {
name = await storage.read(key: 'name');
email = await storage.read(key: 'email');
setState({}); <-- add this
}
#override
Widget build(BuildContext context) {
Translations translations = Translations.of(context);
return Drawer(
backgroundColor: AppColors.secondaryColor,
child: SafeArea(
bottom: false,
child: Column(
children: [
ClipOval(
child: Container(
color: AppColors.primaryColor,
height: 60.0,
width: 60.0,
child: Center(
child: Text(
name==null? "" : name![0] ?? "", <-- update this
style: TextStyle(
color: AppColors.secondaryColor,
fontSize: 30,
fontWeight: FontWeight.bold),
),
),
),
),
);
}
}

Related

How to use data stored in Shared Preferences in Text Widget for Flutter

I am trying to display the name of a project in a new page, as a string that I had saved in a previous page using Shared Preferences. Below is the section of code where I saved this:
onPressed: () async {
SharedPreferences localStorage =
await SharedPreferences
.getInstance();
localStorage.setString(
'project_id', nDataList.id);
localStorage.setString(
'project_name',
nDataList.title);
localStorage.setString(
'project_desc',
nDataList.description);
localStorage.setString(
'project_due',
nDataList.endDate);
// ignore: use_build_context_synchronously
Navigator.pushNamed(
context, 'activities');
},
)
In the new page, I am using the get string in a function and then I want to display the result in a text widget. Here is all the code for the second page:
import 'package:flutter/material.dart';
import 'package:mne/Actual%20Tasks/activity_widget.dart';
import 'package:mne/UserTasks/task_widget.dart';
import 'package:shared_preferences/shared_preferences.dart';
class ProjectTask extends StatefulWidget {
const ProjectTask({Key key}) : super(key: key);
#override
State<ProjectTask> createState() => _ProjectTaskState();
}
class _ProjectTaskState extends State<ProjectTask> {
#override
void initState() {
super.initState();
_fetchData();
}
Future<Null> _fetchData() async {
WidgetsFlutterBinding.ensureInitialized();
SharedPreferences localStorage = await SharedPreferences.getInstance();
var pname = localStorage.getString('project_name');
var pdesc = localStorage.getString('project_desc');
var pdue = localStorage.getString('project_due');
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: true,
centerTitle: true,
title: const Text('Project Details')),
body: SingleChildScrollView(
child: Column(children: [
// for image
Container(
child: Image.asset('assets/images/projectbanner.png'),
),
//for project name
Container(
child: Row(children: [
Container(
padding: const EdgeInsets.only(right: 10, top: 8),
child: const Icon(Icons.calendar_month_outlined)),
RichText(
text: TextSpan(children: [
TextSpan(
text: 'Due: ',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Colors.black)),
TextSpan(
text: '$pname',
style: TextStyle(fontSize: 14, color: Colors.black))
])),
])),
// for description title
Container(child: const Text('Description')),
// for actual desc
Container(),
// for task title
Container(),
// for task widget
Container(height: 630, child: const ActivityWidget()),
]),
),
);
}
}
The error that I am getting says that 'pname' is undefined and that it is of type dynamic. How can I use the information saved in the variable in the text widget? Any help is much appreciated
Try this:
class ProjectTask extends StatefulWidget {
const ProjectTask({Key key}) : super(key: key);
#override
State<ProjectTask> createState() => _ProjectTaskState();
}
class _ProjectTaskState extends State<ProjectTask> {
String pname;
String pdesc;
String pdue;
#override
void initState() {
super.initState();
_fetchData();
}
Future<Null> _fetchData() async {
WidgetsFlutterBinding.ensureInitialized();
SharedPreferences localStorage = await SharedPreferences.getInstance();
setState(() {
pname = localStorage.getString('project_name');
pdesc = localStorage.getString('project_desc');
pdue = localStorage.getString('project_due');
});
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: true,
centerTitle: true,
title: const Text('Project Details')),
body: SingleChildScrollView(
child: Column(children: [
// for image
Container(
child: Image.asset('assets/images/projectbanner.png'),
),
//for project name
Container(
child: Row(children: [
Container(
padding: const EdgeInsets.only(right: 10, top: 8),
child: const Icon(Icons.calendar_month_outlined)),
RichText(
text: TextSpan(children: [
TextSpan(
text: 'Due: ',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Colors.black)),
TextSpan(
text: '$pname',
style: TextStyle(fontSize: 14, color: Colors.black))
])),
])),
// for description title
Container(child: const Text('Description')),
// for actual desc
Container(),
// for task title
Container(),
// for task widget
Container(height: 630, child: const ActivityWidget()),
]),
),
);
}
}
Try this
class ProjectTask extends StatefulWidget {
const ProjectTask({Key key}) : super(key: key);
#override
State<ProjectTask> createState() => _ProjectTaskState();
}
class _ProjectTaskState extends State<ProjectTask> {
String pname;
String pdesc;
String pdue;
#override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
await _fetchData();
});
}
Future<Null> _fetchData() async {
WidgetsFlutterBinding.ensureInitialized();
SharedPreferences localStorage = await SharedPreferences.getInstance();
setState(() {
pname = localStorage.getString('project_name');
pdesc = localStorage.getString('project_desc');
pdue = localStorage.getString('project_due');
});
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: true,
centerTitle: true,
title: const Text('Project Details')),
body: SingleChildScrollView(
child: Column(children: [
// for image
Container(
child: Image.asset('assets/images/projectbanner.png'),
),
//for project name
Container(
child: Row(children: [
Container(
padding: const EdgeInsets.only(right: 10, top: 8),
child: const Icon(Icons.calendar_month_outlined)),
RichText(
text: TextSpan(children: [
TextSpan(
text: 'Due: ',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Colors.black)),
TextSpan(
text: '${pname??''}',
style: TextStyle(fontSize: 14, color: Colors.black))
])),
])),
// for description title
Container(child: const Text(pdesc??'')),
// for actual desc
Container(),
// for task title
Container(),
// for task widget
Container(height: 630, child: const ActivityWidget()),
]),
),
);
}
}

Flutter DropZone always showing Circular Progress Indicator

I'm trying to implement the flutter_dropzone 3.0.5 plugin in my app but can't figure out why it seems to be always loading, making it impossible to drop a file in the dropzone area...
Here is my code so far:
class UploadDocument extends StatefulWidget {
final logger = getLogger("UploadDocument view");
UploadDocument({Key? key}) : super(key: key);
#override
State<UploadDocument> createState() => _UploadDocumentState();
}
class _UploadDocumentState extends State<UploadDocument> {
late DropzoneViewController controller;
#override
Widget build(BuildContext context) {
return Card(
elevation: 8,
child: Padding(
padding: const EdgeInsets.all(50),
child: Container(
color: ProjectColors.lighterAccentColor,
child: Stack(
children: [
DropzoneView(
onCreated: (controller) => this.controller = controller,
onDrop: acceptFile,
),
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const <Widget>[
Icon(
Icons.cloud_upload,
color: ProjectColors.blackBgExtraLighter,
size: 50,
),
Text("Drop Files Here",
style: TextStyle(
color: ProjectColors.blackBgExtraLighter,
fontSize: 20))
],
),
),
],
)),
),
);
}
Future acceptFile(dynamic event) async {
final name = event.name;
final mime = await controller.getFileMIME(event);
final bytes = await controller.getFileSize(event);
final url = await controller.createFileUrl(event);
widget.logger.i('name: $name');
widget.logger.i('mime: $mime');
widget.logger.i('bytes: $bytes');
widget.logger.i('url: $url');
}
}
and the result :
Thanks in advance for any advice!!!

'String' is not a sub type of type map<String, dynamic> flutter error

//Hello, I am trying to pass Map as an argument to the new screen but it ends in error with a red screen. here is my code first the class where the Map is defined, I am using firebase for a database with this app.
I am trying to make get job app so the employer post the job(i use textformfield) but when I try to received data as a map it show error
class FloatSearchBar extends StatefulWidget {
const FloatSearchBar({Key? key}) : super(key: key);
#override
FloatSearchBarState createState() => FloatSearchBarState();
}
class FloatSearchBarState extends State<FloatSearchBar> with WidgetsBindingObserver {
Map<String, dynamic>? userMap;
late FloatingSearchBarController controller;
static const historyLength = 4;
#override
void initState() {
super.initState();
controller = FloatingSearchBarController();
filteredSearchHistory = filterSearchTerms(filter: null);
}
isLoading = true;
});
FirebaseFirestore _firestore = FirebaseFirestore.instance;
await _firestore
.collection("PostJob")
.where("jobType", isEqualTo: selectedTerm.toLowerCase())
.get()
.then((value) {
setState(() {
userMap = value.docs[0].data();
isLoading = false;
});
print(userMap);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => searchresultPage(
recevieduserMap: userMap!['jobType'], key: UniqueKey())));
});
}
...
*and now the class which is getting pushed:-
...class searchresultPage extends StatelessWidget {
FloatSearchBar yes = new FloatSearchBar();
Map<String, dynamic> recevieduserMap ;
searchresultPage({required this.recevieduserMap,Key? key,}) : super(key: key);
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Stack(
children: <Widget>[
Positioned.fill(
top: 70,
child: Align(
alignment: Alignment.center,
child: Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Column(
children: <Widget>[
Card(
elevation: 15,
child: Container(
width: double.infinity,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(padding: EdgeInsets.all(2)),
Text('Job Type:- ' + recevieduserMap["jobType"],style: GoogleFonts.breeSerif(
textStyle: TextStyle(
fontSize: 20,wordSpacing: 1),),),
Text('Job Descreption:- '+recevieduserMap["jobDescrebtion"],style: GoogleFonts.breeSerif(
textStyle: TextStyle(
fontSize: 20,wordSpacing: 1),),),
Text('Company Location:- '+recevieduserMap["companyLocation"],style: GoogleFonts.breeSerif(
textStyle: TextStyle(
fontSize: 20,wordSpacing: 1),),),
Text('Company Name:- '+recevieduserMap["companyName"],style: GoogleFonts.breeSerif(
textStyle: TextStyle(
fontSize: 20,wordSpacing: 1),),),
Text('\$${recevieduserMap["payrate"]}'.toString(),style: GoogleFonts.breeSerif(
textStyle: TextStyle(
fontSize: 20,wordSpacing: 1),)),
],
),
),
),
],
),
),
),
],
),
),
),
],
),
),
);
}
}
...

Get all the scores from all widgets

I am building a quiz app and I created a custom widget to save me a lot of time as I have a lot of questions for the quiz. Everything works apart from the scoring system. If I create multiple instances of the same widget the score will not be incremented and it will stay on 1. Is there any way I can pass each score of the widgets to a global variable in my main widget so then I can add all the scores? (I'm new to flutter).
Custom Widget
class Questions extends StatefulWidget {
final String imagePath;
final String question;
final String answer1;
final String answer2;
final String answer3;
final String answer4;
final bool iscorrectAnswer1;
final bool iscorrectAnswer2;
final bool iscorrectAnswer3;
final bool iscorrectAnswer4;
int score = 0;
bool questionsAnswered = false;
Questions(
this.imagePath,
this.question,
this.answer1,
this.answer2,
this.answer3,
this.answer4,
this.iscorrectAnswer1,
this.iscorrectAnswer2,
this.iscorrectAnswer3,
this.iscorrectAnswer4,
);
#override
_QuestionsState createState() => _QuestionsState();
}
class _QuestionsState extends State<Questions> {
disableButton() {
setState(() {
widget.questionsAnswered = true;
Quiz().score += widget.score;
});
}
#override
#override
Widget build(BuildContext context) {
return Column(
children: [
SizedBox(
width: 600,
height: 600,
child: Image.asset(widget.imagePath),
),
Align(
alignment: Alignment.topCenter,
child: Padding(
padding: EdgeInsets.only(
top: 20,
),
child: Text(
widget.question,
style: TextStyle(
color: Colors.white,
fontSize: 38,
),
),
)),
Padding(
padding: EdgeInsets.only(
top: 40,
),
child: SizedBox(
width: 500,
height: 60,
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(15)),
child: ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
Color(0xFF304e60),
),
),
child: Text(
widget.answer1,
style: TextStyle(
color: Colors.white,
fontSize: 15,
),
),
onPressed: widget.questionsAnswered == false
? () {
setState(() {
if (widget.iscorrectAnswer1 == true) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Correct!'),
),
);
disableButton();
widget.score += 1;
} else {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(
content: Text('Wrong Answer!'),
));
}
});
print(widget.iscorrectAnswer1);
print(widget.score);
}
: null),
),
)),
Padding(
padding: EdgeInsets.only(
top: 10,
),
child: SizedBox(
width: 500,
height: 60,
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(15)),
child: ElevatedButton(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all(Color(0xFF565462))),
child: Text(
widget.answer2,
style: TextStyle(
color: Colors.white,
fontSize: 15,
),
),
onPressed: widget.questionsAnswered == false
? () {
setState(() {
if (widget.iscorrectAnswer2 == true) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Correct!'),
),
);
widget.score += 1;
} else {
disableButton();
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(
content: Text('Wrong Answer!'),
));
}
});
}
: null),
),
)),
Padding(
padding: EdgeInsets.only(
top: 10,
),
child: SizedBox(
width: 500,
height: 60,
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(15)),
child: ElevatedButton(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all(Color(0xFF84693b))),
child: Text(
widget.answer3,
style: TextStyle(
color: Colors.white,
fontSize: 15,
),
),
onPressed: widget.questionsAnswered == false
? () {
setState(() {
if (widget.iscorrectAnswer3 == true) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Correct!'),
),
);
widget.score += 1;
} else {
disableButton();
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(
content: Text('Wrong Answer!'),
));
}
});
}
: null),
),
),
)
],
);
}
}
Main widget where I call this custom widget
class Quiz extends StatefulWidget {
Quiz({Key? key}) : super(key: key);
int score = 0;
#override
_QuizState createState() => _QuizState();
}
class _QuizState extends State<Quiz> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('CyberQuiz'),
),
body: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
children: [
Questions(
'images/malware_quiz.jpeg',
'1. What is a malware?',
'Designed to damage computers, servers or any other devices',
"Used to get user's credentials",
"It's used to destroy networks",
'',
true,
false,
false,
false,
),
],
)));
}
}
As you suggest in your question, you could create a global variable and increment/decrease/reset that.
Basic example code:
import 'package:flutter/material.dart';
class Score {
static int score = 0;
}
class ScoreCounter extends StatefulWidget {
const ScoreCounter({Key? key}) : super(key: key);
#override
State<ScoreCounter> createState() => _ScoreCounterState();
}
class _ScoreCounterState extends State<ScoreCounter> {
#override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: ElevatedButton(
onPressed: () {
setState(() {
Score.score++;
});
},
child: Text('increase score'),
),
),
Expanded(child: Text(Score.score.toString()))
],
);
}
}
Another option is to use the Provider package - link here which has an example
Provider Package

Blogger API not loading on flutter

Am trying to load a blog on flutter using API. for some reasons, the file is not loading on the emulator, and the code not showing any errors or suggestions. Once i click run, after the connection, it stops abruptly... Please, if anyone can preview the code and and help me out.. The error log is saying something about immutable, which i don't really follow.. Please help.
Main.dart
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'package:html/parser.dart';
import 'pages/post_view.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
#override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
var _isLoading = true; //For progress bar
var posts;
var imgUrl;
//initialization
void initState() {
super.initState();
_fetchData();
}
//Function to fetch data from JSON
_fetchData() async {
print("attempting");
final url =
"https://www.googleapis.com/blogger/v3/blogs/MY BLOG ID HERE/posts/?key= API KEY HERE";
final response = await http.get(url);
print(response);
if (response.statusCode == 200) {
//HTTP OK is 200
final Map items = json.decode(response.body);
var post = items['items'];
setState(() {
_isLoading = false;
this.posts = post;
});
}
}
#override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("Blogger"),
actions: <Widget>[
new IconButton(
icon: new Icon(Icons.refresh),
onPressed: () {
setState(() {
_isLoading = true;
});
_fetchData();
})
],
),
body: new Center(
child: _isLoading
? new CircularProgressIndicator()
: new ListView.builder(
itemCount: this.posts != null ? this.posts.length : 0,
itemBuilder: (context, i) {
final Post = this.posts[i];
final postDesc = Post["content"];
//All the below code is to fetch the image
var document = parse(postDesc);
//Regular expression
RegExp regExp = new RegExp(
r"(https?:\/\/.*\.(?:png|jpg|gif))",
caseSensitive: false,
multiLine: false,
);
final match = regExp
.stringMatch(document.outerHtml.toString())
.toString();
//print(document.outerHtml);
//print("firstMatch : " + match);
//Converting the regex output to image (Slashing) , since the output from regex was not perfect for me
if (match.length > 5) {
if (match.contains(".jpg")) {
imgUrl = match.substring(0, match.indexOf(".jpg"));
print(imgUrl);
} else {
imgUrl =
"https://pbs.twimg.com/profile_images/916384996092448768/PF1TSFOE_400x400.jpg";
}
}
String description = document.body.text.trim();
//print(description);
return new Container(
padding:
const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 8.0),
child: new Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Container(
width: 500.0,
height: 180.0,
decoration: new BoxDecoration(
shape: BoxShape.rectangle,
image: new DecorationImage(
fit: BoxFit.fill,
//check if the image is not null (length > 5) only then check imgUrl else display default img
image: new NetworkImage(imgUrl
.toString()
.length >
10
? imgUrl.toString()
: "https://pbs.twimg.com/profile_images/916384996092448768/PF1TSFOE_400x400.jpg")),
),
),
new Padding(
padding:
const EdgeInsets.symmetric(vertical: 10.0),
child: new Text(
Post["title"],
maxLines: 3,
style: new TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
),
),
),
new Text(
description.replaceAll("\n", ", "),
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: new TextStyle(fontSize: 15.0),
),
new Padding(
padding:
const EdgeInsets.symmetric(vertical: 16.0),
child: new RaisedButton(
child: new Text("READ MORE",style: new TextStyle(color: Colors.white),),
color: Colors.blue,
onPressed: () {
//We will pass description to postview through an argument
Navigator
.of(context)
.push(new MaterialPageRoute<Null>(
builder: (BuildContext context) {
return PostView(Post['title'],description,imgUrl);
},
));
},
),
),
Divider(),
],
),
);
},
)));
}
}
Post_view.dart
import 'package:flutter/material.dart';
class PostView extends StatelessWidget {
var desc, title, image;
PostView(String title, String desc, String image) {
this.desc = desc;
this.title = title;
this.image = image;
}
#override
Widget build(BuildContext context) {
if (desc.toString().contains("\n\n\n\n")) {
desc = desc.toString().replaceAll("\n\n\n\n", "\n\n");
}
if (desc.toString().contains("\n\n\n")) {
desc = desc.toString().replaceAll("\n\n\n", "\n");
}
return new Scaffold(
appBar: new AppBar(
title: new Text("Blogger"),
),
body: new Container(
child: new SingleChildScrollView(
child: new Column(
children: <Widget>[
new Padding(
padding:
const EdgeInsets.symmetric(vertical: 16.0, horizontal: 16.0),
child: new Text(
title,
style: new TextStyle(
fontSize: 22.0,
fontWeight: FontWeight.bold,
),
),
),
new Padding(
padding:
const EdgeInsets.symmetric(vertical: 16.0, horizontal: 16.0),
child: new Container(
width: 500.0,
height: 180.0,
decoration: new BoxDecoration(
shape: BoxShape.rectangle,
image: new DecorationImage(
fit: BoxFit.fill,
//check if the image is not null (length > 5) only then check imgUrl else display default img
image: new NetworkImage(image.toString().length > 10
? image.toString()
: "https://pbs.twimg.com/profile_images/916384996092448768/PF1TSFOE_400x400.jpg")),
),
),
),
new Padding(
padding:
const EdgeInsets.symmetric(vertical: 16.0, horizontal: 16.0),
child: new Text(
desc,
style: new TextStyle(
fontSize: 18.0,
),
),
),
],
))),
);
}
}
The problem log reads:
main.dart: Name non-constant identifiers using lowerCamelCase.
post_view.dart: This class (or a class which this class inherits from) is marked as '#immutable', but one or more of its instance fields are not final: PostView.desc, PostView.title, PostView.image
my editor marks class post on the post_view.dart as immutable.. how do i fix that.
final url =
"https://www.googleapis.com/blogger/v3/blogs/MY_BLOG_ID_HERE/posts/?key=API_KEY_HERE";
get your blog ID and put it into the required space and also get an API key for the blog from blogger
it should look like this
final url = "https://www.googleapis.com/blogger/v3/blogs/409370562475495748/posts/?key=AIzaSyA3_4OfkfLc10vy5Q2WeUhfirGUUY4J78F8bk";
also try to make these final PostView.desc, PostView.title, PostView.image and see if it works