Flutter:发布版本会产生问题

时间:2020-08-30 14:33:30

标签: flutter debugging stack widget release

我的代码哪里出问题了?

我的应用程序在调试模式下可以正常工作。但是当我进入发布模式时,某些小部件不会显示哪个放置在堆栈中。

我也获得了互联网许可。 <uses-permission android:name="android.permission.INTERNET"/>

这是我想要的Debug版本输出。

enter image description here 这是我的发行版本输出

enter image description here

这是我的代码-

import 'package:boimarket/model/model.dart';
import 'package:boimarket/screen/pdfscreen.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';


class BookDescription extends StatefulWidget {
  BookDescription({Key key, @required this.storyBooksValue}) : super(key: key);
  final storyBooksValue;

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

class _BookDescriptionState extends State<BookDescription> {



  @override
  void initState() {
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitDown,
      DeviceOrientation.portraitUp,
    ]);
    super.initState();
  }

  @override
  void dispose() {
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitDown,
      DeviceOrientation.portraitUp,
    ]);
  }

  @override
  Widget build(BuildContext context) {
    var _boxHeight = MediaQuery.of(context).size.height;
    var _boxWidth = MediaQuery.of(context).size.width;
    final Color _whiteCream = Color.fromRGBO(250, 245, 228, .8);
    final Color _darkBlue = Color.fromRGBO(0, 68, 69, 1);
    final Color _lightBlue = Color.fromRGBO(44, 120, 108, 1);
    return Scaffold(
      appBar: null,
      body: Stack(
        children: <Widget>[
          Container(
            color: _lightBlue,
            child: Stack(
              children: <Widget>[
                Card(
                  elevation: 10,
                  child: Container(
                    height: _boxHeight,
                    width: _boxWidth,
                    child: FadeInImage.assetNetwork(
                      fadeOutCurve: Curves.easeInCubic,
                      placeholder: 'assets/images/cover.jpg',
                      image: widget.storyBooksValue.imgUrl == null
                          ? "https://firebasestorage.googleapis.com/v0/b/boi-market.appspot.com/o/images%2Fcover.jpg?alt=media&token=f8070b25-533c-454b-9d2e-80702d72371e"
                          : widget.storyBooksValue.imgUrl,
                      height: _boxHeight,
                      width: _boxWidth,
                      fit: BoxFit.cover,
                    ),
                  ),
                ),
                Container(
                  height: _boxHeight,
                  width: _boxWidth,
                  color: Colors.black54,
                ),
                Align(
                  alignment: Alignment.bottomCenter,
                  child: SingleChildScrollView(
                    child: Column(
                      children: [
                        Container(
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Container(
                                padding: EdgeInsets.only(left: 20, top: 60.0),
                                child: Expanded(
                                  child: Text(
                                    "এই লেখকের আরও কিছু বই",
                                    style: TextStyle(
                                        fontSize: 30,
                                        fontWeight: FontWeight.bold,
                                        color: Colors.white),
                                    overflow: TextOverflow.clip,
                                  ),
                                ),
                              ),
                              Container(
                                padding: EdgeInsets.only(top: 10, bottom: 10),
                                height: 250.0,
                                child: FutureBuilder(
                                  future: fetchBooks(),
                                  builder: (context,
                                      AsyncSnapshot<List<Book>> snapshot) {
                                    if (!snapshot.hasData) {
                                      return Column(
                                        mainAxisAlignment:
                                            MainAxisAlignment.center,
                                        crossAxisAlignment:
                                            CrossAxisAlignment.center,
                                        children: <Widget>[
                                          CircularProgressIndicator(
                                            backgroundColor: _whiteCream,
                                          ),
                                          Text("Loading"),
                                        ],
                                      );
                                    } else {
                                      var writterBooks = snapshot.data
                                          .where((b) =>
                                              b.author ==
                                              widget.storyBooksValue.author)
                                          .toList();
                                      print(writterBooks.length);
                                      return ListView.builder(
                                          scrollDirection: Axis.horizontal,
                                          itemCount: writterBooks.length,
                                          itemBuilder: (context, index) {
                                            return GestureDetector(
                                              onTap: () {
                                                Route route = MaterialPageRoute(
                                                  builder: (context) =>
                                                      BookDescription(
                                                          storyBooksValue:
                                                              writterBooks[
                                                                  index]),
                                                );
                                                Navigator.push(context, route);
                                              },
                                              child: Container(
                                                padding: EdgeInsets.all(10),
                                                child: Column(
                                                  children: [
                                                    Container(
                                                      width: 100,
                                                      height: 140.0,
                                                      child: ClipRRect(
                                                        borderRadius:
                                                            BorderRadius
                                                                .circular(5.0),
                                                        child: FadeInImage
                                                            .assetNetwork(
                                                          fadeOutCurve:
                                                              Curves.linear,
                                                          placeholder:
                                                              'assets/images/cover.jpg',
                                                          image: writterBooks[
                                                                          index]
                                                                      .imgUrl ==
                                                                  null
                                                              ? "https://firebasestorage.googleapis.com/v0/b/boi-market.appspot.com/o/images%2Fcover.jpg?alt=media&token=f8070b25-533c-454b-9d2e-80702d72371e"
                                                              : writterBooks[
                                                                      index]
                                                                  .imgUrl,
                                                          width: 90,
                                                          height: 120.0,
                                                          fit: BoxFit.cover,
                                                        ),
                                                      ),
                                                    ),
                                                    Flexible(
                                                      child: Container(
                                                        width: 90,
                                                        child: Text(
                                                          "${writterBooks[index].name}",
                                                          style: TextStyle(
                                                              color:
                                                                  Colors.white,
                                                              fontWeight:
                                                                  FontWeight
                                                                      .bold,
                                                              fontSize: 12.0),
                                                          overflow:
                                                              TextOverflow.clip,
                                                        ),
                                                      ),
                                                    ),
                                                  ],
                                                ),
                                              ),
                                            );
                                          });
                                    }
                                  },
                                ),
                              ),
                            ],
                          ),
                        ),
                        Container(
                          width: _boxWidth,
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.only(
                                topLeft: Radius.circular(40.0),
                                topRight: Radius.circular(40.0)),
                            color: _whiteCream,
                            boxShadow: [
                              BoxShadow(
                                  color: Colors.black45,
                                  blurRadius: 5.0,
                                  spreadRadius: 1.0)
                            ],
                          ),
                          child: Padding(
                            padding: EdgeInsets.all(20),
                            child: Column(
                              children: <Widget>[
                                SizedBox(
                                  height: 30.0,
                                ),
                                Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  children: [
                                    Expanded(
                                      child: Container(
                                        child: Column(
                                          crossAxisAlignment:
                                              CrossAxisAlignment.start,
                                          children: [
                                            RichText(
                                              overflow: TextOverflow.clip,
                                              text: TextSpan(
                                                  style: TextStyle(
                                                      color: Colors.black),
                                                  children: [
                                                    TextSpan(
                                                        text: "বইয়ের নামঃ",
                                                        style: TextStyle(
                                                            fontWeight:
                                                                FontWeight.bold,
                                                            fontSize: 16.0)),
                                                    TextSpan(
                                                        text:
                                                            " ${widget.storyBooksValue.name}")
                                                  ]),
                                            ),
                                            SizedBox(
                                              height: 5.0,
                                            ),
                                            RichText(
                                              overflow: TextOverflow.clip,
                                              text: TextSpan(
                                                  style: TextStyle(
                                                      color: Colors.black),
                                                  children: [
                                                    TextSpan(
                                                        text: "লেখকঃ",
                                                        style: TextStyle(
                                                            fontWeight:
                                                                FontWeight.bold,
                                                            fontSize: 16.0)),
                                                    TextSpan(
                                                        text:
                                                            " ${widget.storyBooksValue.author}")
                                                  ]),
                                            ),
                                            SizedBox(
                                              height: 5.0,
                                            ),
                                            RichText(
                                              overflow: TextOverflow.clip,
                                              text: TextSpan(
                                                  style: TextStyle(
                                                      color: Colors.black),
                                                  children: [
                                                    TextSpan(
                                                        text: "বইয়ের ধরণঃ",
                                                        style: TextStyle(
                                                            fontWeight:
                                                                FontWeight.bold,
                                                            fontSize: 16.0)),
                                                    TextSpan(
                                                        text:
                                                            " ${widget.storyBooksValue.genreClass}")
                                                  ]),
                                            ),
                                          ],
                                        ),
                                      ),
                                    ),
                                    Card(
                                      elevation: 5.0,
                                      child: FadeInImage.assetNetwork(
                                        fadeOutCurve: Curves.easeInCubic,
                                        placeholder: 'assets/images/cover.jpg',
                                        image: widget.storyBooksValue.imgUrl ==
                                                null
                                            ? "https://firebasestorage.googleapis.com/v0/b/boi-market.appspot.com/o/images%2Fcover.jpg?alt=media&token=f8070b25-533c-454b-9d2e-80702d72371e"
                                            : widget.storyBooksValue.imgUrl,
                                        height: 100.0,
                                        fit: BoxFit.cover,
                                      ),
                                    ),
                                  ],
                                ),
                                Divider(),
                                widget.storyBooksValue.description == null
                                    ? Center(
                                        child: Text(
                                            'দুঃখিত, ${widget.storyBooksValue.name} বইটির বর্ণনা পাওয়া যায়নি'))
                                    : SelectableText(
                                        '${widget.storyBooksValue.description} \n',
                                      ),
                                Text(
                                    'আমরা বইটির একটি ebook খুজে পেয়েছি । \n\n আপনি বইটি পড়তে চাইলে, " Read Now " বাটনে ক্লিক করুন । \n'),
                                SizedBox(
                                  height: 75.0,
                                )
                              ],
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                )
              ],
            ),
          ),
          Padding(
            padding: EdgeInsets.only(left: 10.0, top: 20.0),
            child: IconButton(
                icon: Icon(Icons.arrow_back),
                color: _whiteCream,
                onPressed: () {
                  Navigator.pop(context, false);
                }),
          ),
          Positioned(
            bottom: 60.0,
            right: 20.0,
            child: RaisedButton(
              onPressed: () {
                print("clicked");
                Navigator.push(
                  context,
                  MaterialPageRoute(
                      builder: (context) =>
                          PdfScreen(singleBookData: widget.storyBooksValue)),
                );
              },
              shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(30)),
              color: _darkBlue,
              child: Text(
                "Read now",
                style: TextStyle(color: _whiteCream),
              ),
            ),
          ),
        ],
      ),
    );
  }
}

如何解决此问题?请有人帮我。

2 个答案:

答案 0 :(得分:1)

我通过删除文本容器解决了我的问题。只需使用text()而不使用container()

  Expanded(
              child: Text("এই লেখকের আরও কিছু বই",
                    style: TextStyle(
                    fontSize: 30,
                    fontWeight: FontWeight.bold,
                    color: Colors.white),
                    overflow: TextOverflow.clip,
              ),
           )

答案 1 :(得分:0)

要创建APP的发行版,您可以使用android studio, 当我创建应用程序的发行版时,我目前正在开发一个Flutter项目,然后该应用程序仅显示白色的空白屏幕,并且没有其他任何内容,我尝试了所有方法来解决此问题,但在搜索了两天后似乎没有任何效果知道使用android studio我们还可以创建应用程序的发行版,使用android studio的应用程序发行版解决了我的问题。

我个人的选择是用于flutter项目的android studio。

这是我用来创建发行版本的问题的链接。

How to build signed apk from Android Studio for Flutter

相关问题