Skip to content

Commit

Permalink
Upgrade packages for flutter 2 versions
Browse files Browse the repository at this point in the history
  • Loading branch information
lalomartins committed Mar 11, 2021
1 parent 9d52dda commit da2093b
Show file tree
Hide file tree
Showing 10 changed files with 431 additions and 164 deletions.
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# weekly_goals

A new Flutter project.
Really need to write something here eventually.

## Getting Started
## How to generate the proto files

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
1. Check out event-server (let's say side by side with this).
2. Install protoc. Note where you put the include files, let's call that $PROTO_INC. On Windows it
needs to be unpacked manually somewhere.
3. Install protoc_plugin for dart: `pub global activate protoc_plugin`. Pay attention to the
output; you may need to add something to your PATH.
4. Run protoc: `protoc --dart_out=grpc:lib/generated -I../event-server/proto -I$PROTOC_INC ../event-server/proto/service.proto`
4 changes: 2 additions & 2 deletions lib/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ class Config with ChangeNotifier {
notifyListeners();
}

String _serverAccount;
String _serverAccount = '';
String get serverAccount => _serverAccount;
set serverAccount(String serverAccount) {
_serverAccount = serverAccount;
_preferences.setString('serverAccount', serverAccount);
notifyListeners();
}

String _serverToken;
String _serverToken = '';
String get serverToken => _serverToken;
set serverToken(String serverToken) {
_serverToken = serverToken;
Expand Down
2 changes: 1 addition & 1 deletion lib/db.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class WeeklyGoalsDatabase extends _$WeeklyGoalsDatabase {
(select(events)..orderBy([(u) => OrderingTerm(expression: u.timestamp, mode: OrderingMode.desc)])).watch();

Future<List<Event>> get unsyncedEvents => (select(events)
..where((t) => isNull(t.synced))
..where((t) => t.synced.isNull())
..orderBy([(u) => OrderingTerm(expression: u.timestamp, mode: OrderingMode.asc)]))
.get();

Expand Down
327 changes: 276 additions & 51 deletions lib/generated/service.pb.dart

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/generated/service.pbenum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
// Generated code. Do not modify.
// source: service.proto
//
// @dart = 2.3
// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields

47 changes: 34 additions & 13 deletions lib/generated/service.pbgrpc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Generated code. Do not modify.
// source: service.proto
//
// @dart = 2.3
// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields

import 'dart:async' as $async;

Expand Down Expand Up @@ -32,32 +32,44 @@ class EventServerClient extends $grpc.Client {
($0.WatchEventsRequest value) => value.writeToBuffer(),
($core.List<$core.int> value) =>
$0.WatchEventsResponse.fromBuffer(value));
static final _$syncEvents =
$grpc.ClientMethod<$0.SyncEventsRequest, $0.SyncEventsResponse>(
'/eventserver.EventServer/SyncEvents',
($0.SyncEventsRequest value) => value.writeToBuffer(),
($core.List<$core.int> value) =>
$0.SyncEventsResponse.fromBuffer(value));

EventServerClient($grpc.ClientChannel channel, {$grpc.CallOptions options})
: super(channel, options: options);
EventServerClient($grpc.ClientChannel channel,
{$grpc.CallOptions? options,
$core.Iterable<$grpc.ClientInterceptor>? interceptors})
: super(channel, options: options, interceptors: interceptors);

$grpc.ResponseStream<$0.PushEventsResponse> pushEvents(
$async.Stream<$0.PushEventsRequest> request,
{$grpc.CallOptions options}) {
final call = $createCall(_$pushEvents, request, options: options);
return $grpc.ResponseStream(call);
{$grpc.CallOptions? options}) {
return $createStreamingCall(_$pushEvents, request, options: options);
}

$grpc.ResponseStream<$0.GetEventsResponse> getEvents(
$0.GetEventsRequest request,
{$grpc.CallOptions options}) {
final call = $createCall(_$getEvents, $async.Stream.fromIterable([request]),
{$grpc.CallOptions? options}) {
return $createStreamingCall(
_$getEvents, $async.Stream.fromIterable([request]),
options: options);
return $grpc.ResponseStream(call);
}

$grpc.ResponseStream<$0.WatchEventsResponse> watchEvents(
$0.WatchEventsRequest request,
{$grpc.CallOptions options}) {
final call = $createCall(
{$grpc.CallOptions? options}) {
return $createStreamingCall(
_$watchEvents, $async.Stream.fromIterable([request]),
options: options);
return $grpc.ResponseStream(call);
}

$grpc.ResponseStream<$0.SyncEventsResponse> syncEvents(
$async.Stream<$0.SyncEventsRequest> request,
{$grpc.CallOptions? options}) {
return $createStreamingCall(_$syncEvents, request, options: options);
}
}

Expand Down Expand Up @@ -88,6 +100,13 @@ abstract class EventServerServiceBase extends $grpc.Service {
($core.List<$core.int> value) =>
$0.WatchEventsRequest.fromBuffer(value),
($0.WatchEventsResponse value) => value.writeToBuffer()));
$addMethod($grpc.ServiceMethod<$0.SyncEventsRequest, $0.SyncEventsResponse>(
'SyncEvents',
syncEvents,
true,
true,
($core.List<$core.int> value) => $0.SyncEventsRequest.fromBuffer(value),
($0.SyncEventsResponse value) => value.writeToBuffer()));
}

$async.Stream<$0.GetEventsResponse> getEvents_Pre($grpc.ServiceCall call,
Expand All @@ -106,4 +125,6 @@ abstract class EventServerServiceBase extends $grpc.Service {
$grpc.ServiceCall call, $0.GetEventsRequest request);
$async.Stream<$0.WatchEventsResponse> watchEvents(
$grpc.ServiceCall call, $0.WatchEventsRequest request);
$async.Stream<$0.SyncEventsResponse> syncEvents(
$grpc.ServiceCall call, $async.Stream<$0.SyncEventsRequest> request);
}
49 changes: 47 additions & 2 deletions lib/generated/service.pbjson.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,93 @@
// Generated code. Do not modify.
// source: service.proto
//
// @dart = 2.3
// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package

import 'dart:core' as $core;
import 'dart:convert' as $convert;
import 'dart:typed_data' as $typed_data;
@$core.Deprecated('Use pushEventsRequestDescriptor instead')
const PushEventsRequest$json = const {
'1': 'PushEventsRequest',
'2': const [
const {'1': 'event', '3': 1, '4': 1, '5': 11, '6': '.eventserver.Event', '10': 'event'},
],
};

/// Descriptor for `PushEventsRequest`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List pushEventsRequestDescriptor = $convert.base64Decode('ChFQdXNoRXZlbnRzUmVxdWVzdBIoCgVldmVudBgBIAEoCzISLmV2ZW50c2VydmVyLkV2ZW50UgVldmVudA==');
@$core.Deprecated('Use pushEventsResponseDescriptor instead')
const PushEventsResponse$json = const {
'1': 'PushEventsResponse',
'2': const [
const {'1': 'result', '3': 1, '4': 1, '5': 11, '6': '.eventserver.EventOperationResult', '10': 'result'},
],
};

/// Descriptor for `PushEventsResponse`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List pushEventsResponseDescriptor = $convert.base64Decode('ChJQdXNoRXZlbnRzUmVzcG9uc2USOQoGcmVzdWx0GAEgASgLMiEuZXZlbnRzZXJ2ZXIuRXZlbnRPcGVyYXRpb25SZXN1bHRSBnJlc3VsdA==');
@$core.Deprecated('Use getEventsRequestDescriptor instead')
const GetEventsRequest$json = const {
'1': 'GetEventsRequest',
'2': const [
const {'1': 'filter', '3': 1, '4': 1, '5': 11, '6': '.eventserver.EventsFilter', '10': 'filter'},
],
};

/// Descriptor for `GetEventsRequest`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List getEventsRequestDescriptor = $convert.base64Decode('ChBHZXRFdmVudHNSZXF1ZXN0EjEKBmZpbHRlchgBIAEoCzIZLmV2ZW50c2VydmVyLkV2ZW50c0ZpbHRlclIGZmlsdGVy');
@$core.Deprecated('Use getEventsResponseDescriptor instead')
const GetEventsResponse$json = const {
'1': 'GetEventsResponse',
'2': const [
const {'1': 'result', '3': 1, '4': 1, '5': 11, '6': '.eventserver.EventOperationResult', '10': 'result'},
],
};

/// Descriptor for `GetEventsResponse`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List getEventsResponseDescriptor = $convert.base64Decode('ChFHZXRFdmVudHNSZXNwb25zZRI5CgZyZXN1bHQYASABKAsyIS5ldmVudHNlcnZlci5FdmVudE9wZXJhdGlvblJlc3VsdFIGcmVzdWx0');
@$core.Deprecated('Use watchEventsRequestDescriptor instead')
const WatchEventsRequest$json = const {
'1': 'WatchEventsRequest',
'2': const [
const {'1': 'filter', '3': 1, '4': 1, '5': 11, '6': '.eventserver.EventsFilter', '10': 'filter'},
],
};

/// Descriptor for `WatchEventsRequest`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List watchEventsRequestDescriptor = $convert.base64Decode('ChJXYXRjaEV2ZW50c1JlcXVlc3QSMQoGZmlsdGVyGAEgASgLMhkuZXZlbnRzZXJ2ZXIuRXZlbnRzRmlsdGVyUgZmaWx0ZXI=');
@$core.Deprecated('Use watchEventsResponseDescriptor instead')
const WatchEventsResponse$json = const {
'1': 'WatchEventsResponse',
'2': const [
const {'1': 'item', '3': 1, '4': 1, '5': 11, '6': '.eventserver.EventStreamItem', '10': 'item'},
],
};

/// Descriptor for `WatchEventsResponse`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List watchEventsResponseDescriptor = $convert.base64Decode('ChNXYXRjaEV2ZW50c1Jlc3BvbnNlEjAKBGl0ZW0YASABKAsyHC5ldmVudHNlcnZlci5FdmVudFN0cmVhbUl0ZW1SBGl0ZW0=');
@$core.Deprecated('Use syncEventsRequestDescriptor instead')
const SyncEventsRequest$json = const {
'1': 'SyncEventsRequest',
'2': const [
const {'1': 'event', '3': 1, '4': 1, '5': 11, '6': '.eventserver.Event', '9': 0, '10': 'event'},
const {'1': 'filter', '3': 2, '4': 1, '5': 11, '6': '.eventserver.EventsFilter', '9': 0, '10': 'filter'},
],
'8': const [
const {'1': 'pushpull'},
],
};

/// Descriptor for `SyncEventsRequest`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List syncEventsRequestDescriptor = $convert.base64Decode('ChFTeW5jRXZlbnRzUmVxdWVzdBIqCgVldmVudBgBIAEoCzISLmV2ZW50c2VydmVyLkV2ZW50SABSBWV2ZW50EjMKBmZpbHRlchgCIAEoCzIZLmV2ZW50c2VydmVyLkV2ZW50c0ZpbHRlckgAUgZmaWx0ZXJCCgoIcHVzaHB1bGw=');
@$core.Deprecated('Use syncEventsResponseDescriptor instead')
const SyncEventsResponse$json = const {
'1': 'SyncEventsResponse',
'2': const [
const {'1': 'result', '3': 1, '4': 1, '5': 11, '6': '.eventserver.EventOperationResult', '10': 'result'},
],
};

/// Descriptor for `SyncEventsResponse`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List syncEventsResponseDescriptor = $convert.base64Decode('ChJTeW5jRXZlbnRzUmVzcG9uc2USOQoGcmVzdWx0GAEgASgLMiEuZXZlbnRzZXJ2ZXIuRXZlbnRPcGVyYXRpb25SZXN1bHRSBnJlc3VsdA==');
7 changes: 4 additions & 3 deletions lib/server_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:grpc/grpc.dart';
import 'package:moor/moor.dart';
import 'package:timezone/timezone.dart' as tz;
import 'package:uuid/uuid.dart';

import 'config.dart';
import 'db.dart';
Expand Down Expand Up @@ -52,7 +53,7 @@ class ServerClient {
} else {
final data = res.result.event;
final event = EventsCompanion.insert(
uuid: uuid.unparse(data.uuid),
uuid: Uuid.unparse(data.uuid),
type: data.type,
name: data.name,
description: Value(data.description),
Expand All @@ -79,7 +80,7 @@ class ServerClient {
map[e.uuid] = e;
return PushEventsRequest()
..event = (pbTypes.Event()
..uuid = uuid.parse(e.uuid)
..uuid = Uuid.parse(e.uuid)
..account = _dummyAccount
..application = _applicationId
..type = e.type
Expand All @@ -104,7 +105,7 @@ class ServerClient {
print(
'Got error ${res.error.code} ${res.error.message} syncing ${toSync[i].uuid}');
else {
final evUuid = uuid.unparse(res.event.uuid);
final evUuid = Uuid.unparse(res.event.uuid);
final event =
map[evUuid].copyWith(synced: res.event.synced.toDateTime());
// print(
Expand Down
Loading

0 comments on commit da2093b

Please sign in to comment.