渲染库捕获到异常,请检查

时间:2020-10-28 04:10:44

标签: flutter

> Launching lib\main.dart on MotoG3 TE in debug mode... Running Gradle

任务'assembleDebug'...√内置 build \ app \ outputs \ flutter-apk \ app-debug.apk。等待MotoG3 TE 报告其意见...侦听调试服务 ws://127.0.0.1:55032 / k8hU96apsuA = / ws正在将文件同步到设备MotoG3 TE ...

════════渲染库捕获异常 ══════════════════════════════════════════════════ liver SliverGeometry 无效:“ scrollExtent”为负数。相关 导致错误的小部件是:GridView 文件:/// C:/Users/amitc/AndroidStudioProjects/practice/lib/new/widgets/widget.dart:24:21 ══════════════════════════════════════════════════ ══════════════════════════════════════════════════

════════渲染库捕获异常 ══════════════════════════════════════════════════ liver SliverGeometry 无效:“ scrollExtent”为负数。 RenderSliv​​er 返回的违规几何图形为:RenderSliv​​erPadding#d7319 relayoutBoundary = up23 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE parentData:layoutOffset = None(可以使用 尺寸)约束:SliverConstraints(AxisDirection.down, GrowthDirection.forward,ScrollDirection.idle,scrollOffset:0.0, missingPaintExtent:Infinity,crossAxisExtent:328.0, crossAxisDirection:AxisDirection.right,viewportMainAxisExtent: Infinity,remainingCacheExtent:Infinity,cacheOrigin:-0.0)
几何:SliverGeometry(scrollExtent:-4.0,隐藏,maxPaintExtent: -4.0) scrollExtent:-4.0 隐 maxPaintExtent:-4.0填充:EdgeInsets.zero textDirection:ltr子级:RenderSliv​​erGrid#8eeb1 relayoutBoundary = up24 NEEDS-PAINT parentData:paintOffset = Offset(0.0,0.0)(可以使用大小) 约束:SliverConstraints(AxisDirection.down,GrowthDirection.forward,ScrollDirection.idle,scrollOffset:0.0, missingPaintExtent:Infinity,crossAxisExtent:328.0, crossAxisDirection:AxisDirection.right,viewportMainAxisExtent: Infinity,remainingCacheExtent:Infinity,cacheOrigin:0.0) 几何:SliverGeometry(scrollExtent:-4.0,隐藏,maxPaintExtent:-4.0) scrollExtent:-4.0 隐 maxPaintExtent:-4.0 当前没有子级存在相关的引起错误的小部件是:GridView 文件:/// C:/Users/amitc/AndroidStudioProjects/practice/lib/new/widgets/widget.dart:24:21 发生以下异常时正在处理以下RenderObject: 发射:RenderSliv​​erPadding#d7319 relayoutBoundary = up23 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE parentData: layoutOffset =无(可以使用大小)约束: SliverConstraints(AxisDirection.down,GrowthDirection.forward, ScrollDirection.idle,scrollOffset:0.0,其余PaintExtent: 无限,crossAxisExtent:328.0,crossAxisDirection: AxisDirection.right,viewportMainAxisExtent:无穷大, missingCacheExtent:Infinity,cacheOrigin:-0.0)几何: SliverGeometry(scrollExtent:-4.0,隐藏,maxPaintExtent:-4.0) scrollExtent:-4.0 隐 maxPaintExtent:-4.0填充:EdgeInsets.zero textDirection:ltr子级:RenderSliv​​erGrid#8eeb1 relayoutBoundary = up24 NEEDS-PAINT parentData:paintOffset = Offset(0.0,0.0)(可以使用大小) 约束:SliverConstraints(AxisDirection.down,GrowthDirection.forward,ScrollDirection.idle,scrollOffset:0.0, missingPaintExtent:Infinity,crossAxisExtent:328.0, crossAxisDirection:AxisDirection.right,viewportMainAxisExtent: Infinity,remainingCacheExtent:Infinity,cacheOrigin:0.0) 几何:SliverGeometry(scrollExtent:-4.0,隐藏,maxPaintExtent:-4.0) scrollExtent:-4.0 隐 maxPaintExtent:-4.0 当前没有子级活动的RenderObject:RenderSliv​​erPadding#d7319 relayoutBoundary = up23 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE parentData:layoutOffset = None(可以使用 尺寸)约束:SliverConstraints(AxisDirection.down, GrowthDirection.forward,ScrollDirection.idle,scrollOffset:0.0, missingPaintExtent:Infinity,crossAxisExtent:328.0, crossAxisDirection:AxisDirection.right,viewportMainAxisExtent: Infinity,remainingCacheExtent:Infinity,cacheOrigin:-0.0)
几何:SliverGeometry(scrollExtent:-4.0,隐藏,maxPaintExtent: -4.0) scrollExtent:-4.0 隐 maxPaintExtent:-4.0填充:EdgeInsets.zero textDirection:ltr子级:RenderSliv​​erGrid#8eeb1 relayoutBoundary = up24 NEEDS-PAINT parentData:paintOffset = Offset(0.0,0.0)(可以使用大小) 约束:SliverConstraints(AxisDirection.down,GrowthDirection.forward,ScrollDirection.idle,scrollOffset:0.0, missingPaintExtent:Infinity,crossAxisExtent:328.0, crossAxisDirection:AxisDirection.right,viewportMainAxisExtent: Infinity,remainingCacheExtent:Infinity,cacheOrigin:0.0) 几何:SliverGeometry(scrollExtent:-4.0,隐藏,maxPaintExtent:-4.0) scrollExtent:-4.0 隐 maxPaintExtent:-4.0 当前没有孩子live ══════════════════════════════════════════════════ ════

════════渲染库捕获异常 ══════════════════════════════════════════════════ liver SliverGeometry 无效:“ scrollExtent”为负数。相关 导致错误的小部件是:GridView 文件:/// C:/Users/amitc/AndroidStudioProjects/practice/lib/new/widgets/widget.dart:24:21 ══════════════════════════════════════════════════ ══════════════════════════════════════════════════

这是代码[应用未显示预览。] [1]

import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:practice/new/data/data.dart';
import 'package:practice/new/model/categorie_model.dart';
import 'package:practice/new/model/wallpaperModel.dart';
import 'package:practice/new/view/search.dart';
import 'package:practice/new/widgets/widget.dart';
import 'package:http/http.dart' as http;

class Home extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  List<CategorieModel> categories = new List();
  List<WallpaperModel> wallpaper = new List();
  TextEditingController searchController = new TextEditingController();

  Future getTrendingWallpaper() async {
    var responce = await http.get(
        "https://api.pexels.com/v1/curated?per_page=80&page=1",
        headers: {"Authorization": apiKey});
    print(responce.body.toString());
    Map<String, dynamic> jsonData = jsonDecode(responce.body);
    jsonData["photos"].forEach((element) {
      // print(element);
      WallpaperModel wallpaperModel = new WallpaperModel();
      wallpaperModel = WallpaperModel.fromMap(element);
      wallpaper.add(wallpaperModel);
    });
    setState(() {});
  }

  @override
  void initState() {
    getTrendingWallpaper();
    categories = getCategoris();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        title: brandName(),
        elevation: 0.0,
      ),
      body: SingleChildScrollView(
        child: Container(
          child: Column(
            children: [
              Container(
                decoration: BoxDecoration(
                    color: Color(0xfff5f8fd),
                    borderRadius: BorderRadius.circular(30)),
                margin: EdgeInsets.symmetric(horizontal: 24),
                padding: EdgeInsets.symmetric(horizontal: 24),
                child: Row(
                  children: [
                    Expanded(
                      child: TextField(
                        controller: searchController,
                        decoration: InputDecoration(
                            hintText: "search", border: InputBorder.none),
                      ),
                    ),
                    GestureDetector(
                        onTap: () {
                          Navigator.push(                                  //enter to next page through this navigator need to change with
                              context,
                              MaterialPageRoute(
                                  builder: (context) => Search(
                                        searchQuery: searchController.text,
                                      )));
                        },
                        child: Container(child: Icon(Icons.search)))
                  ],
                ),
              ),
              SizedBox(
                height: 16,
              ),
              Container(
                height: 80,
                child: ListView.builder(
                    padding: EdgeInsets.symmetric(horizontal: 24),
                    itemCount: categories.length,
                    shrinkWrap: false,
                    scrollDirection: Axis.horizontal,
                    itemBuilder: (BuildContext context, int index) {
                      return CategoriesTiles(
                        title: categories[index].categorieName,
                        imgUrl: categories[index].imgUrl,
                      );
                    }),
              ),
              SizedBox(
                height: 16,
              ),
              wallPapersList(wallpaper: wallpaper, context: context)
            ],
          ),
        ),
      ),
    );
  }
}

class CategoriesTiles extends StatelessWidget {
  final String imgUrl, title;

  const CategoriesTiles({Key key, @required this.imgUrl, @required this.title})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(right: 4),
      child: Stack(
        children: [
          ClipRRect(
              borderRadius: BorderRadius.circular(18),
              child: Image.network(
                imgUrl,
                height: 50,
                width: 100,
                fit: BoxFit.cover,
              )),
          Container(
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(18),
              color: Colors.black12,
            ),
            height: 50,
            width: 100,
            alignment: Alignment.center,
            child: Text(
              title,
              style: GoogleFonts.raleway(
                  color: Colors.white,
                  fontWeight: FontWeight.w800,
                  fontSize: 15),
            ),
          )
        ],
      ),
    );
  }
}

[https://i.stack.imgur.com/lypXP.png] [2]

0 个答案:

没有答案