native_convert 0.0.1 copy "native_convert: ^0.0.1" to clipboard
native_convert: ^0.0.1 copied to clipboard

A new Flutter plugin.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:native_convert/native_convert.dart';
import 'dart:io';
import 'package:image_pickers/image_pickers.dart';
import 'package:image/image.dart' as Img;
import 'package:native_convert_example/dither/dither.dart';


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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",y
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, @required this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;
  String imageUrl = '';
  @override
  void initState() {
    super.initState();
  }


  void _incrementCounter() {
    setState(() {
      _counter = nativeAdd(_counter, 1);
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.display1,
            ),
            Text(
                "native double value = ${nativeAdd(_counter, _counter)}"),
            imageUrl.length > 0 ? Image.file(
              File(
                imageUrl,
              ),
              fit: BoxFit.cover,
            ) : SizedBox(),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () => openGalley(),
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }

  void openGalley() async{
    await ImagePickers.pickerPaths().then((List medias){
      Media media = medias[0];
      imageUrl = media.path;
      var image = Img.decodeImage(File(imageUrl).readAsBytesSync());
      // print('dither:${dither(image).data}');
      image = dither(image);
      var asUint8List = image.data.buffer.asUint8List();
      // print('asUint8List:$asUint8List');
      setState(() {

      });
    });
  }
}
0
likes
30
pub points
0%
popularity

Publisher

unverified uploader

A new Flutter plugin.

Homepage

License

Apache-2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on native_convert