@@ -102,27 +102,30 @@ void createBackgroundImages({
102102 required String ? backgroundImage,
103103 required String ? darkBackgroundImage,
104104}) {
105- const backgroundDestination = '${_webSplashImagesFolder }light-background.png' ;
105+ print ('[Web] Creating background images' );
106+ _createBackgroundImage (
107+ backgroundImage: backgroundImage,
108+ fileName: "light-background.png" ,
109+ );
110+ _createBackgroundImage (
111+ backgroundImage: darkBackgroundImage,
112+ fileName: "dark-background.png" ,
113+ );
114+ }
115+
116+ void _createBackgroundImage ({
117+ required String ? backgroundImage,
118+ required String fileName,
119+ }) {
120+ final backgroundDestination = '$_webSplashImagesFolder $fileName ' ;
106121 if (backgroundImage == null ) {
107122 final file = File (backgroundDestination);
108123 if (file.existsSync ()) file.deleteSync ();
109124 } else {
110- // Copy will not work if the directory does not exist, so createSync
111- // will ensure that the directory exists.
112- File (backgroundDestination).createSync (recursive: true );
113- File (backgroundImage).copySync (backgroundDestination);
114- }
115-
116- const darkBackgroundDestination =
117- '${_webSplashImagesFolder }dark-background.png' ;
118- if (darkBackgroundImage == null ) {
119- final file = File (darkBackgroundDestination);
120- if (file.existsSync ()) file.deleteSync ();
121- } else {
122- // Copy will not work if the directory does not exist, so createSync
123- // will ensure that the directory exists.
124- File (darkBackgroundDestination).createSync (recursive: true );
125- File (darkBackgroundImage).copySync (darkBackgroundDestination);
125+ createBackgroundImage (
126+ imageDestination: backgroundDestination,
127+ imageSource: backgroundImage,
128+ );
126129 }
127130}
128131
0 commit comments