Added asset wrapper.
FIXES: Image paths on web
This commit is contained in:
parent
0235ec6a83
commit
09f7e4fdd1
4 changed files with 48 additions and 19 deletions
|
@ -1,5 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:localstore/localstore.dart';
|
||||
import 'package:outbag_app/tools/assets.dart';
|
||||
|
||||
class RoomVisibility {
|
||||
final int type;
|
||||
|
@ -154,35 +155,50 @@ class RoomIcon {
|
|||
|
||||
// return image name
|
||||
String get img {
|
||||
String path = "";
|
||||
switch (type.toLowerCase()) {
|
||||
case 'love':
|
||||
return 'undraw/undraw_couple.svg';
|
||||
path = 'undraw/undraw_couple.svg';
|
||||
break;
|
||||
case 'sports':
|
||||
return 'undraw/undraw_greek_freak.svg';
|
||||
path = 'undraw/undraw_greek_freak.svg';
|
||||
break;
|
||||
case 'pets':
|
||||
return 'undraw/undraw_dog.svg';
|
||||
path = 'undraw/undraw_dog.svg';
|
||||
break;
|
||||
case 'vacation':
|
||||
return 'undraw/undraw_trip.svg';
|
||||
path = 'undraw/undraw_trip.svg';
|
||||
break;
|
||||
case 'gifts':
|
||||
return 'undraw/undraw_gifts.svg';
|
||||
path = 'undraw/undraw_gifts.svg';
|
||||
break;
|
||||
case 'groceries':
|
||||
return 'undraw/undraw_gone_shopping.svg';
|
||||
path = 'undraw/undraw_gone_shopping.svg';
|
||||
break;
|
||||
case 'fashion':
|
||||
return 'undraw/undraw_jewelry.svg';
|
||||
path = 'undraw/undraw_jewelry.svg';
|
||||
break;
|
||||
case 'art':
|
||||
return 'undraw/undraw_sculpting.svg';
|
||||
path = 'undraw/undraw_sculpting.svg';
|
||||
break;
|
||||
case 'tech':
|
||||
return 'undraw/undraw_progressive_app.svg';
|
||||
path = 'undraw/undraw_progressive_app.svg';
|
||||
break;
|
||||
case 'home':
|
||||
return 'undraw/undraw_under_construction.svg';
|
||||
path = 'undraw/undraw_under_construction.svg';
|
||||
break;
|
||||
case 'family':
|
||||
return 'undraw/undraw_family.svg';
|
||||
path = 'undraw/undraw_family.svg';
|
||||
break;
|
||||
case 'social':
|
||||
return 'undraw/undraw_pizza_sharing.svg';
|
||||
path = 'undraw/undraw_pizza_sharing.svg';
|
||||
break;
|
||||
case 'other':
|
||||
default:
|
||||
return 'undraw/undraw_file_manager.svg';
|
||||
path = 'undraw/undraw_file_manager.svg';
|
||||
}
|
||||
|
||||
return asset(path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:outbag_app/tools/assets.dart';
|
||||
import 'package:routemaster/routemaster.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'dart:math';
|
||||
|
@ -60,7 +61,7 @@ class _WelcomePageState extends State<WelcomePage> {
|
|||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SvgPicture.asset("undraw/undraw_shopping_app.svg",
|
||||
SvgPicture.asset(asset("undraw/undraw_shopping_app.svg"),
|
||||
fit: BoxFit.contain,
|
||||
width: smallest*0.5,
|
||||
height: smallest*0.5
|
||||
|
@ -76,7 +77,7 @@ class _WelcomePageState extends State<WelcomePage> {
|
|||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SvgPicture.asset("undraw/undraw_mobile_login.svg",
|
||||
SvgPicture.asset(asset("undraw/undraw_mobile_login.svg"),
|
||||
fit: BoxFit.contain,
|
||||
width: smallest*0.5,
|
||||
height: smallest*0.5),
|
||||
|
@ -92,7 +93,7 @@ class _WelcomePageState extends State<WelcomePage> {
|
|||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SvgPicture.asset("undraw/undraw_online_connection.svg",
|
||||
SvgPicture.asset(asset("undraw/undraw_online_connection.svg"),
|
||||
fit: BoxFit.contain,
|
||||
width: smallest*0.5,
|
||||
height: smallest*0.5),
|
||||
|
@ -108,7 +109,7 @@ class _WelcomePageState extends State<WelcomePage> {
|
|||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SvgPicture.asset("undraw/undraw_online_groceries.svg",
|
||||
SvgPicture.asset(asset("undraw/undraw_online_groceries.svg"),
|
||||
fit: BoxFit.contain,
|
||||
width: smallest*0.5,
|
||||
height: smallest*0.5),
|
||||
|
|
11
lib/tools/assets.dart
Normal file
11
lib/tools/assets.dart
Normal file
|
@ -0,0 +1,11 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
|
||||
String asset(String pathInAssets) {
|
||||
String prefix = "";
|
||||
|
||||
if (!kIsWeb || kReleaseMode) {
|
||||
prefix = "assets/";
|
||||
}
|
||||
|
||||
return '$prefix$pathInAssets';
|
||||
}
|
|
@ -47,7 +47,7 @@ dev_dependencies:
|
|||
# package. See that file for information about deactivating specific lint
|
||||
# rules and activating additional ones.
|
||||
flutter_lints: ^2.0.0
|
||||
flutter_launcher_icons: "^0.12.0"
|
||||
flutter_launcher_icons: ^0.12.0
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
@ -65,7 +65,8 @@ flutter:
|
|||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
assets:
|
||||
- assets/
|
||||
- assets/undraw/
|
||||
- assets/icon.png
|
||||
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.dev/assets-and-images/#resolution-aware
|
||||
|
|
Loading…
Reference in a new issue