mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-08-14 09:30:21 +08:00
57 lines
1.3 KiB
Dart
57 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:grpc/grpc.dart';
|
|
|
|
import 'package:gitjournal/generated/shared_preferences.pb.dart';
|
|
import 'package:gitjournal/generated/shared_preferences.pbgrpc.dart';
|
|
|
|
Future<void> main(List<String> args) async {
|
|
return runApp(MyApp());
|
|
}
|
|
|
|
class MyApp extends StatefulWidget {
|
|
@override
|
|
_MyAppState createState() => _MyAppState();
|
|
}
|
|
|
|
class _MyAppState extends State<MyApp> {
|
|
var text = "Empty";
|
|
|
|
@override
|
|
void initState() {
|
|
_initAsync();
|
|
super.initState();
|
|
}
|
|
|
|
void _initAsync() async {
|
|
final channel = ClientChannel(
|
|
'localhost',
|
|
port: 50052,
|
|
options: ChannelOptions(
|
|
credentials: const ChannelCredentials.insecure(),
|
|
codecRegistry:
|
|
CodecRegistry(codecs: const [GzipCodec(), IdentityCodec()]),
|
|
),
|
|
);
|
|
final stub = SharedPreferencesClient(channel);
|
|
var keysResp = await stub.getKeys(EmptyMessage());
|
|
setState(() {
|
|
text = keysResp.value.toString();
|
|
});
|
|
await channel.shutdown();
|
|
// todo: Catch exceptions!
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: 'Welcome to Flutter',
|
|
home: Scaffold(
|
|
body: Center(
|
|
child: Text(text),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|