dbpath 0.0.1 dbpath: ^0.0.1 copied to clipboard
get database path
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:dbpath/dbpath.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _dbPath = 'un set yet';
@override
void initState() {
super.initState();
initPlatformState();
}
Future<void> initPlatformState() async {
try {
_dbPath = await getDataBasePath();
} on PlatformException {
_dbPath = 'Failed to get path.';
}
if (!mounted) return;
setState(() {});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Text('Db-path is \n $_dbPath '),
),
),
);
}
}