All checks were successful
ci/woodpecker/push/build Pipeline was successful
Signed-off-by: Nikolai Rodionov <iam@allanger.xyz>
73 lines
1.9 KiB
Dart
73 lines
1.9 KiB
Dart
import 'dart:developer';
|
|
|
|
import 'package:softplayer_web/api/grpc/test_service.dart';
|
|
import 'package:web/web.dart' as web;
|
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:grpc/grpc_web.dart';
|
|
import 'package:flutter/semantics.dart';
|
|
|
|
void main() async {
|
|
await dotenv.load(fileName: ".env");
|
|
String backendURL = dotenv.env['SOFTPLAYER_BACKEND_URL']!;
|
|
GrpcWebClientChannel grpcChannel = GrpcWebClientChannel.xhr(
|
|
Uri.parse(backendURL),
|
|
);
|
|
|
|
runApp(MyApp(channel: grpcChannel));
|
|
SemanticsBinding.instance.ensureSemantics();
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({super.key, required this.channel});
|
|
final GrpcWebClientChannel channel;
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
debugShowCheckedModeBanner: true,
|
|
title: 'Softplayer',
|
|
home: RootWidget(channel: channel),
|
|
);
|
|
}
|
|
}
|
|
|
|
class RootWidget extends StatefulWidget {
|
|
final GrpcWebClientChannel channel;
|
|
const RootWidget({super.key, required this.channel});
|
|
|
|
@override
|
|
State<StatefulWidget> createState() => _StateRootWidget();
|
|
}
|
|
|
|
class _StateRootWidget extends State<RootWidget> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Container(
|
|
width: double.infinity,
|
|
height: double.infinity,
|
|
child: Column(
|
|
children: [
|
|
ElevatedButton(
|
|
onPressed: () async {
|
|
TestAuthGrpc grpc = TestAuthGrpc(channel: widget.channel);
|
|
grpc.init();
|
|
await grpc.pong();
|
|
},
|
|
child: Text("pong"),
|
|
),
|
|
ElevatedButton(
|
|
onPressed: () async {
|
|
TestNoAuthGrpc grpc = TestNoAuthGrpc(channel: widget.channel);
|
|
grpc.init();
|
|
await grpc.ping();
|
|
},
|
|
child: Text("ping"),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|