devappsdk2 1.0.2 devappsdk2: ^1.0.2 copied to clipboard
A Flutter package support share data between multiple application via content provider.
import 'package:devappsdk2/devappsdk.dart';
import 'package:flutter/material.dart';
import 'package:kdialogs/kdialogs.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Example',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const Home(),
);
}
}
class Home extends StatefulWidget {
const Home({super.key});
@override
State<Home> createState() => _HomeState();
}
class _HomeState extends State<Home> {
String input = "preferencias.server";
String text = "";
@override
void initState() {
void read() async {
final value = await DevAppManager().readValue("preferencias.server");
print(value);
final value2 = await DevAppManager().readValue("preferencias.server");
print(value2);
}
WidgetsBinding.instance.addPostFrameCallback((_) async {
read.call();
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
width: 200,
child: TextFormField(
initialValue: input,
decoration: const InputDecoration(label: Text("Name")),
onChanged: (value) => input = value,
),
),
IconButton(
onPressed: () async {
try {
final value = await DevAppManager().readValue("preferencias.server");
print(value);
final value2 = await DevAppManager().readValue("preferencias.server");
print(value2);
final value3 = await DevAppManager().readValue(input);
setState(() {
text = value3 ?? "not-found";
});
} catch (err) {
if (!context.mounted) return;
showBottomAlertKDialog(context, message: err.toString());
}
},
icon: const Icon(Icons.search),
),
const SizedBox(height: 20.0),
Text(text),
],
),
),
);
}
}