Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why i am getting null error #101

Open
nischal690 opened this issue Feb 2, 2023 · 0 comments
Open

why i am getting null error #101

nischal690 opened this issue Feb 2, 2023 · 0 comments

Comments

@nischal690
Copy link

ist<Map<String, dynamic>> data1 = [];

class Mentions extends StatefulWidget {
const Mentions({
Key? key,
this.width,
this.height,
}) : super(key: key);

final double? width;
final double? height;

@OverRide
_MentionsState createState() => _MentionsState();
}

class _MentionsState extends State {
GlobalKey key = GlobalKey();
Future apicall() async {
http.Response response;
var url = "https://7J8Y54OD18-dsn.algolia.net/1/indexes/users";
response = await http.get(Uri.parse(url), headers: {
'X-Algolia-API-Key': '841e31106f80e21b89b0d2b9ec7cd561',
'X-Algolia-Application-Id': '7J8Y54OD18'
});
if (response.statusCode == 200) {
setState(() {
jsonMap = json.decode(response.body);
(jsonMap['hits'] as List).forEach((x) => {data.add(Map.from(x))});
for (int i = 0; i < data.length; i++) {
data1
.add({'id': data[i]["objectID"], 'display': data[i]["username"]});
}
});
} else {
string = "fsfwe";
}
}

void generatedata() {}

@OverRide
void initState() {
apicall();

super.initState();

}

@OverRide
Widget build(BuildContext context) {
return Portal(
child: Scaffold(
appBar: AppBar(
title: Text("flutter mention"),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(data1.length.toString()),
Container(
child: FlutterMentions(
key: key,
suggestionPosition: SuggestionPosition.Top,
maxLines: 5,
minLines: 3,
decoration: InputDecoration(hintText: 'hello'),
mentions: [
Mention(
trigger: '@',
style: TextStyle(
color: Colors.amber,
),
data: data1,
matchAll: false,
suggestionBuilder: (data1) {
return Container(
padding: EdgeInsets.all(10.0),
child: Row(
children: [
SizedBox(
width: 20.0,
),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant