Skip to content

Commit

Permalink
Add Flutter support
Browse files Browse the repository at this point in the history
  • Loading branch information
223880 committed Jul 29, 2024
1 parent fa3c58b commit 9f00bc0
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
## Roadmap

- [x] Dockerfile
- [ ] Compatible with Flutter for build apps (mobile)
- [x] Compatible with Flutter for build apps (mobile)
- [ ] RBF
- [ ] Full RBF
- [ ] API
Expand Down
42 changes: 42 additions & 0 deletions lib/sdk/flutter.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('Dart Library in Flutter')),
body: Center(
child: FutureBuilder<String>(
future: fetchData(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return CircularProgressIndicator();
} else if (snapshot.hasError) {
return Text('Error: ${snapshot.error}');
} else {
return Text('Data: ${snapshot.data}');
}
},
),
),
),
);
}

Future<String> fetchData() async {
final response = await http.get(Uri.parse('https://jsonplaceholder.typicode.com/posts/1'));
if (response.statusCode == 200) {
var jsonResponse = jsonDecode(response.body);
return jsonResponse['title'];
} else {
throw Exception('Failed to load data');
}
}
}
1 change: 1 addition & 0 deletions pubspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies:
http: '^0.14.0'
cupertino_icons: ^1.0.0
bdk: '^0.31.2'
flutter: '^3.22.3'

# Dev dependencies for the project
dev_dependencies:
Expand Down

0 comments on commit 9f00bc0

Please sign in to comment.