curl_generator 1.0.0 copy "curl_generator: ^1.0.0" to clipboard
curl_generator: ^1.0.0 copied to clipboard

A Flutter package to create simple curl (bash) with params, headers and body.

example/lib/main.dart

import 'package:curl_generator/curl_generator.dart';
import 'package:flutter/material.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({
    Key? key,
  }) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _value = '';

  @override
  void initState() {
    super.initState();
    _initTest();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: Text(_value),
        ),
      ),
    );
  }

  void _initTest() {
    const url = 'https://some.api.com/some/path';
    const params = {
      'some': 'some',
      'params': 'params',
    };
    const header = {
      'some': 'some',
      'header': 'header',
    };
    const body = {
      'some': 'some',
      'body': 'body',
      'value': 123,
      'innerObject': {
        'some': 'some',
        'inner': false,
        'value': 2.5,
      },
    };
    final curl = Curl.curlOf(
      url: url,
      body: body,
      header: header,
      queryParams: params,
    );

    print(curl);

    setState(() {
      _value = curl;
    });
  }
}
5
likes
160
pub points
72%
popularity

Publisher

unverified uploader

A Flutter package to create simple curl (bash) with params, headers and body.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on curl_generator