mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 06:48:26 +00:00
Compass app (#2446)
This commit is contained in:
23
compass_app/server/lib/config/assets.dart
Normal file
23
compass_app/server/lib/config/assets.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright 2024 The Flutter team. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import '../model/activity/activity.dart';
|
||||
import '../model/destination/destination.dart';
|
||||
|
||||
class Assets {
|
||||
static const _activities = '../app/assets/activities.json';
|
||||
static const _destinations = '../app/assets/destinations.json';
|
||||
|
||||
static final List<Destination> destinations =
|
||||
(json.decode(File(Assets._destinations).readAsStringSync()) as List)
|
||||
.map((element) => Destination.fromJson(element))
|
||||
.toList();
|
||||
static final List<Activity> activities =
|
||||
(json.decode(File(Assets._activities).readAsStringSync()) as List)
|
||||
.map((element) => Activity.fromJson(element))
|
||||
.toList();
|
||||
}
|
||||
34
compass_app/server/lib/config/constants.dart
Normal file
34
compass_app/server/lib/config/constants.dart
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright 2024 The Flutter team. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import '../model/user/user.dart';
|
||||
|
||||
class Constants {
|
||||
/// Email for the hardcoded login.
|
||||
static const email = 'email@example.com';
|
||||
|
||||
/// Password for the hardcoded login.
|
||||
static const password = 'password';
|
||||
|
||||
/// Token to be returned on successful login.
|
||||
static const token =
|
||||
' e1c37dfd973353b78bb71df050e2c6e72d53034e148920383968ae49b96f1fd2';
|
||||
|
||||
/// User id to be returned on successful login.
|
||||
static const userId = '123';
|
||||
|
||||
/// User name for the hardcoded user.
|
||||
static const name = 'Sofie';
|
||||
|
||||
/// For demo purposes we use a local asset.
|
||||
static const picture = 'assets/user.jpg';
|
||||
|
||||
/// Hardcoded user.
|
||||
static const user = User(
|
||||
id: Constants.userId,
|
||||
name: Constants.name,
|
||||
email: Constants.email,
|
||||
picture: Constants.picture,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user