Installation#
Get started with Fletch in minutes.
Requirements#
- Dart SDK: 3.6.0 or later
- Platform: Windows, macOS, Linux
Install via Pub#
Add fletch to your pubspec.yaml:
dependencies:
fletch: ^2.0.3
Then install dependencies:
dart pub get
Create Your First Server#
Create bin/server.dart:
import 'package:fletch/fletch.dart';
void main() async {
final app = Fletch();
app.get('/', (req, res) {
res.text('Hello from fletch!');
});
await app.listen(3000);
print('🚀 Server running on http://localhost:3000');
}
Run Your Server#
dart run bin/server.dart
Visit http://localhost:3000 to see your server in action!
Verify Installation#
Test that everything works:
curl http://localhost:3000
# Output: Hello from fletch!
Optional Dependencies#
For MongoDB Support#
dependencies:
mongo_dart: ^0.9.0
For Testing#
dev_dependencies:
test: ^1.24.0
http: ^1.1.0
Project Structure#
A typical Fletch project:
my_api/
├── bin/
│ └── server.dart # Entry point
├── lib/
│ ├── controllers/ # Route controllers
│ ├── models/ # Data models
│ ├── services/ # Business logic
│ └── middleware/ # Custom middleware
├── test/
│ └── server_test.dart
└── pubspec.yaml
**Pro Tip**: Use `dart run --observe` to enable debugging with Dart DevTools!