I'm using api_cache_manager: ^1.0.2
How to get all cache?
Because i'm need all cache and showing in list
please someone help me
API Cache Manager is a Utility package built with Flutter SDK and
SQLite Package. This package will help to make your Rest API store in
the local db for offline access.
import
import 'package:api_cache_manager/api_cache_manager.dart';
import 'package:api_cache_manager/models/cache_db_model.dart';
import 'package:api_cache_manager/utils/cache_db_helper.dart';
This will provide all cached data
List<Map<String,dynamic>> list = await APICacheDBHelper.query(APICacheDBModel.table);
OR
List<Map<String,dynamic>> list =await APICacheDBHelper.rawQuery("select * from ${APICacheDBModel.table}");
This will create dummy data and save in cache and return all data from the cache
Future<List<Map<String, dynamic>>> fetchapiCach() async {
// await APICacheDBHelper.deleteAll(APICacheDBModel.table);
var lists = new List<int>.generate(10, (i) => i + 1);
lists.forEach((element) async {
var cacheData2 = await APICacheManager().addCacheData(new APICacheDBModel(
syncData: '{"name":"lava$element"}',
key: "$element",
));
});
List<Map<String,dynamic>> list = await APICacheDBHelper.query(APICacheDBModel.table);
// await APICacheDBHelper.rawQuery("select * from ${APICacheDBModel.table}");
return list;
}
SampleCode
import 'package:api_cache_manager/api_cache_manager.dart';
import 'package:api_cache_manager/models/cache_db_model.dart';
import 'package:api_cache_manager/utils/cache_db_helper.dart';
import 'package:flutter/material.dart';
void main() {
// fetchapiCach();
runApp(const MyApp());
}
Future<List<Map<String, dynamic>>> fetchapiCach() async {
// await APICacheDBHelper.deleteAll(APICacheDBModel.table);
var lists = new List<int>.generate(10, (i) => i + 1);
lists.forEach((element) async {
var cacheData2 = await APICacheManager().addCacheData(new APICacheDBModel(
syncData: '{"name":"lava$element"}',
key: "$element",
));
});
List<Map<String,dynamic>> list = await APICacheDBHelper.query(APICacheDBModel.table);
// await APICacheDBHelper.rawQuery("select * from ${APICacheDBModel.table}");
// print(list);
list.forEach((element) {
print(element);
});
return list;
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
static const String _title = 'Flutter Code Sample';
#override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: const Center(
child: MyStatelessWidget(),
),
),
);
}
}
class MyStatelessWidget extends StatelessWidget {
const MyStatelessWidget({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return FutureBuilder(
future: fetchapiCach(),
builder: (BuildContext context,
AsyncSnapshot<List<Map<String, dynamic>>> snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(
child: Container(
height: 10, width: 10, child: CircularProgressIndicator()));
} else {
print(snapshot.data);
return ListView.builder(
itemCount: snapshot.data!.length,
itemBuilder: (context, index) {
return ListTile(
title: Row(
children: [
Text(
"${snapshot.data![index]["key"]}",
style: TextStyle(fontSize: 25),
),
Expanded(
child: Align(
alignment: Alignment.topRight,
child: Text("${snapshot.data![index]["syncData"]}"),
)),
],
),
subtitle: Row(
children: [
Expanded(
child: Align(
alignment: Alignment.topRight,
child:
Text("${snapshot.data![index]["syncTime"]}")),
)
],
),
leading: CircleAvatar(),
);
});
}
;
});
}
}
Related
I want to fetch data from the Database and want to show all the records of some columns by using listView.builder in flutter code .How I can do this ??
I want to fetch data from the Database and want to show all the records of some columns by using listView.builder in flutter code .How I can do this ??
static Future<List> getData() async {
final db = await SQLHelper.db();
var data= (await db.rawQuery('select column1,column2,column3,column4 From table'));
return data.toList();
}
import 'package:flutter/material.dart';
import 'package:test_02/dbHelper.dart';
class showOutlets extends StatefulWidget {
#override
State<showOutlets> createState() => showOutletsState();
}
class showOutletsState extends State<showOutlets> {
num age = -1;
String birthDate = "";
var data ;
List<dynamic> list = [SQLHelper.getOutletsData()];
bool _isLoading = false;
void _showFullRecord() async {
data = await SQLHelper.getOutletsData( );
setState(() {
data =data;
_isLoading = false;
});
}
static var boldStyle= const TextStyle(
fontWeight: FontWeight.bold,
);
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('User Data' ),
),
body: _isLoading? const Center(
child: CircularProgressIndicator(),
)
: ListView.builder(
itemCount: list.length,
itemBuilder: (context, index ) => Card(
color: Colors.orangeAccent,
// color: Colors.orange[200],
margin: const EdgeInsets.all(15),
child: Column(
children: [
const Text("USER INFORMATION ",
style: TextStyle(
fontSize: 20.0,
),),
// Text('NAME:${data}'), // how can I show the data on the screen
],
),
)
)
);
}
Create state variable future,
late final future = YourDBClass.getData();
Now use FutureBuilder
FutureBuilder(
future: future,
builder: (context, snapshot) {
if (snapshot.hasData) {
return ListView.builder(...loaded data on snapshot.dat..a);
}
if (snapshot.hasError) return Text("error");
return CircularProgressIndicator();
},
),
More about FutureBuilder
I didn't understand what you really want. but here is an example of how you can get data from database and show them on the screen.
import 'package:flutter/material.dart';
void main() {
runApp(showOutlets());
}
class showOutlets extends StatefulWidget {
#override
State<showOutlets> createState() => showOutletsState();
}
class showOutletsState extends State<showOutlets> {
num age = -1;
String birthDate = "";
bool _isLoading = true;
List<dynamic> dataList;
_getData() async {
dataList = await getDataFromDatabase(); // get data here
_isLoading = false;
}
#override
void initState() {
_getData();
super.initState();
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('User Data'),
),
body: _isLoading
? const Center(
child: CircularProgressIndicator(),
)
: ListView.builder(
itemCount: dataList.length,
itemBuilder: (context, index) => Card(
// Design your card.
color: Colors.orangeAccent,
margin: const EdgeInsets.all(15),
child: Column(
children: [
const Text(
"USER INFORMATION ",
style: TextStyle(
fontSize: 20.0,
),
),
],
),
),
),
);
}
}
I have been trying to build a News App that fetches data from the newsapi.org service and just when I am about to call the data inside the main method I am getting this error saying that my class 'NewsModel' isn't of the type 'Widget' as required by the closure's context. I have no idea what that means but here is my code for the app split into 2 files.
import 'package:flutter/material.dart';
import 'models/news_model.dart';
import 'news_service.dart';
import 'package:assgn_digia_tech/models/news_model.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
#override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
bool _loading = true;
var newsList;
List<NewsModel> articles = [];
void getNews() async {
newsService apiNews = newsService();
await apiNews.getNews();
articles = apiNews.apiNews;
setState(() {
_loading = false;
});
}
#override
void initState() {
super.initState();
getNews();
}
#override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text(
'News API',
style: TextStyle(
color: Colors.black,
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
backgroundColor: Colors.cyan[50],
// ignore: prefer_const_literals_to_create_immutables
actions: [
Padding(
padding: const EdgeInsets.only(right: 12.0),
child: IconButton(
icon: Icon(Icons.search, color: Colors.black, size: 26),
onPressed: () {},
),
),
],
),
body: SafeArea(
child: _loading
? Center(
child: CircularProgressIndicator(),
)
: SingleChildScrollView(
child: Container(
child: Column(
children: [
Container(
child: ListView.builder(
itemCount: articles.length,
shrinkWrap: true,
itemBuilder: (context, index) {
return NewsModel(
title: articles[index].title,
description: articles[index].description,
author: articles[index].author,
content: articles[index].content,
urlToImage: articles[index].urlToImage,
);
},
),
),
],
),
),
),
),
),
);
}
}
import 'dart:convert';
import 'package:assgn_digia_tech/models/news_model.dart';
import 'package:http/http.dart' as http;
class newsService {
List<NewsModel> apiNews = [];
Future<void> getNews() async {
String apiUrl =
'https://newsapi.org/v2/top-headlines?country=in&apiKey=4e3474bb91ec49eda31b75e2daf6da3c';
var response = await http.get(Uri.parse(apiUrl));
var jsonData = jsonDecode(response.body);
if (response.statusCode == 200) {
jsonData['articles'].forEach((element) {
if (element['urlToImage'] != null && element['description'] != null) {
NewsModel article = NewsModel(
title: element['title'],
author: element['author'],
description: element['description'],
urlToImage: element['urlToImage'],
content: element["content"],
);
apiNews.add(article);
}
});
}
}
}
itemBuilder: (context, index) {
return NewsModel(
You are supposed to return a Widget from the builder, because the purpose is to build a UI. Do you have a custom "NewsWidget" here, or do you want to build it from scratch? Maybe start by returning Text(articles[index].title) and then building it up from there to include all the other parts of your NewsModel.
I want to fetch data from API and use the data in tabbar and tabview.
I want to create (Ayurved app), I have a list of subcategory in the api, I followed this documentation, so I need to add api's subcategory to my TabBar.
So How can I do that? I don't understand how this will happen.
This is my Tab Page.
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:hospital/customApiVariable.dart';
import 'package:http/http.dart' as http;
class TabPage extends StatefulWidget {
final medicineCatUniqId;
const TabPage({Key key, this.medicineCatUniqId}) : super(key: key);
// const TabPage({Key key}) : super(key: key);
#override
_TabPageState createState() => _TabPageState();
}
class _TabPageState extends State<TabPage> {
var response;
var medicineSubCategoryApi;
#override
void initState() {
// TODO: implement initState
//
super.initState();
// for loading
fetchData(widget.medicineCatUniqId);
}
fetchData(var medicineCatUniqId) async {
a2rTokenKey=carpet1234');
var api = Uri.parse(
'$baseUrl/productSubCatApi.php?a2rTokenKey=$a2rTokenKey&pcat=$medicineCatUniqId');
response = await http.get(
api,
);
print("medicineCatApiLnk " + api.toString());
print("medicineCat" + response.body);
medicineSubCategoryApi = jsonDecode(response.body);
print("medicineCatString" + medicineSubCategoryApi.toString());
setState(() {});
}
#override
Widget build(BuildContext context) {
return MaterialApp(
home: DefaultTabController(
length: medicineSubCategoryApi.length,
child: Scaffold(
appBar: AppBar(
title: const Text('Tabbed AppBar'),
bottom: TabBar(
isScrollable: true,
tabs: medicineSubCategoryApi.map((choice) {
return Tab(
text: choice.psubCatName,
icon: Icon(choice),
);
}).toList(),
),
),
body: TabBarView(
children: medicineSubCategoryApi.map<Widget>((choice) {
return Padding(
padding: const EdgeInsets.all(20.0),
child: ChoicePage(
choice: choice,
),
);
}).toList(),
),
),
),
);
}
}
class ChoicePage extends StatelessWidget {
const ChoicePage({Key key, this.choice}) : super(key: key);
final choice;
#override
Widget build(BuildContext context) {
final TextStyle textStyle = Theme.of(context).textTheme.display1;
return Card(
color: Colors.white,
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
// Icon(
// choice,
// size: 150.0,
// color: textStyle.color,
// ),
Text(
choice.psubCatName,
style: textStyle,
),
],
),
),
);
}
}
This is my Api Data.
[{"psubCatUniq":"60c464556cd04","psubCatName":"TURMERIC CAPSULES","psubCatDescrition":"TURMERIC CAPSULES","psubCatImg":"http:\/\/a2rstore.com\/inventory\/images\/subCategory-bb.jpg","psubCatIcon":"","psubCatDate":"","psubCatlink":"list.php?subName=TURMERIC CAPSULES&sub=60c464556cd04","pcatUniq":"60c462501a664","pcatName":"Herbal Tablets"},{"psubCatUniq":"60c464360de3f","psubCatName":"PAIN CALM TABLET","psubCatDescrition":"PAIN CALM TABLET","psubCatImg":"http:\/\/a2rstore.com\/inventory\/images\/subCategory-aa.jpg","psubCatIcon":"","psubCatDate":"","psubCatlink":"list.php?subName=PAIN CALM TABLET&sub=60c464360de3f","pcatUniq":"60c462501a664","pcatName":"Herbal Tablets"}]
You can use a FutureBuilder widget to make the API call then access the data you require from the response data to create the Tabs.
A Simple Example
#override
Widget build(BuildContext context) {
return MaterialApp(
home: FutureBuilder(
future: fetchData(widget.medicineCatUniqId),
builder: (context, snapshot) {
if (snapshot.hasData) {
// API data will be stored as snapshot.data
return DefaultTabController(
// Your Widget UI here ( Copy & paste ) what you have above
);
} else if (snapshot.hasError) {
return Text('Error');
} else {
return Text('Loading');
}
}
),
);
}
You will also need to update fetchData() to return the value to FutureBuilder:
fetchData(var medicineCatUniqId) async {
var api = Uri.parse(
'$baseUrl/productSubCatApi.php?a2rTokenKey=$a2rTokenKey&pcat=$medicineCatUniqId');
response = await http.get(
api,
);
print("medicineCatApiLnk " + api.toString());
print("medicineCat" + response.body);
medicineSubCategoryApi = jsonDecode(response.body);
print("medicineCatString" + medicineSubCategoryApi.toString());
//setState(() {});
return medicineSubCategoryApi;
}
I am new to flutter and I got a situation where I need to reuse data from an asynchronous call, after researching a bit I found out about the nice FutureBuilder Widget and I am using, it works great but I have this situation where I need the data from the future call in two different widgets like the code fragment below which causes the async call to be executed twice and I would like to avoid it.
How to avoid the two calls? What's the recommended approach in this case? I couldn't find a reference/recommendation for this situation.
body: Column(
children: [
Container(
height: 200,
child: FutureBuilder(
future: weight.findAll(),
builder: (context, snapshot) {
if(!snapshot.hasData) {
return Center(child: CircularProgressIndicator());
} else {
this._seriesList = _plotWeightSeries(snapshot.data);
return _lineChart();
}
},
),
),
Expanded(
child: FutureBuilder(
future: weight.findAll(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Center(child: CircularProgressIndicator());
} else {
return _getSlidableListView(snapshot.data);
}
},
),
),
],
),
Here is an example using Flutter Hooks and Riverpod.
I define a FutureProvider to fetch the weights from the server:
final weightsProvider = FutureProvider((ref) => findAllWeights());
Future<List<double>> findAllWeights() async {
print('FETCHING DATA'); // This gets run only once
final random = Random();
await Future.delayed(Duration(seconds: 2));
return List.generate(20, (index) => 50 + 20 * random.nextDouble());
}
And then, I use the result in both my WidgetOne to calculate the SUM and my WidgetTwo to calculate the AVERAGE. As you will see, the FETCHING DATA only happens once.
Full source code
import 'dart:math' show Random;
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/all.dart';
void main() {
runApp(
ProviderScope(
child: MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
home: HomePage(),
),
),
);
}
final weightsProvider = FutureProvider((ref) => findAllWeights());
Future<List<double>> findAllWeights() async {
print('FETCHING DATA'); // This gets run only once
final random = Random();
await Future.delayed(Duration(seconds: 2));
return List.generate(20, (index) => 50 + 20 * random.nextDouble());
}
class HomePage extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
WidgetOne(),
WidgetTwo(),
],
),
);
}
}
class WidgetOne extends HookWidget {
#override
Widget build(BuildContext context) {
final weights = useProvider(weightsProvider);
return Card(
child: Column(
children: [
Text('SUM of the weights'),
weights.when(
data: (data) => Text(data.reduce((a, b) => a + b).toString()),
loading: () => CircularProgressIndicator(),
error: (_, __) => Text('Something bad happended'),
),
],
),
);
}
}
class WidgetTwo extends HookWidget {
#override
Widget build(BuildContext context) {
final weights = useProvider(weightsProvider);
return Card(
child: Column(
children: [
Text('AVERAGE of the weights'),
weights.when(
data: (data) =>
Text((data.reduce((a, b) => a + b) / data.length).toString()),
loading: () => CircularProgressIndicator(),
error: (_, __) => Text('Something bad happended'),
),
],
),
);
}
}
I used Riverpod in this examples but there are other State Management, check here for a curated List of state management approaches.
Update for Riverpod 1.0
import 'dart:math' show Random;
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
void main() {
runApp(
const ProviderScope(
child: MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
home: HomePage(),
),
),
);
}
final weightsProvider = FutureProvider((ref) => findAllWeights());
Future<List<double>> findAllWeights() async {
print('FETCHING DATA'); // This gets run only once
final random = Random();
await Future.delayed(const Duration(seconds: 2));
return List.generate(20, (index) => 50 + 20 * random.nextDouble());
}
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: const [
WidgetOne(),
WidgetTwo(),
],
),
);
}
}
class WidgetOne extends HookConsumerWidget {
const WidgetOne({Key? key}) : super(key: key);
#override
Widget build(BuildContext context, WidgetRef ref) {
final weights = ref.watch(weightsProvider);
return Card(
child: Column(
children: [
const Text('SUM of the weights'),
weights.when(
data: (data) => Text(data.reduce((a, b) => a + b).toString()),
loading: () => const CircularProgressIndicator(),
error: (_, __) => const Text('Something bad happended'),
),
],
),
);
}
}
class WidgetTwo extends HookConsumerWidget {
const WidgetTwo({Key? key}) : super(key: key);
#override
Widget build(BuildContext context, WidgetRef ref) {
final weights = ref.watch(weightsProvider);
return Card(
child: Column(
children: [
const Text('AVERAGE of the weights'),
weights.when(
data: (data) =>
Text((data.reduce((a, b) => a + b) / data.length).toString()),
loading: () => const CircularProgressIndicator(),
error: (_, __) => const Text('Something bad happended'),
),
],
),
);
}
}
I was using shared_preferences plugin in my Flutter application, I set my data when I click the button, but I try to get my data is not coming.
I set my data here and when I print it, I can see the output on my console.
shows.forEach((element) {
showCode=element.showName;
show.setString('showName', showCode);
});
I want to get my data here, above the override method. But when I print here, I just see 1 item, but I need to print 2 items.
String showCode;
Future<String> getCode() async{
final codeValue = await SharedPreferences.getInstance();
setState((){
showyCode =codeValue.getString('showName');
});
print('here $showCode');
return showCode;
}
But I cannot call this future in my function, even if I have 2 data to come but I just see 1 item. I tried to include it in Listview then it fills an entire list with 1 item. Anyone have an idea where I'm doing wrong?
_showProgramData
? Container(
height: MediaQuery.of(context).size.height/2,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
children: [
IconButton(icon:Icon(Icons.close) , onPressed:() {Navigator.pushNamed(context, SecondScreen.routeName);}),
Text('Please Select Show',style: TextStyle(fontWeight:FontWeight.bold,fontSize: 24),),
],
),
Text(showCode),
],
),
),
)
You can copy paste run full code below
Step 1: You need to use setStringList and getStringList
Step 2: getCode() return Future<List<String>>
Step 3: In forEach use showCodeList.add(element.showName);
code snippet
void _setData() async {
shows.forEach((element) {
showCodeList.add(element.showName);
});
final codeValue = await SharedPreferences.getInstance();
await codeValue.setStringList('showName', showCodeList);
setState(() {});
}
Future<List<String>> getCode() async {
final codeValue = await SharedPreferences.getInstance();
showCodeList = await codeValue.getStringList('showName');
if (showCodeList == null) {
showCodeList = [];
}
print('here ${showCodeList.toString()}');
return showCodeList;
}
...
FutureBuilder(
future: _future,
builder: (context, AsyncSnapshot<List<String>> snapshot) {
...
} else {
return ListView.builder(
itemCount: snapshot.data.length,
itemBuilder: (context, index) {
return Card(
elevation: 6.0,
child: Padding(
padding: const EdgeInsets.only(
top: 6.0, bottom: 6.0, left: 8.0, right: 8.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(snapshot.data[index]),
working demo
full code
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
void main() async{
WidgetsFlutterBinding.ensureInitialized();
final codeValue = await SharedPreferences.getInstance();
await codeValue.setStringList('showName', []);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
#override
_MyHomePageState createState() => _MyHomePageState();
}
class Show {
String showName;
Show({this.showName});
}
class _MyHomePageState extends State<MyHomePage> {
Future<List<String>> _future;
List<Show> shows = [Show(showName: "a"), Show(showName: "b")];
String showCode;
List<String> showCodeList = [];
void _setData() async {
shows.forEach((element) {
showCodeList.add(element.showName);
});
final codeValue = await SharedPreferences.getInstance();
await codeValue.setStringList('showName', showCodeList);
setState(() {});
}
Future<List<String>> getCode() async {
final codeValue = await SharedPreferences.getInstance();
showCodeList = await codeValue.getStringList('showName');
if (showCodeList == null) {
showCodeList = [];
}
print('here ${showCodeList.toString()}');
return showCodeList;
}
#override
void initState() {
_future = getCode();
super.initState();
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: FutureBuilder(
future: _future,
builder: (context, AsyncSnapshot<List<String>> snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.none:
return Text('none');
case ConnectionState.waiting:
return Center(child: CircularProgressIndicator());
case ConnectionState.active:
return Text('');
case ConnectionState.done:
if (snapshot.hasError) {
return Text(
'${snapshot.error}',
style: TextStyle(color: Colors.red),
);
} else {
return ListView.builder(
itemCount: snapshot.data.length,
itemBuilder: (context, index) {
return Card(
elevation: 6.0,
child: Padding(
padding: const EdgeInsets.only(
top: 6.0, bottom: 6.0, left: 8.0, right: 8.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(snapshot.data[index]),
],
),
));
});
}
}
}),
floatingActionButton: FloatingActionButton(
onPressed: _setData,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}