abi / screenshot-to-code

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)
https://screenshottocode.com
MIT License
56.01k stars 6.86k forks source link

Support Flutter #108

Open dialmedu opened 9 months ago

dialmedu commented 9 months ago

add support to Flutter for mobile apps i testing, this moment add button do show DartPad editor for watch preview the flutter app compiled in web browser.

soporte_para_flutter

@abi How would you approach this functionality? , note that:

The prompt

Performing "prompt" tests, the one that gave me the best result was this:

Keep in mind if in the following instruction you are also an expert in Flutter or use Flutter build sigle main.dart:

- Repeat elements as needed to match the screenshot. For example, if there are 15 items, the code should have 15 items. DO NOT LEAVE comments like "<!-- Repeat for each news item -->" or bad things will happen.
- Use Image.network and https://picsum.photos/ for images.
- Do not add comments in the code such as "Add your code here" in place of writing the full code. WRITE THE FULL CODE.
- Close code in this basic structure:

"```dart
// begin basic structure
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    var title = 'Screeshop App';

    return MaterialApp(
      title: title,
      home: Scaffold(
        appBar: AppBar(
          title: Text(title),
        ),
        body: Image.network('https://picsum.photos/100?image=8'),
      ),
    );
  }

```"
- Do not include markdown "```" or "```dart" at the start or end.
- if is Flutter Just return the code to me without explanations like "this is the code" or "your code would look like this"
abi commented 9 months ago

as mentioned here: https://github.com/abi/screenshot-to-code/pull/105#issuecomment-1827095982, we can have a output settings where the user can pick flutter and then, instead of the three tabs, we show the DartPad editor instead.

does Dart compile in the browser? no backend needed for this?

dialmedu commented 9 months ago

as mentioned here: #105 (comment), we can have a output settings where the user can pick flutter and then, instead of the three tabs, we show the DartPad editor instead.

does Dart compile in the browser? no backend needed for this?

this feat no requiered backend becose embend dartpad editor, (hosted in dartpad.dev ) read more in https://github.com/dart-lang/dart-pad , if the future use alternative "self-host", its requiered backend for run dart_services and dartpad_shared.

abi commented 9 months ago

awesome, flutter would be great to support.

when the framework choice is flutter, we can just embed the dartpad editor instead of having the desktop/mobile/code tabs

dialmedu commented 9 months ago

when the framework choice is flutter, we can just embed the dartpad editor instead of having the desktop/mobile/code tabs

today I will work on that. With the recent update of the 'output settings,' you can proceed with this functionality.