FLUTTER ECOSYSTEM

felixblaschke/shelf_hotreload

felixblaschke/shelf_hotreload open-source repository details.

shelf_hotreload 프로젝트 이미지
Stars
36
Forks
7
최근 푸시(UTC)
2025. 10. 17.
프로젝트 상태
활성
Felix Blaschke GitHub avatar
GITHUB User

Felix Blaschke ↗

Software Developer, M.Sc. Visual Computing

Frankfurt am Main, Germany
언어Dart

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 4 개

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

README 펼치기 / 접기

shelf_hotreload

Wrapper to easily enable hot-reload for shelf applications.

Usage

import 'dart:io';

import 'package:shelf/shelf.dart' as shelf;
import 'package:shelf/shelf_io.dart' as io;
import 'package:shelf_hotreload/shelf_hotreload.dart';

// Run this app with --enable-vm-service (or use debug run)
void main() async {
  withHotreload(() => createServer());
}

Future<HttpServer> createServer() {
  handler(shelf.Request request) => shelf.Response.ok('hot!');
  return io.serve(handler, 'localhost', 8080);
}

In order to enable hot-reload, you need to run your Dart application with --enable-vm-service (or use debug run in your IDE).

For example:

dart run --enable-vm-service path/to/app.dart
Custom logging

You can also also modify the default logging by providing callbacks:

final myLogger = Logger();

withHotreload(
  () => createServer(),
  onReloaded: () => myLogger.log('Reload!'),
  onHotReloadNotAvailable: () => myLogger.log('No hot-reload :('),
  onHotReloadAvailable: () => myLogger.log('Yay! Hot-reload :)'),
  onHotReloadLog: (log) => myLogger.log('Reload Log: ${log.message}'),
  logLevel: Level.INFO,
);