diff --git a/README.md b/README.md index 3c6e818..a3962bc 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/sdk/flutter.dart b/lib/sdk/flutter.dart new file mode 100644 index 0000000..dc3c53a --- /dev/null +++ b/lib/sdk/flutter.dart @@ -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( + 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 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'); + } + } +} diff --git a/pubspec.yml b/pubspec.yml index 4853217..695569a 100644 --- a/pubspec.yml +++ b/pubspec.yml @@ -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: