Home > Blockchain >  Flutter debug banner not removed
Flutter debug banner not removed

Time:10-14

hi i used the debugShowCheckedModeBanner:false inside the materialApp widget and but still the debug banner did not disappear . Any solution please
and thank you hi i used the debugShowCheckedModeBanner:false inside the materialApp widget and but still the debug banner did not disappear . Any solution please
and thank you

import 'dart:convert';
import 'dart:io';
import 'package:az/SR_Details.dart';
import 'package:az/main.dart';
import 'package:badges/badges.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:http/http.dart' as http;
import 'package:intl/intl.dart';

import 'class/sr.dart';

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner:false,
      home: DataFromAPI(),
    );
  }
}

class DataFromAPI extends StatefulWidget {
  @override
  _DataFromAPIState createState() => _DataFromAPIState();
}

List<Attributes> _MyAllData = [];
List<Attributes> filteredSR=[];
var srAttributes = [];
Map<String, Color>  map={
"QUEUED":Color.fromARGB(255, 255, 136, 0),
"CLOSED":Colors.grey,
"Rejeced":Colors.red,
"INPROG":Colors.green,
"PENDING":Colors.blue,
"RESOLVED":Colors.green,
"NEW":Colors.blue,
};
Map<dynamic, String>  map1={
1 :"Urgent",
2:"High",
3:"Medium",
4:"Low",
};
class _DataFromAPIState extends State<DataFromAPI> {
  var var1;
String title_string = "Liste des SR";

  @override
  void initState() {
    loadData().then((value) {
      setState(() {
        srAttributes.addAll(value);
      //  filteredSR=srAttributes;
      });
    });
    super.initState();
  }
void setappbar(numsr) {
setState((){
   title_string =numsr.toString();
});
}
  Future<List<Sr>> loadData() async {
    try {
      var response = await http.get(Uri.parse(
          'http://192:9080/maxrest/rest/mbo/sr/?_lid= &_lpwd= &_format=json'));
      if (response.statusCode == 200) {
        //print(response.body);
        final jsonBody = json.decode(response.body);
        Demandes data = Demandes.fromJson(jsonBody);
        final srAttributes = data.srMboSet.sr;
        title_string='Liste des SR : ${srAttributes.length.toString()}';
        return srAttributes;
      }
    } catch (e) {
      throw Exception(e.toString());
    }
    throw Exception("");
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: new Scaffold(  appBar: AppBar(
          title: Text(title_string),
          leading: IconButton(
              icon: Icon(Icons.arrow_back), onPressed: () {  Navigator.push(
                  context, MaterialPageRoute(builder: (context) => Home())); },
             ),
        ),
        body: FutureBuilder<List<Sr>?>(
          future: loadData(),
          builder: (context, snapshot) {
            if (!snapshot.hasData) {
              return SizedBox(
       height: MediaQuery.of(context).size.height / 1.3,
       child: Center(
           child: CircularProgressIndicator(),
            ),
        );
            } else {
              return new ListView.builder(
                itemCount: snapshot.data?.length,
                itemBuilder: ((_, index) {
                  return index == 0
                      ? _searchbar()
                      :
                      new ListTile(
                          title: new Card(
                            margin: new EdgeInsets.symmetric(
                                vertical: 2.0, horizontal: 8.0),
                            elevation: 10,
                            child: new ListTile(
                              title: new Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: <Widget>[
                                  Padding(padding: new EdgeInsets.all(2.0)),
                                  Row(children :[
                                  Container(
                                   decoration: BoxDecoration(
                                     border: Border.all(
                                     color: Color.fromARGB(255, 255, 255, 255),
                                    ),
                                    color: map['${snapshot.data![index].attributes.status.content}'],
                                    borderRadius: BorderRadius.all(Radius.circular(20)),
                                  ),
                                   child:Text('  ${snapshot.data![index].attributes.status.content}  '),
                                  ),
                                 Container(child: Text('  '),),
                                  Container(
                                   decoration: BoxDecoration(
                                     border: Border.all(
                                     color: Color.fromARGB(255, 255, 255, 255),
                                    ),
                                    color:Colors.grey,
                                    borderRadius: BorderRadius.all(Radius.circular(20)),
                                  ),
                                   child:Text(
                                    "  High  "),
                                  ),
                                   ],
                                    ),
                                    SizedBox( 
                                     height: 8,
                                     ),
                                     Row(children: <Widget>[
                                      Expanded( child: Container(child: Text('${snapshot.data![index].attributes.description?.content}',style: GoogleFonts.openSans(
                                                  textStyle: TextStyle(
                                                  fontSize: 16,
                                                  fontWeight: FontWeight.w600)),),),),
                                     Expanded(child: Container(child:Text( '  ${snapshot.data![index].attributes.ticketid.content}',style: GoogleFonts.openSans(
                                                  textStyle: TextStyle(
                                                  fontSize: 14,
                                                  fontWeight: FontWeight.w400)),)))
                                     ],),
                                      new Divider(
                                        color: Color.fromARGB(255, 110, 109, 109),
                                     ),
                                  Text(
                                    'Reported : ${DateFormat.yMMMMEEEEd().format(DateTime.parse('${snapshot.data![index].attributes.statusdate.content}' ))}' ,
                                 style: GoogleFonts.openSans(
                                                  textStyle: TextStyle(
                                                  fontSize: 16,
                                                  fontWeight: FontWeight.w400)),
                                    ),
                                  new Text(
                                      'Reported by  : ${snapshot.data![index].attributes.reportedby?.content}',style: GoogleFonts.openSans(
                                                  textStyle: TextStyle(
                                                  fontSize: 16,
                                                  fontWeight: FontWeight.w400)),
                                  ),
                                  Row(children: [new Image(image: AssetImage('assets/courroi.png'), width: 20),
                                      Text(
                                      '${snapshot.data![index].attributes.assetnum?.content}'),], ),
                                  Row(children: [new Image(image: AssetImage('assets/location1.png'), width: 20),
                                      Text(
                                      '${snapshot.data![index].attributes.assetsiteid?.content}'),], ) ,
                              
                                ],  
                              ),
                              trailing: Icon(Icons.arrow_forward_ios_rounded),
                              
                            ),
                          ),
                          onTap: () {
        /*  Navigator.push(
          context,MaterialPageRoute(builder: (context) =>SRDetail()),
  );*/
                          }
                          );
                }),
              );
            }
          },
        ),
      ),
    );
  }

CodePudding user response:

You DataFromAPI has another MaterialApp without that parameter. I'd suggest to remove it there because now you have a MaterialApp inside a MaterialApp

CodePudding user response:

You have two material app in your code, remove this material app

   class MyApp extends StatelessWidget {
     @override
      Widget build(BuildContext context) {
        return MaterialApp(
          debugShowCheckedModeBanner:false,
          home: DataFromAPI(),
        );
      }
    }

and return

    DataFromAPI(),

CodePudding user response:

Add debugShowCheckedModeBanner inside DataFromAPI MaterialApp widget.

 MaterialApp(
 debugShowCheckedModeBanner:false,
      home: new Scaffold(  appBar: AppBar(
          title: Text(title_string),
          leading: IconButton(
              icon: Icon(Icons.arrow_back), onPressed: () {  Navigator.push(
                  context, MaterialPageRoute(builder: (context) => Home())); },
             ),
        ),
   .........
  • Related