image_bus 0.1.0 copy "image_bus: ^0.1.0" to clipboard
image_bus: ^0.1.0 copied to clipboard

some convenience functions for manipulate image with a not bad performance.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:image_bus/image_bus.dart';

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  Uint8List? crop;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('image test'),
      ),
      body: ListView(
        padding: const EdgeInsets.all(32),
        children: [
          Image.asset('assets/1.jpg', height: 100),
          if (crop != null)
            Center(
              child: DecoratedBox(
                decoration: BoxDecoration(border: Border.all()),
                child: Image.memory(crop!),
              ),
            ),
        ],
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () async {
          final bytes = await PlatformAssetBundle().load('assets/1.jpg');
          final data = bytes.buffer.asUint8List();
          final result =
              await ImageBus(data).resize(maxWidth: 1920, maxHeight: 1920);
          setState(() {
            crop = result;
          });
        },
      ),
    );
  }
}
0
likes
140
pub points
0%
popularity

Publisher

verified publisherlaihz.tech

some convenience functions for manipulate image with a not bad performance.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on image_bus