Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
dd0b832a
Commit
dd0b832a
authored
Mar 30, 2016
by
Devon Carew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix image loading
parent
37581f94
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
14 deletions
+36
-14
flx.dart
packages/flutter_tools/lib/src/flx.dart
+36
-14
No files found.
packages/flutter_tools/lib/src/flx.dart
View file @
dd0b832a
...
...
@@ -34,14 +34,33 @@ const String _kFontSetMaterial = 'material';
const
String
_kFontSetRoboto
=
'roboto'
;
class
_Asset
{
_Asset
({
this
.
source
,
this
.
base
,
this
.
key
});
_Asset
({
this
.
base
,
String
assetEntry
,
this
.
relativePath
,
this
.
source
})
{
this
.
_assetEntry
=
assetEntry
;
}
String
_assetEntry
;
final
String
source
;
final
String
base
;
final
String
key
;
/// The entry to list in the generated asset manifest.
String
get
assetEntry
=>
_assetEntry
??
relativePath
;
/// Where the resource is on disk realtive to [base].
final
String
relativePath
;
final
String
source
;
/// The delta between what the assetEntry is and the relativePath (e.g.,
/// packages/material_gallery).
String
get
symbolicPrefix
{
if
(
_assetEntry
==
null
||
_assetEntry
==
relativePath
)
return
null
;
int
index
=
_assetEntry
.
indexOf
(
relativePath
);
return
index
==
-
1
?
null
:
_assetEntry
.
substring
(
0
,
index
);
}
@override
String
toString
()
=>
'
base:
$base
, key:
$ke
y
'
;
String
toString
()
=>
'
asset:
$assetEntr
y
'
;
}
Map
<
String
,
dynamic
>
_readMaterialFontsManifest
()
{
...
...
@@ -66,7 +85,7 @@ List<_Asset> _getMaterialAssets(String fontSet) {
result
.
add
(
new
_Asset
(
base:
'
${ArtifactStore.flutterRoot}
/bin/cache/artifacts/material_fonts'
,
source
:
path
.
basename
(
assetKey
),
key
:
assetKey
relativePath
:
assetKey
));
}
}
...
...
@@ -90,7 +109,7 @@ Map<_Asset, List<_Asset>> _parseAssets(
result
[
baseAsset
]
=
variants
;
// Find asset variants
String
assetPath
=
path
.
join
(
baseAsset
.
base
,
baseAsset
.
key
);
String
assetPath
=
path
.
join
(
baseAsset
.
base
,
baseAsset
.
relativePath
);
String
assetFilename
=
path
.
basename
(
assetPath
);
Directory
assetDir
=
new
Directory
(
path
.
dirname
(
assetPath
));
...
...
@@ -101,7 +120,10 @@ Map<_Asset, List<_Asset>> _parseAssets(
FileSystemEntity
.
isFileSync
(
entity
.
path
)
&&
entity
.
path
!=
assetPath
)
{
String
key
=
path
.
relative
(
entity
.
path
,
from:
baseAsset
.
base
);
variants
.
add
(
new
_Asset
(
base:
baseAsset
.
base
,
key:
key
));
String
assetEntry
;
if
(
baseAsset
.
symbolicPrefix
!=
null
)
assetEntry
=
path
.
join
(
baseAsset
.
symbolicPrefix
,
key
);
variants
.
add
(
new
_Asset
(
base:
baseAsset
.
base
,
assetEntry:
assetEntry
,
relativePath:
key
));
}
}
}
...
...
@@ -117,7 +139,7 @@ Map<_Asset, List<_Asset>> _parseAssets(
String
asset
=
font
[
'asset'
];
if
(
asset
==
null
)
continue
;
_Asset
baseAsset
=
new
_Asset
(
base:
assetBase
,
key
:
asset
);
_Asset
baseAsset
=
new
_Asset
(
base:
assetBase
,
relativePath
:
asset
);
result
[
baseAsset
]
=
<
_Asset
>[];
}
}
...
...
@@ -141,11 +163,11 @@ _Asset _resolveAsset(PackageMap packageMap, String assetBase, String asset) {
Uri
uri
=
packageMap
.
map
[
packageKey
];
if
(
uri
!=
null
&&
uri
.
scheme
==
'file'
)
{
File
file
=
new
File
.
fromUri
(
uri
);
return
new
_Asset
(
base:
file
.
path
,
key
:
relativeAsset
);
return
new
_Asset
(
base:
file
.
path
,
assetEntry:
asset
,
relativePath
:
relativeAsset
);
}
}
return
new
_Asset
(
base:
assetBase
,
key
:
asset
);
return
new
_Asset
(
base:
assetBase
,
relativePath
:
asset
);
}
dynamic
_loadManifest
(
String
manifestPath
)
{
...
...
@@ -170,13 +192,13 @@ Future<int> _validateManifest(Object manifest) async {
}
ZipEntry
_createAssetEntry
(
_Asset
asset
)
{
String
source
=
asset
.
source
??
asset
.
key
;
String
source
=
asset
.
source
??
asset
.
relativePath
;
File
file
=
new
File
(
'
${asset.base}
/
$source
'
);
if
(!
file
.
existsSync
())
{
printError
(
'Cannot find asset "
$source
" in directory "
${path.absolute(asset.base)}
".'
);
return
null
;
}
return
new
ZipEntry
.
fromFile
(
asset
.
ke
y
,
file
);
return
new
ZipEntry
.
fromFile
(
asset
.
assetEntr
y
,
file
);
}
ZipEntry
_createAssetManifest
(
Map
<
_Asset
,
List
<
_Asset
>>
assets
)
{
...
...
@@ -184,8 +206,8 @@ ZipEntry _createAssetManifest(Map<_Asset, List<_Asset>> assets) {
for
(
_Asset
main
in
assets
.
keys
)
{
List
<
String
>
variants
=
<
String
>[];
for
(
_Asset
variant
in
assets
[
main
])
variants
.
add
(
variant
.
key
);
json
[
main
.
key
]
=
variants
;
variants
.
add
(
variant
.
relativePath
);
json
[
main
.
relativePath
]
=
variants
;
}
return
new
ZipEntry
.
fromString
(
'AssetManifest.json'
,
JSON
.
encode
(
json
));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment