Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android MyAppState没有显示任何内容 导入'dart:async'; 导入“dart:io”; 导入“dart:键入的_数据”; 进口“包装:颤振/cupertino.dart”; 进口“包装:颤振/材料.省道”; 导入“package:shared_pr_Android_Flutter_Dart_Flutter Layout_Dart Pub - Fatal编程技术网

Android MyAppState没有显示任何内容 导入'dart:async'; 导入“dart:io”; 导入“dart:键入的_数据”; 进口“包装:颤振/cupertino.dart”; 进口“包装:颤振/材料.省道”; 导入“package:shared_pr

Android MyAppState没有显示任何内容 导入'dart:async'; 导入“dart:io”; 导入“dart:键入的_数据”; 进口“包装:颤振/cupertino.dart”; 进口“包装:颤振/材料.省道”; 导入“package:shared_pr,android,flutter,dart,flutter-layout,dart-pub,Android,Flutter,Dart,Flutter Layout,Dart Pub,MyAppState没有显示任何内容 导入'dart:async'; 导入“dart:io”; 导入“dart:键入的_数据”; 进口“包装:颤振/cupertino.dart”; 进口“包装:颤振/材料.省道”; 导入“package:shared_preferences/shared_preferences.dart”; 导入“package:image_gallery_saver/image_gallery_saver.dart”; 导入“包:image_picker/image_pick

MyAppState没有显示任何内容
导入'dart:async';
导入“dart:io”;
导入“dart:键入的_数据”;
进口“包装:颤振/cupertino.dart”;
进口“包装:颤振/材料.省道”;
导入“package:shared_preferences/shared_preferences.dart”;
导入“package:image_gallery_saver/image_gallery_saver.dart”;
导入“包:image_picker/image_picker.dart”;
导入“package:qrscan/qrscan.dart”作为扫描仪;
void main(){
runApp(MyApp());
}
类MyApp扩展了StatefulWidget{
@凌驾
_MyAppState createState()=>\u MyAppState();
}
类MyAppState扩展了状态{
Uint8List字节=Uint8List(0);
TextEditingController\u输入控制器;
TextEditingController\u输出控制器;
@凌驾
initState(){
super.initState();
这是._inputController=新文本编辑控制器();
这是._outputController=新文本编辑控制器();
}
@凌驾
小部件构建(构建上下文){
返回材料PP(
debugShowCheckedModeBanner:false,
家:脚手架(
背景颜色:颜色。灰色[300],
车身:建造商(
生成器:(BuildContext上下文){
返回列表视图(
儿童:[
_qrCodeWidget(this.bytes,context),
容器(
颜色:颜色,白色,
子:列(
儿童:[
文本字段(
控制器:此。\u输入控制器,
键盘类型:TextInputType.url,
textInputAction:textInputAction.go,
提交时:(值)=>_generateBarCode(值),
装饰:输入装饰(
前缀:图标(图标、文本字段),
helperText:“请将您的代码输入到generage qrcode图像。”,
hintText:'请输入您的代码',
hintStyle:TextStyle(字体大小:15),
contentPadding:EdgeInsets.symmetric(
水平:7,垂直:15),
),
),
尺寸箱(高度:20),
文本字段(
控制器:这个输出控制器,
maxLines:2,
装饰:输入装饰(
前缀图标:图标(图标.换行文字),
helperText:“您扫描的条形码或QR码将显示在此区域。”,
hintText:'您扫描的条形码或QR码将显示在此区域。',
hintStyle:TextStyle(字体大小:15),
contentPadding:EdgeInsets.symmetric(
水平:7,垂直:15),
),
),
尺寸箱(高度:20),
这是。_buttonGroup(),
尺寸箱(高度:70),
],
),
),
],
);
},
),
浮动操作按钮:浮动操作按钮(
按下时:()=>\u scanBytes(),
工具提示:“拍照”,
子项:常量图标(Icons.camera_alt),
),
),
);
}
Widget\u qrCodeWidget(Uint8List字节,BuildContext上下文){
返回填充(
填充:边缘设置。全部(20),
孩子:卡片(
标高:6,
子:列(
儿童:[
容器(
孩子:排(
crossAxisAlignment:crossAxisAlignment.end,
儿童:[
图标(Icons.u用户,尺寸:18,颜色:Colors.green),
文本('Generate Qrcode',样式:TextStyle(fontSize:15)),
垫片(),
图标(Icons.more_vert,大小:18,颜色:Colors.black54),
],
),
填充:边缘组。对称(水平:10,垂直:9),
装饰:盒子装饰(
颜色:颜色。黑色,
borderRadius:仅限borderRadius(
左上角:半径。圆形(4),右上角:半径。圆形(4)),
),
),
填充物(
填充:仅限边缘设置(
左:40,右:40,顶部:30,底部:10),
子:列(
儿童:[
大小盒子(
身高:190,
子项:bytes.isEmpty
?中心(
子项:文本('空代码…',
样式:TextStyle(颜色:Colors.black38)),
)
:Image.memory(字节),
),
填充物(
填充:仅限边缘设置(顶部:7,左侧:25,右侧:25),
孩子:排(
mainAxisAlignment:mainAxisAlignment.spaceAround,
儿童:[
扩大(
弹性:5,
儿童:手势检测器(
子:文本(
“删除”,
样式:TextStyle(
字体大小:15,颜色:颜色。蓝色),
textAlign:textAlign.left,
),
onTap:()=>
this.setState(()=>this.bytes=Uint8List(0)),
),
),
文本(“|”,样式:TextStyle(字体大小:15,颜色:颜色
.black26(,
扩大(
弹性:5,
儿童:手势检测器(
onTap:()异步{
最终成功=等待ImageGallerySaver.saveImage(
import 'dart:async';
import 'dart:io';
import 'dart:typed_data';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart';
import 'package:image_picker/image_picker.dart';
import 'package:qrscan/qrscan.dart' as scanner;

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  Uint8List bytes = Uint8List(0);
  TextEditingController _inputController;
  TextEditingController _outputController;

  @override
  initState() {
    super.initState();
    this._inputController = new TextEditingController();
    this._outputController = new TextEditingController();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(

        backgroundColor: Colors.grey[300],

        body: Builder(
          builder: (BuildContext context) {
            return ListView(
              children: <Widget>[
                _qrCodeWidget(this.bytes, context),
                Container(
                  color: Colors.white,
                  child: Column(
                    children: <Widget>[
                      TextField(
                        controller: this._inputController,
                        keyboardType: TextInputType.url,
                        textInputAction: TextInputAction.go,
                        onSubmitted: (value) => _generateBarCode(value),
                        decoration: InputDecoration(
                          prefixIcon: Icon(Icons.text_fields),
                          helperText: 'Please input your code to generage qrcode image.',
                          hintText: 'Please Input Your Code',
                          hintStyle: TextStyle(fontSize: 15),
                          contentPadding: EdgeInsets.symmetric(
                              horizontal: 7, vertical: 15),
                        ),
                      ),
                      SizedBox(height: 20),
                      TextField(
                        controller: this._outputController,
                        maxLines: 2,
                        decoration: InputDecoration(
                          prefixIcon: Icon(Icons.wrap_text),
                          helperText: 'The barcode or qrcode you scan will be displayed in this area.',
                          hintText: 'The barcode or qrcode you scan will be displayed in this area.',
                          hintStyle: TextStyle(fontSize: 15),
                          contentPadding: EdgeInsets.symmetric(
                              horizontal: 7, vertical: 15),
                        ),
                      ),
                      SizedBox(height: 20),
                      this._buttonGroup(),
                      SizedBox(height: 70),
                    ],
                  ),
                ),
              ],
            );
          },
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () => _scanBytes(),
          tooltip: 'Take a Photo',
          child: const Icon(Icons.camera_alt),
        ),
      ),
    );
  }

  Widget _qrCodeWidget(Uint8List bytes, BuildContext context) {
    return Padding(
      padding: EdgeInsets.all(20),
      child: Card(
        elevation: 6,
        child: Column(
          children: <Widget>[
            Container(
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.end,
                children: <Widget>[
                  Icon(Icons.verified_user, size: 18, color: Colors.green),
                  Text('  Generate Qrcode', style: TextStyle(fontSize: 15)),
                  Spacer(),
                  Icon(Icons.more_vert, size: 18, color: Colors.black54),
                ],
              ),
              padding: EdgeInsets.symmetric(horizontal: 10, vertical: 9),
              decoration: BoxDecoration(
                color: Colors.black12,
                borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(4), topRight: Radius.circular(4)),
              ),
            ),
            Padding(
              padding: EdgeInsets.only(
                  left: 40, right: 40, top: 30, bottom: 10),
              child: Column(
                children: <Widget>[
                  SizedBox(
                    height: 190,
                    child: bytes.isEmpty
                        ? Center(
                      child: Text('Empty code ... ',
                          style: TextStyle(color: Colors.black38)),
                    )
                        : Image.memory(bytes),
                  ),
                  Padding(
                    padding: EdgeInsets.only(top: 7, left: 25, right: 25),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceAround,
                      children: <Widget>[
                        Expanded(
                          flex: 5,
                          child: GestureDetector(
                            child: Text(
                              'remove',
                              style: TextStyle(
                                  fontSize: 15, color: Colors.blue),
                              textAlign: TextAlign.left,
                            ),
                            onTap: () =>
                                this.setState(() => this.bytes = Uint8List(0)),
                          ),
                        ),
                        Text('|', style: TextStyle(fontSize: 15, color: Colors
                            .black26)),
                        Expanded(
                          flex: 5,
                          child: GestureDetector(
                            onTap: () async {
                              final success = await ImageGallerySaver.saveImage(
                                  this.bytes);
                              SnackBar snackBar;
                              if (success) {
                                snackBar = new SnackBar(content: new Text(
                                    'Successful Preservation!'));
                                Scaffold.of(context).showSnackBar(snackBar);
                              } else {
                                snackBar =
                                new SnackBar(content: new Text('Save failed!'));
                              }
                            },
                            child: Text(
                              'save',
                              style: TextStyle(
                                  fontSize: 15, color: Colors.blue),
                              textAlign: TextAlign.right,
                            ),
                          ),
                        ),
                      ],
                    ),
                  )
                ],
              ),
            ),
            Divider(height: 2, color: Colors.black26),

          ],
        ),
      ),
    );
  }

  Widget _buttonGroup() {
    return Row(
      children: <Widget>[
        Expanded(
          flex: 1,
          child: SizedBox(
            height: 120,
            child: InkWell(
              onTap: () => _generateBarCode(this._inputController.text),
              child: Card(
                child: Column(
                  children: <Widget>[
                    Expanded(
                      flex: 2,
                      child: Image.asset('images/generate_qrcode.png'),
                    ),
                    Divider(height: 20),
                    Expanded(flex: 1, child: Text("Generate")),
                  ],
                ),
              ),
            ),
          ),
        ),
        Expanded(
          flex: 1,
          child: SizedBox(
            height: 120,
            child: InkWell(
              onTap: _scan,
              child: Card(
                child: Column(
                  children: <Widget>[
                    Expanded(
                      flex: 2,
                      child: Image.asset('images/scanner.png'),
                    ),
                    Divider(height: 20),
                    Expanded(flex: 1, child: Text("Scan")),
                  ],
                ),
              ),
            ),
          ),
        ),
        Expanded(
          flex: 1,
          child: SizedBox(
            height: 120,
            child: InkWell(
              onTap: _scanPhoto,
              child: Card(
                child: Column(
                  children: <Widget>[
                    Expanded(
                      flex: 2,
                      child: Image.asset('images/albums.png'),
                    ),
                    Divider(height: 20),
                    Expanded(flex: 1, child: Text("Scan Photo")),
                  ],
                ),
              ),
            ),
          ),
        ),
      ],
    );
  }

  Future _scan() async {
    String barcode = await scanner.scan();
    if (barcode == null) {
      print('nothing return.');
    } else {
      this._outputController.text = barcode;
    }
  }

  Future _scanPhoto() async {
    String barcode = await scanner.scanPhoto();
    this._outputController.text = barcode;
  }

  Future _scanPath(String path) async {
    String barcode = await scanner.scanPath(path);
    this._outputController.text = barcode;
  }

  Future _scanBytes() async {
    File file = await ImagePicker.pickImage(source: ImageSource.camera);
    Uint8List bytes = file.readAsBytesSync();
    String barcode = await scanner.scanBytes(bytes);
    this._outputController.text = barcode;
  }

  Future _generateBarCode(String inputCode) async {
    Uint8List result = await scanner.generateBarCode(inputCode);
    this.setState(() => this.bytes = result);
  }
}
class MyAppState extends State<MyApp> {
  Future<SharedPreferences> _sPrefs = SharedPreferences.getInstance();
  final TextEditingController controller = TextEditingController();
  List<String> listOne, listTwo;

  @override
  void initState() {
    super.initState();
    listOne = [];
    listTwo = [];
  }

  Future<Null> addString() async {
    final SharedPreferences prefs = await _sPrefs;
    listOne.add(controller.text);
    prefs.setStringList('list', listOne);
    setState(() {
      controller.text = '';
    });
  }

  Future<Null> clearItems() async {
    final SharedPreferences prefs = await _sPrefs;
    prefs.clear();
    setState(() {
      listOne = [];
      listTwo = [];
    });
  }

  Future<Null> getStrings() async {
    final SharedPreferences prefs = await _sPrefs;
    listTwo = prefs.getStringList('list');
    setState(() {});
  }

  Future<Null> updateStrings(String str) async {
    final SharedPreferences prefs = await _sPrefs;
    setState(() {
      listOne.remove(str);
      listTwo.remove(str);
    });
    prefs.setStringList('list', listOne);

  }

  @override
  Widget build(BuildContext context) {
    getStrings();
    return Center(
      child: ListView(
        children: <Widget>[
          TextField(
              controller: controller,
              decoration: InputDecoration(
                hintText: 'Type in something...',
              )),
          RaisedButton(
            child: Text("Submit"),
            onPressed: () {
              addString();
            },
          ),
          RaisedButton(
            child: Text("Clear"),
            onPressed: () {
              clearItems();
            },
          ),
          Flex(
            direction: Axis.vertical,
            children: listTwo == null
                ? []
                : listTwo
                .map((String s) => Dismissible(
                key: Key(s),
                onDismissed: (direction) {
                  updateStrings(s);
                },
                child: ListTile(
                  title: Text(s),
                )))
                .toList(),
          )
        ],
      ),
    );
  }
}
import 'package:flutter/material.dart';
void main() {
   runApp(MyApp());
}

class MyApp extends StatelessWidget {
 @override
  Widget build(BuildContext context) {
    return MaterialApp(
    theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
    debugShowCheckedModeBanner: false,
    //Here I have called MyWidget Class 
   home: MyWidget()
  );
 }
}

 class MyWidget extends StatefulWidget {
 @override
 _MyWidgetState createState() => _MyWidgetState();
 }

class _MyWidgetState extends State<MyWidget> {
 Uint8List bytes = Uint8List(0);
 TextEditingController _inputController;
 TextEditingController _outputController;
 @override
  initState() {
   super.initState();
   this._inputController = new TextEditingController();
   this._outputController = new TextEditingController();
}

@override
 Widget build(BuildContext context) {
   return MaterialApp(
    debugShowCheckedModeBanner: false,
     home: Scaffold(