Flutter passing variable into Widget - flutter

Hy guys i try two methods to pass variable inside widget in this case shared preferences.i can't pass _counterios or _counterdroid inside Widget build(BuildContext context) {... i try also localstorage wath's the best method and how??? thanks.. Code below
_loadCounter() async {
print("inizializzazione versione");
if (Platform.isAndroid) {
SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {
_counterdroid = (prefs.getString('counterdroid'));
print(_counterdroid + "lettura file");
});
}
else if (Platform.isIOS) {
SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {
_counterios = (prefs.getString('counterios'));
print(_counterios + "lettura file");
});
}
}
Widget build(BuildContext context) {
print(_counterdroid + "controllo tablet");
if (_counterdroid == "ipadpro") {
return new Scaffold(
appBar: new AppBar(
title: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
'assets/pngapp/logobianco.png',
fit: BoxFit.contain,
height: 20,
),
Container(
padding: const EdgeInsets.all(10.0),
child: Text('La Corte TakeAway'))
],
),
),
);
}
}

ok... code is...
import 'package:device_info/device_info.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:image_picker/image_picker.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:social_share_plugin/social_share_plugin.dart';
import 'package:takeaway/pages/informazioni.dart';
import 'package:takeaway/pages/popup.dart';
import 'package:takeaway/pages/popup_content.dart';
import 'package:map_launcher/map_launcher.dart';
import 'package:url_launcher/url_launcher.dart';
import 'dart:io';
import 'package:takeaway/pages/ncl.dart';
import 'dart:io' show Platform;
Map<String, dynamic> _readAndroidBuildData(AndroidDeviceInfo build) {
return <String, dynamic>{
'model': build.model,
};
}
Map<String, dynamic> _readIosDeviceInfo(IosDeviceInfo data) {
return <String, dynamic>{
'utsname.machine:': data.utsname.machine,
};
}
deviceInfo() async{
final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
Map<String, dynamic> deviceData = <String, dynamic>{};
try {
if (Platform.isAndroid) {
deviceData = _readAndroidBuildData(await deviceInfoPlugin.androidInfo);
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
final String droiddevice = androidInfo.model;
final prefsdroid = await SharedPreferences.getInstance();
prefsdroid.setString('counterdroid', droiddevice);
print(droiddevice);
} else if (Platform.isIOS) {
deviceData = _readIosDeviceInfo(await deviceInfoPlugin.iosInfo);
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
final String iosdevice = iosInfo.utsname.machine;
final prefsios = await SharedPreferences.getInstance();
prefsios.setString('counterios', iosdevice);
}
} on PlatformException {
deviceData = <String, dynamic>{
'Error:': 'Failed to get platform version.'
};
}
}
class CallsAndMessagesService {
void call(String number) => launch("tel:$number");
void sendSms(String number) => launch("sms:$number");
void sendEmail(String email) => launch("mailto:$email");
}
final String telephoneNumber = "+393287875572";
void main() {
runApp(new MyApp());
deviceInfo();
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'La Corte TakeAway',
theme: new ThemeData(
primarySwatch: Colors.red,
primaryColor: const Color(0xFFc42e2e),
accentColor: const Color(0xFFfafafa),
canvasColor: const Color(0xFFfafafa),
),
home: new MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key}) : super(key: key);
#override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
String _counterios = "";
String _counterdroid = "";
#override
void initState() {
super.initState();
_loadCounter();
}
#override
Widget textSection = new Container(
padding: const EdgeInsets.all(32.0),
child: new Text(
'Informazioni',
softWrap: true,
),
);
_loadCounter() async {
print("inizializzazione versione");
if (Platform.isAndroid) {
SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {
_counterdroid = (prefs.getString('counterdroid'));
print(_counterdroid+"lettura file");
});
}
else if (Platform.isIOS) {
SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {
_counterios = (prefs.getString('counterios'));
print(_counterios+"lettura file");
});
}
}
Widget build ( BuildContext context ) {
print(_counterdroid+"controllo tablet"); }
All another pages attach no matter... variable _counterios and _counterdroid have value of device only not pass into widget and i need there...

I am not sure weather this solution will work or not, but you can try this.
call _loadCounter in initState.
#override
void initState() {
super.initState();
}
if this does not work, can you please share code of _MyHomePageState extends State<MyHomePage> ?
Updated after code updated.
try like this, this is working for me.
_loadCounter() async {
print("inizializzazione versione");
if (Platform.isAndroid) {
SharedPreferences prefs = await SharedPreferences.getInstance();
_counterdroid = (prefs.getString('counterdroid'));
print(_counterios);
}
else if (Platform.isIOS) {
SharedPreferences prefs = await SharedPreferences.getInstance();
_counterios = (prefs.getString('counterios'));
print(_counterios);
}
}

Related

How to use MapShapeSource.network() with data from API Call (Post / Get from server)

I'm working with SfMaps syncfusion map and when I try to load geojson data from the local assets folder using the MapShapeSource.asset() property and everything works fine. But I'm having problems when I want to load geojson data as a result from api calling (GET / POST) using the http package flutter.
// Function to load data json from API
Future<void> loadGeojsonDataFromAPI() async {
setState(() => loading = true);
try {
final response = await http.post(
Uri.parse("some url"),
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: body);
if (response.statusCode >= 400) {
throw Exception('statusCode=${response.statusCode}');
}
setState(() {
loading = false;
data = jsonDecode(response.body);
});
} catch (e) {
setState(() => loading = false);
debugPrint("Error load data: $e");
return;
}
}
// Loadjson data from API in Map Shape Source.network() but not sure how to do it
dataSource = MapShapeSource.network(
'url',
shapeDataField: 'name',
);
I believe this can be solved using MapShapeSource.network(), but am still confused about how to use it.
any kind of help is very much appreciated
You can load the area shape JSON data from the web/network using the MapShapeSource.network() constructor available in the maps widget. We have shared the user guide documentation and sample below for your reference.
UG, https://help.syncfusion.com/flutter/maps/getting-started#from-network
Code snippet:
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_maps/maps.dart';
import 'package:http/http.dart' as http;
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Syncfusion Flutter Maps',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Syncfusion Flutter Maps'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
#override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
late MapShapeSource _dataSource;
late List<IndiaMap> _mapDetails;
Future<bool> _fetchNetworkJsonDetails() async {
if (_mapDetails.isNotEmpty) {
return true;
}
final http.Response response = await http
.get(Uri.tryParse('https://api.npoint.io/b127f79b6e9c883d0aba')!);
if (response.statusCode == 200) {
Map<String, dynamic> responseJson = json.decode(response.body);
List<dynamic> countriesCoordinates = responseJson['features'];
for (int i = 0; i < countriesCoordinates.length; i++) {
Map<String, dynamic> data = countriesCoordinates[i]['properties'];
IndiaMap mapDetail = IndiaMap.fromJsonMap(data);
_mapDetails.add(mapDetail);
}
_dataSource = MapShapeSource.network(
'https://api.npoint.io/b127f79b6e9c883d0aba',
shapeDataField: 'name',
dataCount: _mapDetails.length,
primaryValueMapper: (index) => _mapDetails[index].state,
);
return true;
} else {
throw Exception('Failed to load JSON');
}
}
#override
void initState() {
_mapDetails = [];
super.initState();
}
#override
void dispose() {
_mapDetails.clear();
super.dispose();
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(widget.title)),
body: FutureBuilder(
future: _fetchNetworkJsonDetails(),
builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
if (snapshot.hasData) {
return Padding(
padding: const EdgeInsets.all(15),
child: SfMaps(
layers: [
MapShapeLayer(
source: _dataSource,
color: const Color.fromRGBO(15, 59, 177, 0.5),
strokeColor: Colors.white,
strokeWidth: 0.5,
),
],
),
);
} else {
return const Center(child: CircularProgressIndicator());
}
}),
);
}
}
class IndiaMap {
late String state;
late String country;
IndiaMap(this.state, this.country);
IndiaMap.fromJsonMap(Map data) {
state = data['name'];
country = data['admin'];
}
}

My variable returns null on reassignment but prints the correct value inside the function

I am creating an app that logs in users and saves the user's data locally. The problem is it displays null when I try to display it on a text field or something but when I print said variable inside the function, it displays the value. I'm not sure what the problem is here.
Here's the code.
String? email = '';
void getEmail() async {
Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
SharedPreferences prefs = await _prefs;
setState(() {
email = prefs.getString('username');
});
}
So the 'email' variable is what keeps returning null, as you can see in the function, when the 'getEmail' is called, it should reassign the 'email' variable to the acquired value.
When I try to display it, it returns null or nothing at all, but when I call a print in the fuction, it returns the true value, what is the problem here?
Example
void getEmail() async{
...
email = prefs.getString('username');
print(email);
the result of this would be 'jafar'
but if I call it in a Text or whatnot in the build Method, For example
TextButton(onPressed: (){getEmail();
print(email);}, child: Text('click')),
Text('${email}')
everything returns null; what is the problem?
Complete Code
class Example extends StatefulWidget {
const Example({Key? key}) : super(key: key);
State createState() => _ExampleState();
}
class _ExampleState extends State {
#override
Widget build(BuildContext context) {
FirebaseAuth auth = FirebaseAuth.instance;
String? email = '';
void getEmail() async {
Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
SharedPreferences prefs = await _prefs;
setState(() {
email = prefs.getString('username');
});
}
return Scaffold(
body: SafeArea(child: Column(children: [
TextButton(onPressed: (){getEmail();
print(email);}, child: Text('click')),
Text('${email}')
],),)
);
}
}
Your getEmail is Future, so you should await for it, so change:
void getEmail() async {
Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
SharedPreferences prefs = await _prefs;
setState(() {
email = prefs.getString('username');
});
}
to
Future getEmail() async {
Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
SharedPreferences prefs = await _prefs;
setState(() {
email = prefs.getString('username');
});
}
then In your onPress:
onPressed: () {
await getEmail();
print(email);
},
But I recommended you use this approach:
first change your getEmail() to this:
Future<String?> getEmail() async {
Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
SharedPreferences prefs = await _prefs;
return prefs.getString('username');
}
then use it this way:
onPressed: () {
var _email = await getEmail();
if(_email!= null){
print(_email);
setState(() {
email = _email;
});
}
},
Full working example:
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
MyApp({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: EmailWidget(),
);
}
}
class EmailWidget extends StatefulWidget {
const EmailWidget({Key? key}) : super(key: key);
#override
State<EmailWidget> createState() => _EmailWidgetState();
}
class _EmailWidgetState extends State<EmailWidget> {
Future<String?> getEmail() async {
Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
SharedPreferences prefs = await _prefs;
return prefs.getString('username');
}
Future setEmail() async {
Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
SharedPreferences prefs = await _prefs;
return prefs.setString('username', 'amir');
}
String? email;
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.purple[50],
appBar: AppBar(
title: Text('fist'),
),
body: Column(
children: [
TextButton(
onPressed: () async {
var result = await getEmail();
if (result != null) {
setState(() {
email = result;
});
print(result);
} else {
await setEmail();
}
},
child: Text('click'),
),
Text('${email}')
],
),
);
}
}
Result:

Hive boxes are deleted when app closes or restart

The problem is that Hive is acting unexpectedly, and when the app closes or I restart it all, the data in the box is cleared.
main.dart:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(statusBarColor: Colors.transparent));
await Firebase.initializeApp();
await Hive.initFlutter();
Hive.registerAdapter(CredentialsModelAdapter());
Hive.registerAdapter(DoctorModelAdapter());
Hive.registerAdapter(DuserModelAdapter());
Hive.registerAdapter(DoctorAppointmentsAdapter());
Hive.registerAdapter(AppointmentStatusesAdapter());
Hive.registerAdapter(AccountTypeAdapter());
Hive.registerAdapter(UserAdapter());
await Hive.openBox<CredentialsModel>("cred");
await Hive.openBox<DuserModel>("doctor");
runApp(ProviderScope(child: MyApp()));
}
class MyApp extends StatelessWidget {
MyApp({Key? key}) : super(key: key);
final _appRouter = app_router.AppRouter();
#override
Widget build(BuildContext context) {
return MaterialApp.router(
title: "x",
debugShowCheckedModeBanner: false,
routerDelegate: _appRouter.delegate(),
routeInformationParser: _appRouter.defaultRouteParser(),
);
}
}
Here is where I fetch the data from the api and store it in box:
#override
Future<Either<ApiFailures, dynamic>> signInWithEmailAndPassword(
{required String email, required String password}) async {
late Box<CredentialsModel> credentials;
var result;
try {
final response = await http.get(Uri.parse(
"xxxxxxxx"));
if (response.statusCode == 200) {
result = await json.decode(response.body);
if (result["AZSVR"] == "FAILED") {
return const Left(ApiFailures.authFailed());
} else {
var content = CredentialsModel.fromJson(result);
credentials = Hive.box("cred");
credentials.put('cred', content);
return right(result["api_token"]);
}
}
} on SocketException catch (e) {
return const Left(ApiFailures.noConnection());
} on HttpException {
return const Left(ApiFailures.notfound());
} catch (_) {
return const Left(ApiFailures.notfound());
}
return Right(result["api_token"]);
}
Where I call the box:
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:vwelfare/application/provider/doctor.repository.provider.dart';
import 'package:vwelfare/domain/models/doctor/duser.dart';
import '../../domain/models/credentials/credentials.dart';
class MyWidget extends HookConsumerWidget {
const MyWidget({super.key});
#override
Widget build(BuildContext context, WidgetRef ref) {
final Box<CredentialsModel> credBox = Hive.box("cred");
final Box<DuserModel> doctorBox = Hive.box("doctor");
final controller = useTextEditingController();
final uid = useState(0);
final cred = useState(const CredentialsModel());
return Scaffold(
body: ValueListenableBuilder(
valueListenable: credBox.listenable(),
builder: (context, Box<CredentialsModel> box, _) {
final cred = box.get("cred");
print(cred!.api_token);
final doctor = ref.watch(getDoctor(cred.api_token!));
return doctor.when(
data: (data) => data.fold(
(l) => ValueListenableBuilder(
valueListenable: doctorBox.listenable(),
builder: (context, Box<DuserModel> box, _) {
final model = box.get("doctor");
final doctor = model!.User;
if (doctor != null) {
return Center(
child: Text("${doctor.address}"),
);
} else {
return const Center(
child: Text("CONTACT US"),
);
}
}),
(r) => Center(child: Text("${r.User!.name}"))),
loading: () => const CircularProgressIndicator(),
error: (error, stackTrace) {
print(error);
return Center(
child: Text("$error hello"),
);
});
},
),
);
}
}
I don't know if I am doing something wrong but I followed the docs as they say:
1- registered the adapter
2- opened the box
3- called it in a widget
What am I doing wrong?

how to load file from online in flutter

I'm able to load file from my code. But the problem is, how to load the file from online server which is from this link- https://freevpn.gg/c/59.139.187.41/udp
My current code is-
var contennt=await rootBundle.loadString('assets/vpnconfig.ovpn');
You could use flutter cache manager to download the file and then read it. https://pub.dev/packages/flutter_cache_manager
String url = 'your_link';
final file = await DefaultCacheManager().getSingleFile(url);
var content = await file.readAsString();
dependencies:
flutter_filereader: ^2.2.0
import 'dart:convert';
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_filereader_example/file.dart';
import 'package:path_provider/path_provider.dart';
import 'package:permission_handler/permission_handler.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
#override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
#override
void initState() {
Permission.storage.request();
super.initState();
}
#override
Widget build(BuildContext context) {
return MaterialApp(
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
#override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
String taskId;
Map<String, String> iosfiles = {
"docx": "assets/files/docx.docx", // IOS test
"doc": "assets/files/doc.doc", // IOS test
"xlsx": "assets/files/xlsx.xlsx", // IOS test
"xls": "assets/files/xls.xls", // IOS test
"pptx": "assets/files/pptx.pptx", // IOS test
"ppt": "assets/files/ppt.ppt", // IOS test
"pdf": "assets/files/pdf.pdf", // IOS test
"txt": "assets/files/txt.txt", // IOS test
"jpg": "assets/files/jpg.jpg", //
"jpeg": "assets/files/jpeg1.jpeg", //
"png": "assets/files/png.png", //
};
Map<String, String> androidfiles = {
"docx": "assets/files/docx.docx", // android test
"doc": "assets/files/doc.doc", // android test
"xlsx": "assets/files/xlsx.xlsx", // android test
"xls": "assets/files/xls.xls", // android test
"pptx": "assets/files/pptx.pptx", // android test
"ppt": "assets/files/ppt.ppt", // android test
"pdf": "assets/files/pdf.pdf", // android test
"txt": "assets/files/txt.txt" // android test
};
Map<String, String> files;
#override
void initState() {
if (Platform.isAndroid) {
files = androidfiles;
} else {
files = iosfiles;
}
super.initState();
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('File Reader'),
),
body: ListView.builder(
itemBuilder: (ctx, index) {
return item(files.keys.elementAt(index), files.values.elementAt(index));
},
itemCount: files.length,
),
);
}
item(String type, String path) {
return GestureDetector(
onTap: () {
onTap(type, path);
},
child: Container(
alignment: Alignment.center,
height: 50,
margin: EdgeInsetsDirectional.only(bottom: 5),
color: Colors.blue,
child: Center(
child: Text(
type,
style: TextStyle(color: Colors.white, fontSize: 20),
),
),
),
);
}
onTap(String type, String assetPath) async {
String localPath = await fileLocalName(type, assetPath);
if (!await File(localPath).exists()) {
if (!await asset2Local(type, assetPath)) {
return;
}
}
Navigator.of(context).push(MaterialPageRoute(builder: (ctx) {
return FileReaderPage(
filePath: localPath,
);
}));
}
fileLocalName(String type, String assetPath) async {
String dic = await _localSavedDir() + "/filereader/files/";
return dic + base64.encode(utf8.encode(assetPath)) + "." + type;
}
fileExists(String type, String assetPath) async {
String fileName = await fileLocalName(type, assetPath);
if (await File(fileName).exists()) {
return true;
}
return false;
}
asset2Local(String type, String assetPath) async {
if (Platform.isAndroid) {
if (!await Permission.storage.isGranted) {
debugPrint("没有存储权限");
return false;
}
}
File file = File(await fileLocalName(type, assetPath));
if (await fileExists(type, assetPath)) {
await file.delete();
}
await file.create(recursive: true);
//await file.create();
debugPrint("文件路径->" + file.path);
ByteData bd = await rootBundle.load(assetPath);
await file.writeAsBytes(bd.buffer.asUint8List(), flush: true);
return true;
}
_localSavedDir() async {
Directory dic;
if (defaultTargetPlatform == TargetPlatform.android) {
dic = await getExternalStorageDirectory();
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
dic = await getApplicationDocumentsDirectory();
}
return dic.path;
}
}

How to Delete cache and app dir in flutter

In my flutter app, I store some images in cache directory and some files in application document directory, now I want to add possibility to my users to delete the cache dir and app dir,
How can I achieve this?
You need path_provider package
Then try this code:
Future<void> _deleteCacheDir() async {
final cacheDir = await getTemporaryDirectory();
if (cacheDir.existsSync()) {
cacheDir.deleteSync(recursive: true);
}
}
Future<void> _deleteAppDir() async {
final appDir = await getApplicationSupportDirectory();
if(appDir.existsSync()){
appDir.deleteSync(recursive: true);
}
}
This code may help you :
import 'dart:async';
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
void main() {
runApp(
MaterialApp(
title: 'Reading and Writing Files',
home: FlutterDemo(storage: CounterStorage()),
),
);
}
class CounterStorage {
Future<String> get _localPath async {
final directory = await getApplicationDocumentsDirectory();
return directory.path;
}
Future<File> get _localFile async {
final path = await _localPath;
return File('$path/counter.txt');
}
Future<int> readCounter() async {
try {
final file = await _localFile;
// Read the file
String contents = await file.readAsString();
return int.parse(contents);
} catch (e) {
// If encountering an error, return 0
return 0;
}
}
Future<File> writeCounter(int counter) async {
final file = await _localFile;
// Write the file
return file.writeAsString('$counter');
}
}
class FlutterDemo extends StatefulWidget {
final CounterStorage storage;
FlutterDemo({Key key, #required this.storage}) : super(key: key);
#override
_FlutterDemoState createState() => _FlutterDemoState();
}
class _FlutterDemoState extends State<FlutterDemo> {
int _counter;
#override
void initState() {
super.initState();
widget.storage.readCounter().then((int value) {
setState(() {
_counter = value;
});
});
}
Future<File> _incrementCounter() {
setState(() {
_counter++;
});
// Write the variable as a string to the file.
return widget.storage.writeCounter(_counter);
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Reading and Writing Files')),
body: Center(
child: Text(
'Button tapped $_counter time${_counter == 1 ? '' : 's'}.',
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}
Also, you can find very helpful document here:
https://github.com/flutter/samples/blob/master/INDEX.md