nookipedia_flutter 0.2.6 nookipedia_flutter: ^0.2.6 copied to clipboard
Flutter wrapper for Nookipedia API. The Nookipedia API provides endpoints for retrieving Animal Crossing data pulled from the Nookipedia wiki.
import 'package:flutter/material.dart';
import 'package:nookipedia_flutter/nookipedia_flutter.dart';
void main() {
NookipediaClient.initialize(
apiKey: "API-KEY-HERE",
);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(title),
),
body: FutureBuilder(
future: NookipediaClient.instance.clothing
.fetchNames(category: ClothingCategory.dressUp),
builder: ((context, AsyncSnapshot<List<String>> snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
}
if (snapshot.hasError) {
return Text(snapshot.error?.toString() ?? "Something went wrong");
}
var data = snapshot.data!;
return ListView.builder(
itemCount: data.length,
itemBuilder: ((context, index) {
return ListTile(title: Text(data[index]));
}),
);
}),
),
);
}
}