Skip to content

question:'package:flutter/src/widegets/text.dart':failed assertion:line 235 pos 15 : 'data ! = NULL ' : is not true code: #31785

Closed

Description

@sarahalramly

body: Container(
child: FutureBuilder(
future: _getQu(),
builder: (BuildContext context, AsyncSnapshot snapshot){
if (snapshot.data == null){
return Container(
child: Center(
child: Text(" تحميل البينات........"),
),
);
}Dn.jpg

Activity

  1. sarahalramly commented on Apr 29, 2019

    @sarahalramly
    Author

    import 'package:flutter/material.dart';
    import 'dart:async';
    import 'package:http/http.dart' as http;
    import 'dart:convert';

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

    class MyApp extends StatelessWidget {
    @OverRide
    Widget build(BuildContext context) {
    return MaterialApp(
    title: "الواجهه الرئيسية",
    debugShowCheckedModeBanner: false,
    theme: new ThemeData(
    primarySwatch: Colors.green[700]
    ),
    home: new MyhomePage(title: 'الاسئلة'),
    );
    }
    }
    class MyhomePage extends StatefulWidget {
    MyhomePage({Key key , this.title}):super(key:key);
    final String title;
    @OverRide
    _MyhomePageState createState()=> _MyhomePageState();

    }
    class _MyhomePageState extends State {
    var stringData = "";
    Future <List> _getQu() async{
    var data= await http.get("http://www.json-generator.com/api/json/get/cfwZmvEBbc?indent=2");
    var jsonData =json.decode(data.body);

    stringData =jsonData;
    

    List qu =[];
    for(var u in jsonData){
    Qu qur = Qu(u["questions"],u["ansar"]);
    qu.add(qur);
    }
    print(qu.length);
    return qu;

    }
    @override
    

    Widget build(BuildContext context){
    return new Scaffold(
    appBar: new AppBar(
    title: new Text(widget.title),
    ),
    body: Container(
    child: FutureBuilder(
    future: _getQu(),
    builder: (BuildContext context, AsyncSnapshot snapshot){

             if (stringData == null){
               return Container(
             child: Center(
                child: Text(" تحميل البينات........" ,  textDirection: TextDirection.rtl,),
              ),
               );
            } else{
             return ListView.builder(
               itemCount: snapshot.data.length,
               itemBuilder: (BuildContext context, int index){
                 return ListTile(
                
                 title: Text(snapshot.data[index].questions),
                 );
               },
             ); 
            }
           },
         ),
       ),
     );
    

    }

    }
    class Qu {
    final String questions;
    final bool ansar;
    Qu(this.questions, this.ansar);

    }

  2. baderouaich commented on Apr 29, 2019

    @baderouaich

    FutureBuilder<List> ( future: _getBookList(), builder: (context, snapshot) { if (snapshot.hasData) { return ListView.builder( itemCount: snapshot.data.length, itemBuilder: (BuildContext context, int index){ return ListTile( title: Text(snapshot.data[index].questions), ); }, ); } else if (snapshot.hasError) { return Text("${snapshot.error}"); } // By default, show a loading spinner return CircularProgressIndicator(); }, )

  3. BondarenkoStas commented on Oct 16, 2019

    @BondarenkoStas

    This is a question better suited for StackOverflow, since there doesn’t seem to be anything wrong with Flutter itself. Closing, as this is not an issue report. See https://flutter.dev/community for support options.

  4. github-actions commented on Aug 26, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  5. locked as resolved and limited conversation to collaborators on Aug 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions