flutter

pub.dev - flutter package publish (패키지 올리기)

이나주니 2025. 3. 6. 14:25
반응형

제가 만들것은 위젯이 아닌 안드로이드 디바이스 웹뷰를 체크해주고 업데이트가 되도록 스토어로 이동시키는 기능입니다.

※ 안드로이드의 웹뷰 버전이 낮으면 웹뷰가 실행이 되지 않아 나는 이슈에 따른 대응 방안

 

먼저 프로젝트를 만든후 원하는 기능을 만들어줍니다.

 

패이지 생성 후

내가 만들 코드를 작성해줍니다.

 

info - lib\android_web_view_check.dart:34:9 - Don't invoke 'print' in production code. Try using a logging framework. - avoid_print 

이때 print 가 있으면 오류가 나니  

import 'dart:developer';

log("Debug message");

이렇게 바꿔주세요!

 

 

코드를 모두 작성 이 되었다면 

 

git에 내 프로젝트를 올려줍니다.

머저 깃 패키지를 만듭니다.

 

위 license 는 본인이 원하는것으로 지정해 줍니다.

 

MIT 라이선스 (가장 일반적)

MIT 라이선스는 제한 없이 사용 가능하지만, 저작권 표시를 유지해야 하는 라이선스입니다.

MIT License

Copyright (c) 2025 [Your Name or Organization]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

 

Apache 2.0 라이선스 (기업 친화적)

Apache 2.0 라이선스는 MIT보다 더 강력한 특허 보호 기능을 제공합니다.

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

Copyright 2025 [Your Name or Organization]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

 

이후 저장시

 

 

다시 pubspec.yaml 으로 돌아옵니다. 

여기서 name과 homepage와 publish_to 를 수정할텐데요

homepage는 깃주소를 넣고

publish_to 엔 

publish_to: "https://pub.dev"

 

이렇게 넣어주세요

 

 

이후 CHANGELOG.md 파일이 없으면 만듭니다.

 

## 1.0.0+1
- 최초 릴리즈
- Android WebView 관련 기능 추가

 

이렇게 본인에 대한 내용을 넣어줍니다.

 

 또 README.md 에 들어가 본인이 설명하고자 하는 내용을 넣어주세요.

 

이후 flutter pub publish --dry-run 을 실행해 줍니다.

 

혹시

Package validation found the following error:
* You must have a LICENSE file in the root directory.
  An open-source license helps ensure people can legally use your code.
Sorry, your package is missing a requirement and can't be published yet.
For more information, see: https://dart.dev/tools/pub/cmd/pub-lish.

이런 오류가 나지 않나요?

 만약 오류가 발생한다면 

LICENSE 파일을 만들어 본인이 지정한 라이센스에 대한 파일을 작성해주세요

 

MIT License

Copyright (c) 2025 [Your Name or Organization]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

 

명령어 flutter pub publish --dry-run 실행 후

정상이면 

이 메시지가 나옵니다.

이후 flutter pub publish 진행

 

Y를 눌러주세요

그럼

 

Then click "Allow access" 하라고 뜨는데 저 파란 링크를 눌러야합니다.

그런데 링크가 길어서 url이 잘려서 열립니다 그럼

 

이렇게 뜹니다. 몇십분 찾고 찾다가

url이 잘못된걸알았습니다.

그래서 url를 마우스로 다 긁어서 웹 url창에 복붙 하시면 정상적으로 접근 됩니다.

이점 꼭 참고해주세요!

승인 을 했다면

 

pub.dev에 들어가서 확인

 

 

짠 성공!

반응형