x_path_provider 0.0.1
x_path_provider: ^0.0.1 copied to clipboard
Get application directory path
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:x_path_provider/x_path_provider.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final _xPathProvider = XPathProvider();
var _path = "-";
@override
void initState() {
super.initState();
}
void _getAppDirectoryPath() async {
_path = await _xPathProvider.getAppDirectory() ?? "-";
setState(() {});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('X Path Provider'),
),
body: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text(
"PATH:",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
),
),
Text(
_path,
textAlign: TextAlign.center,
),
],
),
),
),
bottomNavigationBar: SizedBox(
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.green,
),
onPressed: _getAppDirectoryPath,
child: const Text(
"Get Path",
style: TextStyle(
color: Colors.white,
),
),
),
),
),
);
}
}