-
-
Save richard-flosi/8b43c06732d296f1145b8f5d12bf194e to your computer and use it in GitHub Desktop.
#!/bin/sh | |
FLUTTER_BRANCH=`grep channel: .metadata | sed 's/ channel: //g'` | |
FLUTTER_REVISION=`grep revision: .metadata | sed 's/ revision: //g'` | |
git clone https://github.com/flutter/flutter.git | |
cd flutter | |
git checkout $FLUTTER_BRANCH | |
git pull origin $FLUTTER_BRANCH | |
git checkout $FLUTTER_REVISION | |
cd .. | |
flutter/bin/flutter config --enable-web | |
flutter/bin/flutter build web |
[build] | |
command = "./flutter-netlify-build.sh" | |
publish = "build/web" |
@richard-flosi You were right! The issue is in the .metadata file as it was not updated reflecting the current flutter version on dev.
My apologies.
For others fighting with this.
.metadata
file is not updated by flutter upgrade
command.
I initially thought it reflects the current flutter version, which is not the case as it rather reflects the version of flutter at the time the project was created.
Looking around I honestly cannot find where the up to date project's flutter version is identified.
What's in your
.metadata
file?
AreFLUTTER_BRANCH
andFLUTTER_REVISION
set right?
I'm not using this methodology anymore. The idea here was to parse .metadata from flutters output. I'm using a fixed version at this point.I'm not sure exactly what is happening for you. Also, make sure that you clear the cache and retry the build in Netlify and maybe add some logging so you know if it's using a cached version of flutter or installing it from
git clone
.
Can you please share your new methodology
Here is the build script I just used to launch a new flutter web site on netlify:
build.sh
#!/bin/bash
# Get flutter
git clone https://github.com/flutter/flutter.git
FLUTTER=flutter/bin/flutter
# Configure flutter
FLUTTER_CHANNEL=master
FLUTTER_VERSION=v1.17.0
$FLUTTER channel $FLUTTER_CHANNEL
$FLUTTER version $FLUTTER_VERSION
$FLUTTER config --enable-web
# Build flutter for web
$FLUTTER build web
echo "OK"
Can you please share your new methodology?
I created a new gist to demonstrate here:
https://gist.github.com/richard-flosi/766040cec9bd2ea5da7a33bc01706de4
Hi there ! I'm pretty new to Flutter Web and Netlify and was wondering if perhaps you knew any resources that could explain this process ! How-to setup netlify with build scripts !
how can i generate .g.dart files while deploying??
how can i generate .g.dart files while deploying??
I'm not sure myself, but it looks like this issue may address your question: google/json_serializable.dart#581
See comment here: google/json_serializable.dart#581 (comment)
How to fix this error: 12:18:29 PM: Exception: Failed to compile application for the Web.
12:18:29 PM:
12:18:29 PM: build.command failed
12:18:29 PM: ────────────────────────────────────────────────────────────────
12:18:29 PM:
12:18:29 PM: Error message
12:18:29 PM: Command failed with exit code 1: if cd flutter; then git pull && cd ..; else git clone https://github.com/flutter/flutter.git; fi && flutter/bin/flutter config --enable-web && flutter/bin/flutter build web --release (https://ntl.fyi/exit-code-1)
12:18:29 PM:
12:18:29 PM: Error location
12:18:29 PM: In Build command from Netlify app:
12:18:29 PM: if cd flutter; then git pull && cd ..; else git clone https://github.com/flutter/flutter.git; fi && flutter/bin/flutter config --enable-web && flutter/bin/flutter build web --release
12:18:29 PM:
12:18:29 PM: Resolved config
12:18:29 PM: build:
12:18:29 PM: command: if cd flutter; then git pull && cd ..; else git clone https://github.com/flutter/flutter.git; fi && flutter/bin/flutter config --enable-web && flutter/bin/flutter build web --release
12:18:29 PM: commandOrigin: ui
12:18:29 PM: environment:
12:18:29 PM: - REVIEW_ID
12:18:29 PM: publish: /opt/build/repo/build/web
12:18:29 PM: publishOrigin: ui
12:18:31 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:18:31 PM: Failing build: Failed to build site
12:18:32 PM: Finished processing build request in 1m21.142s
@fisforfaheem This example is pretty old now and it looks like Netlify is reporting your build failed. I'd probably work on getting the build to work locally first and there is probably a better way to do this now. Have you read through the Flutter web docs here? https://docs.flutter.dev/platform-integration/web/building
i tried
I like your first approach of checking the metadata file as it reflects what I set as needed on one place.
I believe the metadata part is ok.
.metadata
file:Thanks for tip on the logging. I will dig further into in.