qid
int64
1
74.7M
question
stringlengths
16
65.1k
date
stringlengths
10
10
metadata
sequence
response_j
stringlengths
2
117k
response_k
stringlengths
3
61.5k
3,507,477
It doesn't seem that HttpServletResponse exposes any methods to do this. Right now, I'm adding a bunch of logging code to a crufty and ill-understood servlet, in an attempt to figure out what exactly it does. I know that it sets a bunch of cookies, but I don't know when, why, or what. It would be nice to just log all the cookies in the HttpServletResponse object at the end of the servlet's execution. I know that cookies are typically the browser's responsibility, and I remember that there was no way to do this in .NET. Just hoping that Java may be different... But if this isn't possible -- any other ideas for how to accomplish what I'm trying to do? Thanks, as always.
2010/08/17
[ "https://Stackoverflow.com/questions/3507477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/207341/" ]
If logging is all you're after, then I suggest writing an implemention of `javax.servlet.Filter` which wraps the supplied `HttpServletResponse` in a wrapper which allows you to expose the cookies after the filter executes. Something like this: ``` public class CookieLoggingFilter implements Filter { public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException ,ServletException { ResponseWrapper wrappedResponse = new ResponseWrapper((HttpServletResponse) response); filterChain.doFilter(request, wrappedResponse); // use a real logger here, naturally :) System.out.println("Cookies: " + wrappedResponse.cookies); } private class ResponseWrapper extends HttpServletResponseWrapper { private Collection<Cookie> cookies = new ArrayList<Cookie>(); public ResponseWrapper(HttpServletResponse response) { super(response); } @Override public void addCookie(Cookie cookie) { super.addCookie(cookie); cookies.add(cookie); } } // other methods here } ``` One big caveat: This will *not* show you what cookies are sent back to the browser, it will only show you which cookies the application code added to the response. If the container chooses to change, add to, or ignore those cookies (e.g. session cookies are handled by the container, not the application), you won't know using this approach. But that may not matter for your situation. The only way to be sure is to use a browser plugin like [Live Http Headers for Firefox](http://livehttpheaders.mozdev.org/), or a man-in-the-middle HTTP logging proxy.
Your only approach is to wrap the HttpServletResponse object so that the addCookie methods can intercept and log when cookies are set. You can do this by adding a ServletFilter which wraps the existing HttpServletResponse before it is passed into your Servlet.
3,507,477
It doesn't seem that HttpServletResponse exposes any methods to do this. Right now, I'm adding a bunch of logging code to a crufty and ill-understood servlet, in an attempt to figure out what exactly it does. I know that it sets a bunch of cookies, but I don't know when, why, or what. It would be nice to just log all the cookies in the HttpServletResponse object at the end of the servlet's execution. I know that cookies are typically the browser's responsibility, and I remember that there was no way to do this in .NET. Just hoping that Java may be different... But if this isn't possible -- any other ideas for how to accomplish what I'm trying to do? Thanks, as always.
2010/08/17
[ "https://Stackoverflow.com/questions/3507477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/207341/" ]
Your only approach is to wrap the HttpServletResponse object so that the addCookie methods can intercept and log when cookies are set. You can do this by adding a ServletFilter which wraps the existing HttpServletResponse before it is passed into your Servlet.
Cookies are sent to the client in the "Set-Cookie" response header. Try this: ``` private static void logResponseHeaders(HttpServletResponse httpServletResponse) { Collection<String> headerNames = httpServletResponse.getHeaderNames(); for (String headerName : headerNames) { if (headerName.equals("Set-Cookie")) { log.info("Response header name={}, header value={}", headerName, httpServletResponse.getHeader(headerName)); } } } ```
3,507,477
It doesn't seem that HttpServletResponse exposes any methods to do this. Right now, I'm adding a bunch of logging code to a crufty and ill-understood servlet, in an attempt to figure out what exactly it does. I know that it sets a bunch of cookies, but I don't know when, why, or what. It would be nice to just log all the cookies in the HttpServletResponse object at the end of the servlet's execution. I know that cookies are typically the browser's responsibility, and I remember that there was no way to do this in .NET. Just hoping that Java may be different... But if this isn't possible -- any other ideas for how to accomplish what I'm trying to do? Thanks, as always.
2010/08/17
[ "https://Stackoverflow.com/questions/3507477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/207341/" ]
If logging is all you're after, then I suggest writing an implemention of `javax.servlet.Filter` which wraps the supplied `HttpServletResponse` in a wrapper which allows you to expose the cookies after the filter executes. Something like this: ``` public class CookieLoggingFilter implements Filter { public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException ,ServletException { ResponseWrapper wrappedResponse = new ResponseWrapper((HttpServletResponse) response); filterChain.doFilter(request, wrappedResponse); // use a real logger here, naturally :) System.out.println("Cookies: " + wrappedResponse.cookies); } private class ResponseWrapper extends HttpServletResponseWrapper { private Collection<Cookie> cookies = new ArrayList<Cookie>(); public ResponseWrapper(HttpServletResponse response) { super(response); } @Override public void addCookie(Cookie cookie) { super.addCookie(cookie); cookies.add(cookie); } } // other methods here } ``` One big caveat: This will *not* show you what cookies are sent back to the browser, it will only show you which cookies the application code added to the response. If the container chooses to change, add to, or ignore those cookies (e.g. session cookies are handled by the container, not the application), you won't know using this approach. But that may not matter for your situation. The only way to be sure is to use a browser plugin like [Live Http Headers for Firefox](http://livehttpheaders.mozdev.org/), or a man-in-the-middle HTTP logging proxy.
I had the same problem where I was using a 3rd party library which accepts an HttpServletResponse and I needed to read back the cookies that it set on my response object. To solve that I created an HttpServletResponseWrapper extension which exposes these cookies for me after I make the call: ``` public class CookieAwareHttpServletResponse extends HttpServletResponseWrapper { private List<Cookie> cookies = new ArrayList<Cookie>(); public CookieAwareHttpServletResponse (HttpServletResponse aResponse) { super (aResponse); } @Override public void addCookie (Cookie aCookie) { cookies.add (aCookie); super.addCookie(aCookie); } public List<Cookie> getCookies () { return Collections.unmodifiableList (cookies); } } ``` And the way I use it: ``` // wrap the response object CookieAwareHttpServletResponse response = new CookieAwareHttpServletResponse(aResponse); // make the call to the 3rd party library String order = orderService.getOrder (aRequest, response, String.class); // get the list of cookies set List<Cookie> cookies = response.getCookies(); ```
3,507,477
It doesn't seem that HttpServletResponse exposes any methods to do this. Right now, I'm adding a bunch of logging code to a crufty and ill-understood servlet, in an attempt to figure out what exactly it does. I know that it sets a bunch of cookies, but I don't know when, why, or what. It would be nice to just log all the cookies in the HttpServletResponse object at the end of the servlet's execution. I know that cookies are typically the browser's responsibility, and I remember that there was no way to do this in .NET. Just hoping that Java may be different... But if this isn't possible -- any other ideas for how to accomplish what I'm trying to do? Thanks, as always.
2010/08/17
[ "https://Stackoverflow.com/questions/3507477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/207341/" ]
If logging is all you're after, then I suggest writing an implemention of `javax.servlet.Filter` which wraps the supplied `HttpServletResponse` in a wrapper which allows you to expose the cookies after the filter executes. Something like this: ``` public class CookieLoggingFilter implements Filter { public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException ,ServletException { ResponseWrapper wrappedResponse = new ResponseWrapper((HttpServletResponse) response); filterChain.doFilter(request, wrappedResponse); // use a real logger here, naturally :) System.out.println("Cookies: " + wrappedResponse.cookies); } private class ResponseWrapper extends HttpServletResponseWrapper { private Collection<Cookie> cookies = new ArrayList<Cookie>(); public ResponseWrapper(HttpServletResponse response) { super(response); } @Override public void addCookie(Cookie cookie) { super.addCookie(cookie); cookies.add(cookie); } } // other methods here } ``` One big caveat: This will *not* show you what cookies are sent back to the browser, it will only show you which cookies the application code added to the response. If the container chooses to change, add to, or ignore those cookies (e.g. session cookies are handled by the container, not the application), you won't know using this approach. But that may not matter for your situation. The only way to be sure is to use a browser plugin like [Live Http Headers for Firefox](http://livehttpheaders.mozdev.org/), or a man-in-the-middle HTTP logging proxy.
Cookies are sent to the client in the "Set-Cookie" response header. Try this: ``` private static void logResponseHeaders(HttpServletResponse httpServletResponse) { Collection<String> headerNames = httpServletResponse.getHeaderNames(); for (String headerName : headerNames) { if (headerName.equals("Set-Cookie")) { log.info("Response header name={}, header value={}", headerName, httpServletResponse.getHeader(headerName)); } } } ```
3,507,477
It doesn't seem that HttpServletResponse exposes any methods to do this. Right now, I'm adding a bunch of logging code to a crufty and ill-understood servlet, in an attempt to figure out what exactly it does. I know that it sets a bunch of cookies, but I don't know when, why, or what. It would be nice to just log all the cookies in the HttpServletResponse object at the end of the servlet's execution. I know that cookies are typically the browser's responsibility, and I remember that there was no way to do this in .NET. Just hoping that Java may be different... But if this isn't possible -- any other ideas for how to accomplish what I'm trying to do? Thanks, as always.
2010/08/17
[ "https://Stackoverflow.com/questions/3507477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/207341/" ]
I had the same problem where I was using a 3rd party library which accepts an HttpServletResponse and I needed to read back the cookies that it set on my response object. To solve that I created an HttpServletResponseWrapper extension which exposes these cookies for me after I make the call: ``` public class CookieAwareHttpServletResponse extends HttpServletResponseWrapper { private List<Cookie> cookies = new ArrayList<Cookie>(); public CookieAwareHttpServletResponse (HttpServletResponse aResponse) { super (aResponse); } @Override public void addCookie (Cookie aCookie) { cookies.add (aCookie); super.addCookie(aCookie); } public List<Cookie> getCookies () { return Collections.unmodifiableList (cookies); } } ``` And the way I use it: ``` // wrap the response object CookieAwareHttpServletResponse response = new CookieAwareHttpServletResponse(aResponse); // make the call to the 3rd party library String order = orderService.getOrder (aRequest, response, String.class); // get the list of cookies set List<Cookie> cookies = response.getCookies(); ```
Cookies are sent to the client in the "Set-Cookie" response header. Try this: ``` private static void logResponseHeaders(HttpServletResponse httpServletResponse) { Collection<String> headerNames = httpServletResponse.getHeaderNames(); for (String headerName : headerNames) { if (headerName.equals("Set-Cookie")) { log.info("Response header name={}, header value={}", headerName, httpServletResponse.getHeader(headerName)); } } } ```
64,822,800
Good Morning, I'm trying to put a Carousel on the home page looking for Firebase data, but for some reason, the first time I load the application it appears the message below: ``` ════════ Exception caught by widgets library ═════════════════════════════════════ ══════════════════ The following _CastError was thrown building DotsIndicator (animation: PageController # 734f9 (one client, offset 0.0), dirty, state: _AnimatedState # 636ca): Null check operator used on a null value ``` and the screen looks like this: [![Screen Fail](https://i.stack.imgur.com/dntBE.jpg)](https://i.stack.imgur.com/dntBE.jpg) After giving a hot reload the error continues to appear, but the image is loaded successfully, any tips of what I can do? [![Screen Ok](https://i.stack.imgur.com/ILvCb.jpg)](https://i.stack.imgur.com/ILvCb.jpg) HomeManager: ``` import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provantagens_app/models/section.dart'; class HomeManager extends ChangeNotifier{ HomeManager({this.images}){ _loadSections(); images = images ?? []; } void addSection(Section section){ _editingSections.add(section); notifyListeners(); } final List<dynamic> _sections = []; List<String> images; List<dynamic> newImages; List<dynamic> _editingSections = []; bool editing = false; bool loading = false; int index, totalItems; final Firestore firestore = Firestore.instance; Future<void> _loadSections() async{ loading = true; firestore.collection('home').snapshots().listen((snapshot){ _sections.clear(); for(final DocumentSnapshot document in snapshot.documents){ _sections.add( Section.fromDocument(document)); images = List<String>.from(document.data['images'] as List<dynamic>); } }); loading = false; notifyListeners(); } List<dynamic> get sections { if(editing) return _editingSections; else return _sections; } void enterEditing({Section section}){ editing = true; _editingSections = _sections.map((s) => s.clone()).toList(); defineIndex(section: section); notifyListeners(); } void saveEditing() async{ bool valid = true; for(final section in _editingSections){ if(!section.valid()) valid = false; } if(!valid) return; loading = true; notifyListeners(); for(final section in _editingSections){ await section.save(); } for(final section in List.from(_sections)){ if(!_editingSections.any((s) => s.id == section.id)){ await section.delete(); } } loading = false; editing = false; notifyListeners(); } void discardEditing(){ editing = false; notifyListeners(); } void removeSection(Section section){ _editingSections.remove(section); notifyListeners(); } void onMoveUp(Section section){ int index = _editingSections.indexOf(section); if(index != 0) { _editingSections.remove(section); _editingSections.insert(index - 1, section); index = _editingSections.indexOf(section); } notifyListeners(); } HomeManager clone(){ return HomeManager( images: List.from(images), ); } void onMoveDown(Section section){ index = _editingSections.indexOf(section); totalItems = _editingSections.length; if(index < totalItems - 1){ _editingSections.remove(section); _editingSections.insert(index + 1, section); index = _editingSections.indexOf(section); }else{ } notifyListeners(); } void defineIndex({Section section}){ index = _editingSections.indexOf(section); totalItems = _editingSections.length; notifyListeners(); } } ``` HomeScreen: ``` import 'package:carousel_pro/carousel_pro.dart'; import 'package:flutter/material.dart'; import 'package:provantagens_app/commom/custom_drawer.dart'; import 'package:provantagens_app/commom/custom_icons_icons.dart'; import 'package:provantagens_app/models/home_manager.dart'; import 'package:provantagens_app/models/section.dart'; import 'package:provantagens_app/screens/home/components/home_carousel.dart'; import 'package:provantagens_app/screens/home/components/menu_icon_tile.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; // ignore: must_be_immutable class HomeScreen extends StatelessWidget { HomeManager homeManager; Section section; List<Widget> get children => null; String videoUrl = 'https://www.youtube.com/watch?v=VFnDo3JUzjs'; int index; var _tapPosition; @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration( gradient: LinearGradient(colors: const [ Colors.white, Colors.white, ], begin: Alignment.topCenter, end: Alignment.bottomCenter)), child: Scaffold( backgroundColor: Colors.transparent, drawer: CustomDrawer(), appBar: AppBar( backgroundColor: Colors.transparent, iconTheme: IconThemeData(color: Colors.black), title: Text('Página inicial', style: TextStyle(color: Color.fromARGB(255, 30, 158, 8))), centerTitle: true, actions: <Widget>[ Divider(), ], ), body: Consumer<HomeManager>( builder: (_, homeManager, __){ return ListView(children: <Widget>[ AspectRatio( aspectRatio: 1, child:HomeCarousel(homeManager), ), Column( children: <Widget>[ Container( height: 50, ), Divider( color: Colors.black, ), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Padding( padding: const EdgeInsets.only(left:12.0), child: MenuIconTile(title: 'Parceiros', iconData: Icons.apartment, page: 1,), ), Padding( padding: const EdgeInsets.only(left:7.0), child: MenuIconTile(title: 'Beneficios', iconData: Icons.card_giftcard, page: 2,), ), Padding( padding: const EdgeInsets.only(right:3.0), child: MenuIconTile(title: 'Suporte', iconData: Icons.help_outline, page: 6,), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ MenuIconTile(iconData: Icons.assignment, title: 'Dados pessoais', page: 3) , MenuIconTile(iconData: Icons.credit_card_outlined, title: 'Meu cartão', page: 4) , MenuIconTile(iconData: Icons.account_balance_wallet_outlined, title: 'Pagamento', page: 5,) , ], ), Divider( color: Colors.black, ), Container( height: 50, ), Consumer<HomeManager>( builder: (_, sec, __){ return RaisedButton( child: Text('Teste'), onPressed: (){ Navigator.of(context) .pushReplacementNamed('/teste', arguments: sec); }, ); }, ), Text('Saiba onde usar o seu', style: TextStyle(color: Colors.black, fontSize: 20),), Text('Cartão Pró Vantagens', style: TextStyle(color: Color.fromARGB(255, 30, 158, 8), fontSize: 30),), AspectRatio( aspectRatio: 1, child: Image.network( 'https://static.wixstatic.com/media/d170e1_80b5f6510f5841c19046f1ed5bca71e4~mv2.png/v1/fill/w_745,h_595,al_c,q_90,usm_0.66_1.00_0.01/Arte_Cart%C3%83%C2%B5es.webp', fit: BoxFit.fill, ), ), Divider(), Container( height: 150, child: Row( children: [ AspectRatio( aspectRatio: 1, child: Image.network( 'https://static.wixstatic.com/media/d170e1_486dd638987b4ef48d12a4bafee20e80~mv2.png/v1/fill/w_684,h_547,al_c,q_90,usm_0.66_1.00_0.01/Arte_Cart%C3%83%C2%B5es_2.webp', fit: BoxFit.fill, ), ), Padding( padding: const EdgeInsets.only(left:20.0), child: RichText( text: TextSpan(children: <TextSpan>[ TextSpan( text: 'Adquira já o seu', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, color: Colors.black, ), ), TextSpan( text: '\n\CARTÃO PRÓ VANTAGENS', style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, color: Color.fromARGB(255, 30, 158, 8)), ), ]), ), ), ], ), ), Divider(), tableBeneficios(), Divider(), Padding( padding: const EdgeInsets.all(16.0), child: Column( children: [ Text( 'O cartão Pró-Vantagens é sediado na cidade de Hortolândia/SP e já está no mercado há mais de 3 anos. Somos um time de profissionais apaixonados por gestão de benefícios e empenhados em gerar o máximo de valor para os conveniados.'), FlatButton( onPressed: () { launch( 'https://www.youtube.com/watch?v=VFnDo3JUzjs'); }, child: Text('SAIBA MAIS')), ], ), ), Container( color: Color.fromARGB(255, 105, 190, 90), child: Column( children: <Widget>[ Row( children: [ Padding( padding: const EdgeInsets.all(16), child: Text( '© 2020 todos os direitos reservados a Cartão Pró Vantagens.', style: TextStyle(fontSize: 10), ), ) ], ), Divider(), Row( children: [ Padding( padding: const EdgeInsets.all(16), child: Text( 'Rua Luís Camilo de Camargo, 175 -\n\Centro, Hortolândia (piso superior)', style: TextStyle(fontSize: 10), ), ), Padding( padding: const EdgeInsets.only(left: 16), child: IconButton( icon: Icon(CustomIcons.facebook), color: Colors.black, onPressed: () { launch( 'https://www.facebook.com/provantagens/'); }, ), ), Padding( padding: const EdgeInsets.only(left: 16), child: IconButton( icon: Icon(CustomIcons.instagram), color: Colors.black, onPressed: () { launch( 'https://www.instagram.com/cartaoprovantagens/'); }, ), ), ], ), ], ), ) ], ), ]); }, ) ), ); } tableBeneficios() { return Table( defaultColumnWidth: FlexColumnWidth(120.0), border: TableBorder( horizontalInside: BorderSide( color: Colors.black, style: BorderStyle.solid, width: 1.0, ), verticalInside: BorderSide( color: Colors.black, style: BorderStyle.solid, width: 1.0, ), ), children: [ _criarTituloTable(",Plus, Premium"), _criarLinhaTable("Seguro de vida\n\(Morte Acidental),X,X"), _criarLinhaTable("Seguro de Vida\n\(Qualquer natureza),,X"), _criarLinhaTable("Invalidez Total e Parcial,X,X"), _criarLinhaTable("Assistência Residencial,X,X"), _criarLinhaTable("Assistência Funeral,X,X"), _criarLinhaTable("Assistência Pet,X,X"), _criarLinhaTable("Assistência Natalidade,X,X"), _criarLinhaTable("Assistência Eletroassist,X,X"), _criarLinhaTable("Assistência Alimentação,X,X"), _criarLinhaTable("Descontos em Parceiros,X,X"), ], ); } _criarLinhaTable(String listaNomes) { return TableRow( children: listaNomes.split(',').map((name) { return Container( alignment: Alignment.center, child: RichText( text: TextSpan(children: <TextSpan>[ TextSpan( text: name != "X" ? '' : 'X', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, color: Colors.black, ), ), TextSpan( text: name != 'X' ? name : '', style: TextStyle( fontSize: 10.0, fontWeight: FontWeight.bold, color: Color.fromARGB(255, 30, 158, 8)), ), ]), ), padding: EdgeInsets.all(8.0), ); }).toList(), ); } _criarTituloTable(String listaNomes) { return TableRow( children: listaNomes.split(',').map((name) { return Container( alignment: Alignment.center, child: RichText( text: TextSpan(children: <TextSpan>[ TextSpan( text: name == "" ? '' : 'Plano ', style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, color: Colors.black, ), ), TextSpan( text: name, style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, color: Color.fromARGB(255, 30, 158, 8)), ), ]), ), padding: EdgeInsets.all(8.0), ); }).toList(), ); } void _storePosition(TapDownDetails details) { _tapPosition = details.globalPosition; } } ```
2020/11/13
[ "https://Stackoverflow.com/questions/64822800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14632998/" ]
I forked the library to create a custom carousel for my company's project, and since we updated flutter to 2.x we had the same problem. To fix this just update boolean expressions like ``` if(carouselState.pageController.position.minScrollExtent == null || carouselState.pageController.position.maxScrollExtent == null){ ... } ``` to ``` if(!carouselState.pageController.position.hasContentDimensions){ ... } ``` [Here is flutter's github reference.](https://github.com/flutter/flutter/issues/66250)
Just upgrade to `^3.0.0` Check here <https://pub.dev/packages/carousel_slider>
64,822,800
Good Morning, I'm trying to put a Carousel on the home page looking for Firebase data, but for some reason, the first time I load the application it appears the message below: ``` ════════ Exception caught by widgets library ═════════════════════════════════════ ══════════════════ The following _CastError was thrown building DotsIndicator (animation: PageController # 734f9 (one client, offset 0.0), dirty, state: _AnimatedState # 636ca): Null check operator used on a null value ``` and the screen looks like this: [![Screen Fail](https://i.stack.imgur.com/dntBE.jpg)](https://i.stack.imgur.com/dntBE.jpg) After giving a hot reload the error continues to appear, but the image is loaded successfully, any tips of what I can do? [![Screen Ok](https://i.stack.imgur.com/ILvCb.jpg)](https://i.stack.imgur.com/ILvCb.jpg) HomeManager: ``` import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provantagens_app/models/section.dart'; class HomeManager extends ChangeNotifier{ HomeManager({this.images}){ _loadSections(); images = images ?? []; } void addSection(Section section){ _editingSections.add(section); notifyListeners(); } final List<dynamic> _sections = []; List<String> images; List<dynamic> newImages; List<dynamic> _editingSections = []; bool editing = false; bool loading = false; int index, totalItems; final Firestore firestore = Firestore.instance; Future<void> _loadSections() async{ loading = true; firestore.collection('home').snapshots().listen((snapshot){ _sections.clear(); for(final DocumentSnapshot document in snapshot.documents){ _sections.add( Section.fromDocument(document)); images = List<String>.from(document.data['images'] as List<dynamic>); } }); loading = false; notifyListeners(); } List<dynamic> get sections { if(editing) return _editingSections; else return _sections; } void enterEditing({Section section}){ editing = true; _editingSections = _sections.map((s) => s.clone()).toList(); defineIndex(section: section); notifyListeners(); } void saveEditing() async{ bool valid = true; for(final section in _editingSections){ if(!section.valid()) valid = false; } if(!valid) return; loading = true; notifyListeners(); for(final section in _editingSections){ await section.save(); } for(final section in List.from(_sections)){ if(!_editingSections.any((s) => s.id == section.id)){ await section.delete(); } } loading = false; editing = false; notifyListeners(); } void discardEditing(){ editing = false; notifyListeners(); } void removeSection(Section section){ _editingSections.remove(section); notifyListeners(); } void onMoveUp(Section section){ int index = _editingSections.indexOf(section); if(index != 0) { _editingSections.remove(section); _editingSections.insert(index - 1, section); index = _editingSections.indexOf(section); } notifyListeners(); } HomeManager clone(){ return HomeManager( images: List.from(images), ); } void onMoveDown(Section section){ index = _editingSections.indexOf(section); totalItems = _editingSections.length; if(index < totalItems - 1){ _editingSections.remove(section); _editingSections.insert(index + 1, section); index = _editingSections.indexOf(section); }else{ } notifyListeners(); } void defineIndex({Section section}){ index = _editingSections.indexOf(section); totalItems = _editingSections.length; notifyListeners(); } } ``` HomeScreen: ``` import 'package:carousel_pro/carousel_pro.dart'; import 'package:flutter/material.dart'; import 'package:provantagens_app/commom/custom_drawer.dart'; import 'package:provantagens_app/commom/custom_icons_icons.dart'; import 'package:provantagens_app/models/home_manager.dart'; import 'package:provantagens_app/models/section.dart'; import 'package:provantagens_app/screens/home/components/home_carousel.dart'; import 'package:provantagens_app/screens/home/components/menu_icon_tile.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; // ignore: must_be_immutable class HomeScreen extends StatelessWidget { HomeManager homeManager; Section section; List<Widget> get children => null; String videoUrl = 'https://www.youtube.com/watch?v=VFnDo3JUzjs'; int index; var _tapPosition; @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration( gradient: LinearGradient(colors: const [ Colors.white, Colors.white, ], begin: Alignment.topCenter, end: Alignment.bottomCenter)), child: Scaffold( backgroundColor: Colors.transparent, drawer: CustomDrawer(), appBar: AppBar( backgroundColor: Colors.transparent, iconTheme: IconThemeData(color: Colors.black), title: Text('Página inicial', style: TextStyle(color: Color.fromARGB(255, 30, 158, 8))), centerTitle: true, actions: <Widget>[ Divider(), ], ), body: Consumer<HomeManager>( builder: (_, homeManager, __){ return ListView(children: <Widget>[ AspectRatio( aspectRatio: 1, child:HomeCarousel(homeManager), ), Column( children: <Widget>[ Container( height: 50, ), Divider( color: Colors.black, ), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Padding( padding: const EdgeInsets.only(left:12.0), child: MenuIconTile(title: 'Parceiros', iconData: Icons.apartment, page: 1,), ), Padding( padding: const EdgeInsets.only(left:7.0), child: MenuIconTile(title: 'Beneficios', iconData: Icons.card_giftcard, page: 2,), ), Padding( padding: const EdgeInsets.only(right:3.0), child: MenuIconTile(title: 'Suporte', iconData: Icons.help_outline, page: 6,), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ MenuIconTile(iconData: Icons.assignment, title: 'Dados pessoais', page: 3) , MenuIconTile(iconData: Icons.credit_card_outlined, title: 'Meu cartão', page: 4) , MenuIconTile(iconData: Icons.account_balance_wallet_outlined, title: 'Pagamento', page: 5,) , ], ), Divider( color: Colors.black, ), Container( height: 50, ), Consumer<HomeManager>( builder: (_, sec, __){ return RaisedButton( child: Text('Teste'), onPressed: (){ Navigator.of(context) .pushReplacementNamed('/teste', arguments: sec); }, ); }, ), Text('Saiba onde usar o seu', style: TextStyle(color: Colors.black, fontSize: 20),), Text('Cartão Pró Vantagens', style: TextStyle(color: Color.fromARGB(255, 30, 158, 8), fontSize: 30),), AspectRatio( aspectRatio: 1, child: Image.network( 'https://static.wixstatic.com/media/d170e1_80b5f6510f5841c19046f1ed5bca71e4~mv2.png/v1/fill/w_745,h_595,al_c,q_90,usm_0.66_1.00_0.01/Arte_Cart%C3%83%C2%B5es.webp', fit: BoxFit.fill, ), ), Divider(), Container( height: 150, child: Row( children: [ AspectRatio( aspectRatio: 1, child: Image.network( 'https://static.wixstatic.com/media/d170e1_486dd638987b4ef48d12a4bafee20e80~mv2.png/v1/fill/w_684,h_547,al_c,q_90,usm_0.66_1.00_0.01/Arte_Cart%C3%83%C2%B5es_2.webp', fit: BoxFit.fill, ), ), Padding( padding: const EdgeInsets.only(left:20.0), child: RichText( text: TextSpan(children: <TextSpan>[ TextSpan( text: 'Adquira já o seu', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, color: Colors.black, ), ), TextSpan( text: '\n\CARTÃO PRÓ VANTAGENS', style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, color: Color.fromARGB(255, 30, 158, 8)), ), ]), ), ), ], ), ), Divider(), tableBeneficios(), Divider(), Padding( padding: const EdgeInsets.all(16.0), child: Column( children: [ Text( 'O cartão Pró-Vantagens é sediado na cidade de Hortolândia/SP e já está no mercado há mais de 3 anos. Somos um time de profissionais apaixonados por gestão de benefícios e empenhados em gerar o máximo de valor para os conveniados.'), FlatButton( onPressed: () { launch( 'https://www.youtube.com/watch?v=VFnDo3JUzjs'); }, child: Text('SAIBA MAIS')), ], ), ), Container( color: Color.fromARGB(255, 105, 190, 90), child: Column( children: <Widget>[ Row( children: [ Padding( padding: const EdgeInsets.all(16), child: Text( '© 2020 todos os direitos reservados a Cartão Pró Vantagens.', style: TextStyle(fontSize: 10), ), ) ], ), Divider(), Row( children: [ Padding( padding: const EdgeInsets.all(16), child: Text( 'Rua Luís Camilo de Camargo, 175 -\n\Centro, Hortolândia (piso superior)', style: TextStyle(fontSize: 10), ), ), Padding( padding: const EdgeInsets.only(left: 16), child: IconButton( icon: Icon(CustomIcons.facebook), color: Colors.black, onPressed: () { launch( 'https://www.facebook.com/provantagens/'); }, ), ), Padding( padding: const EdgeInsets.only(left: 16), child: IconButton( icon: Icon(CustomIcons.instagram), color: Colors.black, onPressed: () { launch( 'https://www.instagram.com/cartaoprovantagens/'); }, ), ), ], ), ], ), ) ], ), ]); }, ) ), ); } tableBeneficios() { return Table( defaultColumnWidth: FlexColumnWidth(120.0), border: TableBorder( horizontalInside: BorderSide( color: Colors.black, style: BorderStyle.solid, width: 1.0, ), verticalInside: BorderSide( color: Colors.black, style: BorderStyle.solid, width: 1.0, ), ), children: [ _criarTituloTable(",Plus, Premium"), _criarLinhaTable("Seguro de vida\n\(Morte Acidental),X,X"), _criarLinhaTable("Seguro de Vida\n\(Qualquer natureza),,X"), _criarLinhaTable("Invalidez Total e Parcial,X,X"), _criarLinhaTable("Assistência Residencial,X,X"), _criarLinhaTable("Assistência Funeral,X,X"), _criarLinhaTable("Assistência Pet,X,X"), _criarLinhaTable("Assistência Natalidade,X,X"), _criarLinhaTable("Assistência Eletroassist,X,X"), _criarLinhaTable("Assistência Alimentação,X,X"), _criarLinhaTable("Descontos em Parceiros,X,X"), ], ); } _criarLinhaTable(String listaNomes) { return TableRow( children: listaNomes.split(',').map((name) { return Container( alignment: Alignment.center, child: RichText( text: TextSpan(children: <TextSpan>[ TextSpan( text: name != "X" ? '' : 'X', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, color: Colors.black, ), ), TextSpan( text: name != 'X' ? name : '', style: TextStyle( fontSize: 10.0, fontWeight: FontWeight.bold, color: Color.fromARGB(255, 30, 158, 8)), ), ]), ), padding: EdgeInsets.all(8.0), ); }).toList(), ); } _criarTituloTable(String listaNomes) { return TableRow( children: listaNomes.split(',').map((name) { return Container( alignment: Alignment.center, child: RichText( text: TextSpan(children: <TextSpan>[ TextSpan( text: name == "" ? '' : 'Plano ', style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, color: Colors.black, ), ), TextSpan( text: name, style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, color: Color.fromARGB(255, 30, 158, 8)), ), ]), ), padding: EdgeInsets.all(8.0), ); }).toList(), ); } void _storePosition(TapDownDetails details) { _tapPosition = details.globalPosition; } } ```
2020/11/13
[ "https://Stackoverflow.com/questions/64822800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14632998/" ]
I forked the library to create a custom carousel for my company's project, and since we updated flutter to 2.x we had the same problem. To fix this just update boolean expressions like ``` if(carouselState.pageController.position.minScrollExtent == null || carouselState.pageController.position.maxScrollExtent == null){ ... } ``` to ``` if(!carouselState.pageController.position.hasContentDimensions){ ... } ``` [Here is flutter's github reference.](https://github.com/flutter/flutter/issues/66250)
I solved the similar problem as follows. You can take advantage of the Boolean variable. I hope, help you. ``` child: !loading ? HomeCarousel(homeManager) : Center(child:ProgressIndicator()), ``` or ``` child: isLoading ? HomeCarousel(homeManager) : SplashScreen(), ``` ``` class SplashScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Text('Loading...') ), ); } } ```
64,822,800
Good Morning, I'm trying to put a Carousel on the home page looking for Firebase data, but for some reason, the first time I load the application it appears the message below: ``` ════════ Exception caught by widgets library ═════════════════════════════════════ ══════════════════ The following _CastError was thrown building DotsIndicator (animation: PageController # 734f9 (one client, offset 0.0), dirty, state: _AnimatedState # 636ca): Null check operator used on a null value ``` and the screen looks like this: [![Screen Fail](https://i.stack.imgur.com/dntBE.jpg)](https://i.stack.imgur.com/dntBE.jpg) After giving a hot reload the error continues to appear, but the image is loaded successfully, any tips of what I can do? [![Screen Ok](https://i.stack.imgur.com/ILvCb.jpg)](https://i.stack.imgur.com/ILvCb.jpg) HomeManager: ``` import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provantagens_app/models/section.dart'; class HomeManager extends ChangeNotifier{ HomeManager({this.images}){ _loadSections(); images = images ?? []; } void addSection(Section section){ _editingSections.add(section); notifyListeners(); } final List<dynamic> _sections = []; List<String> images; List<dynamic> newImages; List<dynamic> _editingSections = []; bool editing = false; bool loading = false; int index, totalItems; final Firestore firestore = Firestore.instance; Future<void> _loadSections() async{ loading = true; firestore.collection('home').snapshots().listen((snapshot){ _sections.clear(); for(final DocumentSnapshot document in snapshot.documents){ _sections.add( Section.fromDocument(document)); images = List<String>.from(document.data['images'] as List<dynamic>); } }); loading = false; notifyListeners(); } List<dynamic> get sections { if(editing) return _editingSections; else return _sections; } void enterEditing({Section section}){ editing = true; _editingSections = _sections.map((s) => s.clone()).toList(); defineIndex(section: section); notifyListeners(); } void saveEditing() async{ bool valid = true; for(final section in _editingSections){ if(!section.valid()) valid = false; } if(!valid) return; loading = true; notifyListeners(); for(final section in _editingSections){ await section.save(); } for(final section in List.from(_sections)){ if(!_editingSections.any((s) => s.id == section.id)){ await section.delete(); } } loading = false; editing = false; notifyListeners(); } void discardEditing(){ editing = false; notifyListeners(); } void removeSection(Section section){ _editingSections.remove(section); notifyListeners(); } void onMoveUp(Section section){ int index = _editingSections.indexOf(section); if(index != 0) { _editingSections.remove(section); _editingSections.insert(index - 1, section); index = _editingSections.indexOf(section); } notifyListeners(); } HomeManager clone(){ return HomeManager( images: List.from(images), ); } void onMoveDown(Section section){ index = _editingSections.indexOf(section); totalItems = _editingSections.length; if(index < totalItems - 1){ _editingSections.remove(section); _editingSections.insert(index + 1, section); index = _editingSections.indexOf(section); }else{ } notifyListeners(); } void defineIndex({Section section}){ index = _editingSections.indexOf(section); totalItems = _editingSections.length; notifyListeners(); } } ``` HomeScreen: ``` import 'package:carousel_pro/carousel_pro.dart'; import 'package:flutter/material.dart'; import 'package:provantagens_app/commom/custom_drawer.dart'; import 'package:provantagens_app/commom/custom_icons_icons.dart'; import 'package:provantagens_app/models/home_manager.dart'; import 'package:provantagens_app/models/section.dart'; import 'package:provantagens_app/screens/home/components/home_carousel.dart'; import 'package:provantagens_app/screens/home/components/menu_icon_tile.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; // ignore: must_be_immutable class HomeScreen extends StatelessWidget { HomeManager homeManager; Section section; List<Widget> get children => null; String videoUrl = 'https://www.youtube.com/watch?v=VFnDo3JUzjs'; int index; var _tapPosition; @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration( gradient: LinearGradient(colors: const [ Colors.white, Colors.white, ], begin: Alignment.topCenter, end: Alignment.bottomCenter)), child: Scaffold( backgroundColor: Colors.transparent, drawer: CustomDrawer(), appBar: AppBar( backgroundColor: Colors.transparent, iconTheme: IconThemeData(color: Colors.black), title: Text('Página inicial', style: TextStyle(color: Color.fromARGB(255, 30, 158, 8))), centerTitle: true, actions: <Widget>[ Divider(), ], ), body: Consumer<HomeManager>( builder: (_, homeManager, __){ return ListView(children: <Widget>[ AspectRatio( aspectRatio: 1, child:HomeCarousel(homeManager), ), Column( children: <Widget>[ Container( height: 50, ), Divider( color: Colors.black, ), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Padding( padding: const EdgeInsets.only(left:12.0), child: MenuIconTile(title: 'Parceiros', iconData: Icons.apartment, page: 1,), ), Padding( padding: const EdgeInsets.only(left:7.0), child: MenuIconTile(title: 'Beneficios', iconData: Icons.card_giftcard, page: 2,), ), Padding( padding: const EdgeInsets.only(right:3.0), child: MenuIconTile(title: 'Suporte', iconData: Icons.help_outline, page: 6,), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ MenuIconTile(iconData: Icons.assignment, title: 'Dados pessoais', page: 3) , MenuIconTile(iconData: Icons.credit_card_outlined, title: 'Meu cartão', page: 4) , MenuIconTile(iconData: Icons.account_balance_wallet_outlined, title: 'Pagamento', page: 5,) , ], ), Divider( color: Colors.black, ), Container( height: 50, ), Consumer<HomeManager>( builder: (_, sec, __){ return RaisedButton( child: Text('Teste'), onPressed: (){ Navigator.of(context) .pushReplacementNamed('/teste', arguments: sec); }, ); }, ), Text('Saiba onde usar o seu', style: TextStyle(color: Colors.black, fontSize: 20),), Text('Cartão Pró Vantagens', style: TextStyle(color: Color.fromARGB(255, 30, 158, 8), fontSize: 30),), AspectRatio( aspectRatio: 1, child: Image.network( 'https://static.wixstatic.com/media/d170e1_80b5f6510f5841c19046f1ed5bca71e4~mv2.png/v1/fill/w_745,h_595,al_c,q_90,usm_0.66_1.00_0.01/Arte_Cart%C3%83%C2%B5es.webp', fit: BoxFit.fill, ), ), Divider(), Container( height: 150, child: Row( children: [ AspectRatio( aspectRatio: 1, child: Image.network( 'https://static.wixstatic.com/media/d170e1_486dd638987b4ef48d12a4bafee20e80~mv2.png/v1/fill/w_684,h_547,al_c,q_90,usm_0.66_1.00_0.01/Arte_Cart%C3%83%C2%B5es_2.webp', fit: BoxFit.fill, ), ), Padding( padding: const EdgeInsets.only(left:20.0), child: RichText( text: TextSpan(children: <TextSpan>[ TextSpan( text: 'Adquira já o seu', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, color: Colors.black, ), ), TextSpan( text: '\n\CARTÃO PRÓ VANTAGENS', style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, color: Color.fromARGB(255, 30, 158, 8)), ), ]), ), ), ], ), ), Divider(), tableBeneficios(), Divider(), Padding( padding: const EdgeInsets.all(16.0), child: Column( children: [ Text( 'O cartão Pró-Vantagens é sediado na cidade de Hortolândia/SP e já está no mercado há mais de 3 anos. Somos um time de profissionais apaixonados por gestão de benefícios e empenhados em gerar o máximo de valor para os conveniados.'), FlatButton( onPressed: () { launch( 'https://www.youtube.com/watch?v=VFnDo3JUzjs'); }, child: Text('SAIBA MAIS')), ], ), ), Container( color: Color.fromARGB(255, 105, 190, 90), child: Column( children: <Widget>[ Row( children: [ Padding( padding: const EdgeInsets.all(16), child: Text( '© 2020 todos os direitos reservados a Cartão Pró Vantagens.', style: TextStyle(fontSize: 10), ), ) ], ), Divider(), Row( children: [ Padding( padding: const EdgeInsets.all(16), child: Text( 'Rua Luís Camilo de Camargo, 175 -\n\Centro, Hortolândia (piso superior)', style: TextStyle(fontSize: 10), ), ), Padding( padding: const EdgeInsets.only(left: 16), child: IconButton( icon: Icon(CustomIcons.facebook), color: Colors.black, onPressed: () { launch( 'https://www.facebook.com/provantagens/'); }, ), ), Padding( padding: const EdgeInsets.only(left: 16), child: IconButton( icon: Icon(CustomIcons.instagram), color: Colors.black, onPressed: () { launch( 'https://www.instagram.com/cartaoprovantagens/'); }, ), ), ], ), ], ), ) ], ), ]); }, ) ), ); } tableBeneficios() { return Table( defaultColumnWidth: FlexColumnWidth(120.0), border: TableBorder( horizontalInside: BorderSide( color: Colors.black, style: BorderStyle.solid, width: 1.0, ), verticalInside: BorderSide( color: Colors.black, style: BorderStyle.solid, width: 1.0, ), ), children: [ _criarTituloTable(",Plus, Premium"), _criarLinhaTable("Seguro de vida\n\(Morte Acidental),X,X"), _criarLinhaTable("Seguro de Vida\n\(Qualquer natureza),,X"), _criarLinhaTable("Invalidez Total e Parcial,X,X"), _criarLinhaTable("Assistência Residencial,X,X"), _criarLinhaTable("Assistência Funeral,X,X"), _criarLinhaTable("Assistência Pet,X,X"), _criarLinhaTable("Assistência Natalidade,X,X"), _criarLinhaTable("Assistência Eletroassist,X,X"), _criarLinhaTable("Assistência Alimentação,X,X"), _criarLinhaTable("Descontos em Parceiros,X,X"), ], ); } _criarLinhaTable(String listaNomes) { return TableRow( children: listaNomes.split(',').map((name) { return Container( alignment: Alignment.center, child: RichText( text: TextSpan(children: <TextSpan>[ TextSpan( text: name != "X" ? '' : 'X', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, color: Colors.black, ), ), TextSpan( text: name != 'X' ? name : '', style: TextStyle( fontSize: 10.0, fontWeight: FontWeight.bold, color: Color.fromARGB(255, 30, 158, 8)), ), ]), ), padding: EdgeInsets.all(8.0), ); }).toList(), ); } _criarTituloTable(String listaNomes) { return TableRow( children: listaNomes.split(',').map((name) { return Container( alignment: Alignment.center, child: RichText( text: TextSpan(children: <TextSpan>[ TextSpan( text: name == "" ? '' : 'Plano ', style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, color: Colors.black, ), ), TextSpan( text: name, style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, color: Color.fromARGB(255, 30, 158, 8)), ), ]), ), padding: EdgeInsets.all(8.0), ); }).toList(), ); } void _storePosition(TapDownDetails details) { _tapPosition = details.globalPosition; } } ```
2020/11/13
[ "https://Stackoverflow.com/questions/64822800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14632998/" ]
I forked the library to create a custom carousel for my company's project, and since we updated flutter to 2.x we had the same problem. To fix this just update boolean expressions like ``` if(carouselState.pageController.position.minScrollExtent == null || carouselState.pageController.position.maxScrollExtent == null){ ... } ``` to ``` if(!carouselState.pageController.position.hasContentDimensions){ ... } ``` [Here is flutter's github reference.](https://github.com/flutter/flutter/issues/66250)
This worked for me So I edited scrollposition.dart package from line 133 ``` @override //double get minScrollExtent => _minScrollExtent!; // double? _minScrollExtent; double get minScrollExtent { if (_minScrollExtent == null) { _minScrollExtent = 0.0; } return double.parse(_minScrollExtent.toString()); } double? _minScrollExtent; @override // double get maxScrollExtent => _maxScrollExtent!; // double? _maxScrollExtent; double get maxScrollExtent { if (_maxScrollExtent == null) { _maxScrollExtent = 0.0; } return double.parse(_maxScrollExtent.toString()); } double? _maxScrollExtent; ```
64,822,800
Good Morning, I'm trying to put a Carousel on the home page looking for Firebase data, but for some reason, the first time I load the application it appears the message below: ``` ════════ Exception caught by widgets library ═════════════════════════════════════ ══════════════════ The following _CastError was thrown building DotsIndicator (animation: PageController # 734f9 (one client, offset 0.0), dirty, state: _AnimatedState # 636ca): Null check operator used on a null value ``` and the screen looks like this: [![Screen Fail](https://i.stack.imgur.com/dntBE.jpg)](https://i.stack.imgur.com/dntBE.jpg) After giving a hot reload the error continues to appear, but the image is loaded successfully, any tips of what I can do? [![Screen Ok](https://i.stack.imgur.com/ILvCb.jpg)](https://i.stack.imgur.com/ILvCb.jpg) HomeManager: ``` import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provantagens_app/models/section.dart'; class HomeManager extends ChangeNotifier{ HomeManager({this.images}){ _loadSections(); images = images ?? []; } void addSection(Section section){ _editingSections.add(section); notifyListeners(); } final List<dynamic> _sections = []; List<String> images; List<dynamic> newImages; List<dynamic> _editingSections = []; bool editing = false; bool loading = false; int index, totalItems; final Firestore firestore = Firestore.instance; Future<void> _loadSections() async{ loading = true; firestore.collection('home').snapshots().listen((snapshot){ _sections.clear(); for(final DocumentSnapshot document in snapshot.documents){ _sections.add( Section.fromDocument(document)); images = List<String>.from(document.data['images'] as List<dynamic>); } }); loading = false; notifyListeners(); } List<dynamic> get sections { if(editing) return _editingSections; else return _sections; } void enterEditing({Section section}){ editing = true; _editingSections = _sections.map((s) => s.clone()).toList(); defineIndex(section: section); notifyListeners(); } void saveEditing() async{ bool valid = true; for(final section in _editingSections){ if(!section.valid()) valid = false; } if(!valid) return; loading = true; notifyListeners(); for(final section in _editingSections){ await section.save(); } for(final section in List.from(_sections)){ if(!_editingSections.any((s) => s.id == section.id)){ await section.delete(); } } loading = false; editing = false; notifyListeners(); } void discardEditing(){ editing = false; notifyListeners(); } void removeSection(Section section){ _editingSections.remove(section); notifyListeners(); } void onMoveUp(Section section){ int index = _editingSections.indexOf(section); if(index != 0) { _editingSections.remove(section); _editingSections.insert(index - 1, section); index = _editingSections.indexOf(section); } notifyListeners(); } HomeManager clone(){ return HomeManager( images: List.from(images), ); } void onMoveDown(Section section){ index = _editingSections.indexOf(section); totalItems = _editingSections.length; if(index < totalItems - 1){ _editingSections.remove(section); _editingSections.insert(index + 1, section); index = _editingSections.indexOf(section); }else{ } notifyListeners(); } void defineIndex({Section section}){ index = _editingSections.indexOf(section); totalItems = _editingSections.length; notifyListeners(); } } ``` HomeScreen: ``` import 'package:carousel_pro/carousel_pro.dart'; import 'package:flutter/material.dart'; import 'package:provantagens_app/commom/custom_drawer.dart'; import 'package:provantagens_app/commom/custom_icons_icons.dart'; import 'package:provantagens_app/models/home_manager.dart'; import 'package:provantagens_app/models/section.dart'; import 'package:provantagens_app/screens/home/components/home_carousel.dart'; import 'package:provantagens_app/screens/home/components/menu_icon_tile.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; // ignore: must_be_immutable class HomeScreen extends StatelessWidget { HomeManager homeManager; Section section; List<Widget> get children => null; String videoUrl = 'https://www.youtube.com/watch?v=VFnDo3JUzjs'; int index; var _tapPosition; @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration( gradient: LinearGradient(colors: const [ Colors.white, Colors.white, ], begin: Alignment.topCenter, end: Alignment.bottomCenter)), child: Scaffold( backgroundColor: Colors.transparent, drawer: CustomDrawer(), appBar: AppBar( backgroundColor: Colors.transparent, iconTheme: IconThemeData(color: Colors.black), title: Text('Página inicial', style: TextStyle(color: Color.fromARGB(255, 30, 158, 8))), centerTitle: true, actions: <Widget>[ Divider(), ], ), body: Consumer<HomeManager>( builder: (_, homeManager, __){ return ListView(children: <Widget>[ AspectRatio( aspectRatio: 1, child:HomeCarousel(homeManager), ), Column( children: <Widget>[ Container( height: 50, ), Divider( color: Colors.black, ), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Padding( padding: const EdgeInsets.only(left:12.0), child: MenuIconTile(title: 'Parceiros', iconData: Icons.apartment, page: 1,), ), Padding( padding: const EdgeInsets.only(left:7.0), child: MenuIconTile(title: 'Beneficios', iconData: Icons.card_giftcard, page: 2,), ), Padding( padding: const EdgeInsets.only(right:3.0), child: MenuIconTile(title: 'Suporte', iconData: Icons.help_outline, page: 6,), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ MenuIconTile(iconData: Icons.assignment, title: 'Dados pessoais', page: 3) , MenuIconTile(iconData: Icons.credit_card_outlined, title: 'Meu cartão', page: 4) , MenuIconTile(iconData: Icons.account_balance_wallet_outlined, title: 'Pagamento', page: 5,) , ], ), Divider( color: Colors.black, ), Container( height: 50, ), Consumer<HomeManager>( builder: (_, sec, __){ return RaisedButton( child: Text('Teste'), onPressed: (){ Navigator.of(context) .pushReplacementNamed('/teste', arguments: sec); }, ); }, ), Text('Saiba onde usar o seu', style: TextStyle(color: Colors.black, fontSize: 20),), Text('Cartão Pró Vantagens', style: TextStyle(color: Color.fromARGB(255, 30, 158, 8), fontSize: 30),), AspectRatio( aspectRatio: 1, child: Image.network( 'https://static.wixstatic.com/media/d170e1_80b5f6510f5841c19046f1ed5bca71e4~mv2.png/v1/fill/w_745,h_595,al_c,q_90,usm_0.66_1.00_0.01/Arte_Cart%C3%83%C2%B5es.webp', fit: BoxFit.fill, ), ), Divider(), Container( height: 150, child: Row( children: [ AspectRatio( aspectRatio: 1, child: Image.network( 'https://static.wixstatic.com/media/d170e1_486dd638987b4ef48d12a4bafee20e80~mv2.png/v1/fill/w_684,h_547,al_c,q_90,usm_0.66_1.00_0.01/Arte_Cart%C3%83%C2%B5es_2.webp', fit: BoxFit.fill, ), ), Padding( padding: const EdgeInsets.only(left:20.0), child: RichText( text: TextSpan(children: <TextSpan>[ TextSpan( text: 'Adquira já o seu', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, color: Colors.black, ), ), TextSpan( text: '\n\CARTÃO PRÓ VANTAGENS', style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, color: Color.fromARGB(255, 30, 158, 8)), ), ]), ), ), ], ), ), Divider(), tableBeneficios(), Divider(), Padding( padding: const EdgeInsets.all(16.0), child: Column( children: [ Text( 'O cartão Pró-Vantagens é sediado na cidade de Hortolândia/SP e já está no mercado há mais de 3 anos. Somos um time de profissionais apaixonados por gestão de benefícios e empenhados em gerar o máximo de valor para os conveniados.'), FlatButton( onPressed: () { launch( 'https://www.youtube.com/watch?v=VFnDo3JUzjs'); }, child: Text('SAIBA MAIS')), ], ), ), Container( color: Color.fromARGB(255, 105, 190, 90), child: Column( children: <Widget>[ Row( children: [ Padding( padding: const EdgeInsets.all(16), child: Text( '© 2020 todos os direitos reservados a Cartão Pró Vantagens.', style: TextStyle(fontSize: 10), ), ) ], ), Divider(), Row( children: [ Padding( padding: const EdgeInsets.all(16), child: Text( 'Rua Luís Camilo de Camargo, 175 -\n\Centro, Hortolândia (piso superior)', style: TextStyle(fontSize: 10), ), ), Padding( padding: const EdgeInsets.only(left: 16), child: IconButton( icon: Icon(CustomIcons.facebook), color: Colors.black, onPressed: () { launch( 'https://www.facebook.com/provantagens/'); }, ), ), Padding( padding: const EdgeInsets.only(left: 16), child: IconButton( icon: Icon(CustomIcons.instagram), color: Colors.black, onPressed: () { launch( 'https://www.instagram.com/cartaoprovantagens/'); }, ), ), ], ), ], ), ) ], ), ]); }, ) ), ); } tableBeneficios() { return Table( defaultColumnWidth: FlexColumnWidth(120.0), border: TableBorder( horizontalInside: BorderSide( color: Colors.black, style: BorderStyle.solid, width: 1.0, ), verticalInside: BorderSide( color: Colors.black, style: BorderStyle.solid, width: 1.0, ), ), children: [ _criarTituloTable(",Plus, Premium"), _criarLinhaTable("Seguro de vida\n\(Morte Acidental),X,X"), _criarLinhaTable("Seguro de Vida\n\(Qualquer natureza),,X"), _criarLinhaTable("Invalidez Total e Parcial,X,X"), _criarLinhaTable("Assistência Residencial,X,X"), _criarLinhaTable("Assistência Funeral,X,X"), _criarLinhaTable("Assistência Pet,X,X"), _criarLinhaTable("Assistência Natalidade,X,X"), _criarLinhaTable("Assistência Eletroassist,X,X"), _criarLinhaTable("Assistência Alimentação,X,X"), _criarLinhaTable("Descontos em Parceiros,X,X"), ], ); } _criarLinhaTable(String listaNomes) { return TableRow( children: listaNomes.split(',').map((name) { return Container( alignment: Alignment.center, child: RichText( text: TextSpan(children: <TextSpan>[ TextSpan( text: name != "X" ? '' : 'X', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, color: Colors.black, ), ), TextSpan( text: name != 'X' ? name : '', style: TextStyle( fontSize: 10.0, fontWeight: FontWeight.bold, color: Color.fromARGB(255, 30, 158, 8)), ), ]), ), padding: EdgeInsets.all(8.0), ); }).toList(), ); } _criarTituloTable(String listaNomes) { return TableRow( children: listaNomes.split(',').map((name) { return Container( alignment: Alignment.center, child: RichText( text: TextSpan(children: <TextSpan>[ TextSpan( text: name == "" ? '' : 'Plano ', style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, color: Colors.black, ), ), TextSpan( text: name, style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, color: Color.fromARGB(255, 30, 158, 8)), ), ]), ), padding: EdgeInsets.all(8.0), ); }).toList(), ); } void _storePosition(TapDownDetails details) { _tapPosition = details.globalPosition; } } ```
2020/11/13
[ "https://Stackoverflow.com/questions/64822800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14632998/" ]
I forked the library to create a custom carousel for my company's project, and since we updated flutter to 2.x we had the same problem. To fix this just update boolean expressions like ``` if(carouselState.pageController.position.minScrollExtent == null || carouselState.pageController.position.maxScrollExtent == null){ ... } ``` to ``` if(!carouselState.pageController.position.hasContentDimensions){ ... } ``` [Here is flutter's github reference.](https://github.com/flutter/flutter/issues/66250)
I faced the same issue. This is how I solved it ``` class PlansPage extends StatefulWidget { const PlansPage({Key? key}) : super(key: key); @override State<PlansPage> createState() => _PlansPageState(); } class _PlansPageState extends State<PlansPage> { int _currentPage = 1; late CarouselController carouselController; @override void initState() { super.initState(); carouselController = CarouselController(); } } ``` Then put initialization the carouselController inside the initState method I was able to use the methods jumpToPage(\_currentPage ) and animateToPage(\_currentPage) etc. I use animateToPage inside GestureDetector in onTap. ``` onTap: () { setState(() { _currentPage = pageIndex; }); carouselController.animateToPage(_currentPage); }, ``` I apologize in advance if this is inappropriate.
64,822,800
Good Morning, I'm trying to put a Carousel on the home page looking for Firebase data, but for some reason, the first time I load the application it appears the message below: ``` ════════ Exception caught by widgets library ═════════════════════════════════════ ══════════════════ The following _CastError was thrown building DotsIndicator (animation: PageController # 734f9 (one client, offset 0.0), dirty, state: _AnimatedState # 636ca): Null check operator used on a null value ``` and the screen looks like this: [![Screen Fail](https://i.stack.imgur.com/dntBE.jpg)](https://i.stack.imgur.com/dntBE.jpg) After giving a hot reload the error continues to appear, but the image is loaded successfully, any tips of what I can do? [![Screen Ok](https://i.stack.imgur.com/ILvCb.jpg)](https://i.stack.imgur.com/ILvCb.jpg) HomeManager: ``` import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provantagens_app/models/section.dart'; class HomeManager extends ChangeNotifier{ HomeManager({this.images}){ _loadSections(); images = images ?? []; } void addSection(Section section){ _editingSections.add(section); notifyListeners(); } final List<dynamic> _sections = []; List<String> images; List<dynamic> newImages; List<dynamic> _editingSections = []; bool editing = false; bool loading = false; int index, totalItems; final Firestore firestore = Firestore.instance; Future<void> _loadSections() async{ loading = true; firestore.collection('home').snapshots().listen((snapshot){ _sections.clear(); for(final DocumentSnapshot document in snapshot.documents){ _sections.add( Section.fromDocument(document)); images = List<String>.from(document.data['images'] as List<dynamic>); } }); loading = false; notifyListeners(); } List<dynamic> get sections { if(editing) return _editingSections; else return _sections; } void enterEditing({Section section}){ editing = true; _editingSections = _sections.map((s) => s.clone()).toList(); defineIndex(section: section); notifyListeners(); } void saveEditing() async{ bool valid = true; for(final section in _editingSections){ if(!section.valid()) valid = false; } if(!valid) return; loading = true; notifyListeners(); for(final section in _editingSections){ await section.save(); } for(final section in List.from(_sections)){ if(!_editingSections.any((s) => s.id == section.id)){ await section.delete(); } } loading = false; editing = false; notifyListeners(); } void discardEditing(){ editing = false; notifyListeners(); } void removeSection(Section section){ _editingSections.remove(section); notifyListeners(); } void onMoveUp(Section section){ int index = _editingSections.indexOf(section); if(index != 0) { _editingSections.remove(section); _editingSections.insert(index - 1, section); index = _editingSections.indexOf(section); } notifyListeners(); } HomeManager clone(){ return HomeManager( images: List.from(images), ); } void onMoveDown(Section section){ index = _editingSections.indexOf(section); totalItems = _editingSections.length; if(index < totalItems - 1){ _editingSections.remove(section); _editingSections.insert(index + 1, section); index = _editingSections.indexOf(section); }else{ } notifyListeners(); } void defineIndex({Section section}){ index = _editingSections.indexOf(section); totalItems = _editingSections.length; notifyListeners(); } } ``` HomeScreen: ``` import 'package:carousel_pro/carousel_pro.dart'; import 'package:flutter/material.dart'; import 'package:provantagens_app/commom/custom_drawer.dart'; import 'package:provantagens_app/commom/custom_icons_icons.dart'; import 'package:provantagens_app/models/home_manager.dart'; import 'package:provantagens_app/models/section.dart'; import 'package:provantagens_app/screens/home/components/home_carousel.dart'; import 'package:provantagens_app/screens/home/components/menu_icon_tile.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; // ignore: must_be_immutable class HomeScreen extends StatelessWidget { HomeManager homeManager; Section section; List<Widget> get children => null; String videoUrl = 'https://www.youtube.com/watch?v=VFnDo3JUzjs'; int index; var _tapPosition; @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration( gradient: LinearGradient(colors: const [ Colors.white, Colors.white, ], begin: Alignment.topCenter, end: Alignment.bottomCenter)), child: Scaffold( backgroundColor: Colors.transparent, drawer: CustomDrawer(), appBar: AppBar( backgroundColor: Colors.transparent, iconTheme: IconThemeData(color: Colors.black), title: Text('Página inicial', style: TextStyle(color: Color.fromARGB(255, 30, 158, 8))), centerTitle: true, actions: <Widget>[ Divider(), ], ), body: Consumer<HomeManager>( builder: (_, homeManager, __){ return ListView(children: <Widget>[ AspectRatio( aspectRatio: 1, child:HomeCarousel(homeManager), ), Column( children: <Widget>[ Container( height: 50, ), Divider( color: Colors.black, ), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Padding( padding: const EdgeInsets.only(left:12.0), child: MenuIconTile(title: 'Parceiros', iconData: Icons.apartment, page: 1,), ), Padding( padding: const EdgeInsets.only(left:7.0), child: MenuIconTile(title: 'Beneficios', iconData: Icons.card_giftcard, page: 2,), ), Padding( padding: const EdgeInsets.only(right:3.0), child: MenuIconTile(title: 'Suporte', iconData: Icons.help_outline, page: 6,), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ MenuIconTile(iconData: Icons.assignment, title: 'Dados pessoais', page: 3) , MenuIconTile(iconData: Icons.credit_card_outlined, title: 'Meu cartão', page: 4) , MenuIconTile(iconData: Icons.account_balance_wallet_outlined, title: 'Pagamento', page: 5,) , ], ), Divider( color: Colors.black, ), Container( height: 50, ), Consumer<HomeManager>( builder: (_, sec, __){ return RaisedButton( child: Text('Teste'), onPressed: (){ Navigator.of(context) .pushReplacementNamed('/teste', arguments: sec); }, ); }, ), Text('Saiba onde usar o seu', style: TextStyle(color: Colors.black, fontSize: 20),), Text('Cartão Pró Vantagens', style: TextStyle(color: Color.fromARGB(255, 30, 158, 8), fontSize: 30),), AspectRatio( aspectRatio: 1, child: Image.network( 'https://static.wixstatic.com/media/d170e1_80b5f6510f5841c19046f1ed5bca71e4~mv2.png/v1/fill/w_745,h_595,al_c,q_90,usm_0.66_1.00_0.01/Arte_Cart%C3%83%C2%B5es.webp', fit: BoxFit.fill, ), ), Divider(), Container( height: 150, child: Row( children: [ AspectRatio( aspectRatio: 1, child: Image.network( 'https://static.wixstatic.com/media/d170e1_486dd638987b4ef48d12a4bafee20e80~mv2.png/v1/fill/w_684,h_547,al_c,q_90,usm_0.66_1.00_0.01/Arte_Cart%C3%83%C2%B5es_2.webp', fit: BoxFit.fill, ), ), Padding( padding: const EdgeInsets.only(left:20.0), child: RichText( text: TextSpan(children: <TextSpan>[ TextSpan( text: 'Adquira já o seu', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, color: Colors.black, ), ), TextSpan( text: '\n\CARTÃO PRÓ VANTAGENS', style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, color: Color.fromARGB(255, 30, 158, 8)), ), ]), ), ), ], ), ), Divider(), tableBeneficios(), Divider(), Padding( padding: const EdgeInsets.all(16.0), child: Column( children: [ Text( 'O cartão Pró-Vantagens é sediado na cidade de Hortolândia/SP e já está no mercado há mais de 3 anos. Somos um time de profissionais apaixonados por gestão de benefícios e empenhados em gerar o máximo de valor para os conveniados.'), FlatButton( onPressed: () { launch( 'https://www.youtube.com/watch?v=VFnDo3JUzjs'); }, child: Text('SAIBA MAIS')), ], ), ), Container( color: Color.fromARGB(255, 105, 190, 90), child: Column( children: <Widget>[ Row( children: [ Padding( padding: const EdgeInsets.all(16), child: Text( '© 2020 todos os direitos reservados a Cartão Pró Vantagens.', style: TextStyle(fontSize: 10), ), ) ], ), Divider(), Row( children: [ Padding( padding: const EdgeInsets.all(16), child: Text( 'Rua Luís Camilo de Camargo, 175 -\n\Centro, Hortolândia (piso superior)', style: TextStyle(fontSize: 10), ), ), Padding( padding: const EdgeInsets.only(left: 16), child: IconButton( icon: Icon(CustomIcons.facebook), color: Colors.black, onPressed: () { launch( 'https://www.facebook.com/provantagens/'); }, ), ), Padding( padding: const EdgeInsets.only(left: 16), child: IconButton( icon: Icon(CustomIcons.instagram), color: Colors.black, onPressed: () { launch( 'https://www.instagram.com/cartaoprovantagens/'); }, ), ), ], ), ], ), ) ], ), ]); }, ) ), ); } tableBeneficios() { return Table( defaultColumnWidth: FlexColumnWidth(120.0), border: TableBorder( horizontalInside: BorderSide( color: Colors.black, style: BorderStyle.solid, width: 1.0, ), verticalInside: BorderSide( color: Colors.black, style: BorderStyle.solid, width: 1.0, ), ), children: [ _criarTituloTable(",Plus, Premium"), _criarLinhaTable("Seguro de vida\n\(Morte Acidental),X,X"), _criarLinhaTable("Seguro de Vida\n\(Qualquer natureza),,X"), _criarLinhaTable("Invalidez Total e Parcial,X,X"), _criarLinhaTable("Assistência Residencial,X,X"), _criarLinhaTable("Assistência Funeral,X,X"), _criarLinhaTable("Assistência Pet,X,X"), _criarLinhaTable("Assistência Natalidade,X,X"), _criarLinhaTable("Assistência Eletroassist,X,X"), _criarLinhaTable("Assistência Alimentação,X,X"), _criarLinhaTable("Descontos em Parceiros,X,X"), ], ); } _criarLinhaTable(String listaNomes) { return TableRow( children: listaNomes.split(',').map((name) { return Container( alignment: Alignment.center, child: RichText( text: TextSpan(children: <TextSpan>[ TextSpan( text: name != "X" ? '' : 'X', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, color: Colors.black, ), ), TextSpan( text: name != 'X' ? name : '', style: TextStyle( fontSize: 10.0, fontWeight: FontWeight.bold, color: Color.fromARGB(255, 30, 158, 8)), ), ]), ), padding: EdgeInsets.all(8.0), ); }).toList(), ); } _criarTituloTable(String listaNomes) { return TableRow( children: listaNomes.split(',').map((name) { return Container( alignment: Alignment.center, child: RichText( text: TextSpan(children: <TextSpan>[ TextSpan( text: name == "" ? '' : 'Plano ', style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, color: Colors.black, ), ), TextSpan( text: name, style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, color: Color.fromARGB(255, 30, 158, 8)), ), ]), ), padding: EdgeInsets.all(8.0), ); }).toList(), ); } void _storePosition(TapDownDetails details) { _tapPosition = details.globalPosition; } } ```
2020/11/13
[ "https://Stackoverflow.com/questions/64822800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14632998/" ]
Just upgrade to `^3.0.0` Check here <https://pub.dev/packages/carousel_slider>
I solved the similar problem as follows. You can take advantage of the Boolean variable. I hope, help you. ``` child: !loading ? HomeCarousel(homeManager) : Center(child:ProgressIndicator()), ``` or ``` child: isLoading ? HomeCarousel(homeManager) : SplashScreen(), ``` ``` class SplashScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Text('Loading...') ), ); } } ```
64,822,800
Good Morning, I'm trying to put a Carousel on the home page looking for Firebase data, but for some reason, the first time I load the application it appears the message below: ``` ════════ Exception caught by widgets library ═════════════════════════════════════ ══════════════════ The following _CastError was thrown building DotsIndicator (animation: PageController # 734f9 (one client, offset 0.0), dirty, state: _AnimatedState # 636ca): Null check operator used on a null value ``` and the screen looks like this: [![Screen Fail](https://i.stack.imgur.com/dntBE.jpg)](https://i.stack.imgur.com/dntBE.jpg) After giving a hot reload the error continues to appear, but the image is loaded successfully, any tips of what I can do? [![Screen Ok](https://i.stack.imgur.com/ILvCb.jpg)](https://i.stack.imgur.com/ILvCb.jpg) HomeManager: ``` import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provantagens_app/models/section.dart'; class HomeManager extends ChangeNotifier{ HomeManager({this.images}){ _loadSections(); images = images ?? []; } void addSection(Section section){ _editingSections.add(section); notifyListeners(); } final List<dynamic> _sections = []; List<String> images; List<dynamic> newImages; List<dynamic> _editingSections = []; bool editing = false; bool loading = false; int index, totalItems; final Firestore firestore = Firestore.instance; Future<void> _loadSections() async{ loading = true; firestore.collection('home').snapshots().listen((snapshot){ _sections.clear(); for(final DocumentSnapshot document in snapshot.documents){ _sections.add( Section.fromDocument(document)); images = List<String>.from(document.data['images'] as List<dynamic>); } }); loading = false; notifyListeners(); } List<dynamic> get sections { if(editing) return _editingSections; else return _sections; } void enterEditing({Section section}){ editing = true; _editingSections = _sections.map((s) => s.clone()).toList(); defineIndex(section: section); notifyListeners(); } void saveEditing() async{ bool valid = true; for(final section in _editingSections){ if(!section.valid()) valid = false; } if(!valid) return; loading = true; notifyListeners(); for(final section in _editingSections){ await section.save(); } for(final section in List.from(_sections)){ if(!_editingSections.any((s) => s.id == section.id)){ await section.delete(); } } loading = false; editing = false; notifyListeners(); } void discardEditing(){ editing = false; notifyListeners(); } void removeSection(Section section){ _editingSections.remove(section); notifyListeners(); } void onMoveUp(Section section){ int index = _editingSections.indexOf(section); if(index != 0) { _editingSections.remove(section); _editingSections.insert(index - 1, section); index = _editingSections.indexOf(section); } notifyListeners(); } HomeManager clone(){ return HomeManager( images: List.from(images), ); } void onMoveDown(Section section){ index = _editingSections.indexOf(section); totalItems = _editingSections.length; if(index < totalItems - 1){ _editingSections.remove(section); _editingSections.insert(index + 1, section); index = _editingSections.indexOf(section); }else{ } notifyListeners(); } void defineIndex({Section section}){ index = _editingSections.indexOf(section); totalItems = _editingSections.length; notifyListeners(); } } ``` HomeScreen: ``` import 'package:carousel_pro/carousel_pro.dart'; import 'package:flutter/material.dart'; import 'package:provantagens_app/commom/custom_drawer.dart'; import 'package:provantagens_app/commom/custom_icons_icons.dart'; import 'package:provantagens_app/models/home_manager.dart'; import 'package:provantagens_app/models/section.dart'; import 'package:provantagens_app/screens/home/components/home_carousel.dart'; import 'package:provantagens_app/screens/home/components/menu_icon_tile.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; // ignore: must_be_immutable class HomeScreen extends StatelessWidget { HomeManager homeManager; Section section; List<Widget> get children => null; String videoUrl = 'https://www.youtube.com/watch?v=VFnDo3JUzjs'; int index; var _tapPosition; @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration( gradient: LinearGradient(colors: const [ Colors.white, Colors.white, ], begin: Alignment.topCenter, end: Alignment.bottomCenter)), child: Scaffold( backgroundColor: Colors.transparent, drawer: CustomDrawer(), appBar: AppBar( backgroundColor: Colors.transparent, iconTheme: IconThemeData(color: Colors.black), title: Text('Página inicial', style: TextStyle(color: Color.fromARGB(255, 30, 158, 8))), centerTitle: true, actions: <Widget>[ Divider(), ], ), body: Consumer<HomeManager>( builder: (_, homeManager, __){ return ListView(children: <Widget>[ AspectRatio( aspectRatio: 1, child:HomeCarousel(homeManager), ), Column( children: <Widget>[ Container( height: 50, ), Divider( color: Colors.black, ), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Padding( padding: const EdgeInsets.only(left:12.0), child: MenuIconTile(title: 'Parceiros', iconData: Icons.apartment, page: 1,), ), Padding( padding: const EdgeInsets.only(left:7.0), child: MenuIconTile(title: 'Beneficios', iconData: Icons.card_giftcard, page: 2,), ), Padding( padding: const EdgeInsets.only(right:3.0), child: MenuIconTile(title: 'Suporte', iconData: Icons.help_outline, page: 6,), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ MenuIconTile(iconData: Icons.assignment, title: 'Dados pessoais', page: 3) , MenuIconTile(iconData: Icons.credit_card_outlined, title: 'Meu cartão', page: 4) , MenuIconTile(iconData: Icons.account_balance_wallet_outlined, title: 'Pagamento', page: 5,) , ], ), Divider( color: Colors.black, ), Container( height: 50, ), Consumer<HomeManager>( builder: (_, sec, __){ return RaisedButton( child: Text('Teste'), onPressed: (){ Navigator.of(context) .pushReplacementNamed('/teste', arguments: sec); }, ); }, ), Text('Saiba onde usar o seu', style: TextStyle(color: Colors.black, fontSize: 20),), Text('Cartão Pró Vantagens', style: TextStyle(color: Color.fromARGB(255, 30, 158, 8), fontSize: 30),), AspectRatio( aspectRatio: 1, child: Image.network( 'https://static.wixstatic.com/media/d170e1_80b5f6510f5841c19046f1ed5bca71e4~mv2.png/v1/fill/w_745,h_595,al_c,q_90,usm_0.66_1.00_0.01/Arte_Cart%C3%83%C2%B5es.webp', fit: BoxFit.fill, ), ), Divider(), Container( height: 150, child: Row( children: [ AspectRatio( aspectRatio: 1, child: Image.network( 'https://static.wixstatic.com/media/d170e1_486dd638987b4ef48d12a4bafee20e80~mv2.png/v1/fill/w_684,h_547,al_c,q_90,usm_0.66_1.00_0.01/Arte_Cart%C3%83%C2%B5es_2.webp', fit: BoxFit.fill, ), ), Padding( padding: const EdgeInsets.only(left:20.0), child: RichText( text: TextSpan(children: <TextSpan>[ TextSpan( text: 'Adquira já o seu', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, color: Colors.black, ), ), TextSpan( text: '\n\CARTÃO PRÓ VANTAGENS', style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, color: Color.fromARGB(255, 30, 158, 8)), ), ]), ), ), ], ), ), Divider(), tableBeneficios(), Divider(), Padding( padding: const EdgeInsets.all(16.0), child: Column( children: [ Text( 'O cartão Pró-Vantagens é sediado na cidade de Hortolândia/SP e já está no mercado há mais de 3 anos. Somos um time de profissionais apaixonados por gestão de benefícios e empenhados em gerar o máximo de valor para os conveniados.'), FlatButton( onPressed: () { launch( 'https://www.youtube.com/watch?v=VFnDo3JUzjs'); }, child: Text('SAIBA MAIS')), ], ), ), Container( color: Color.fromARGB(255, 105, 190, 90), child: Column( children: <Widget>[ Row( children: [ Padding( padding: const EdgeInsets.all(16), child: Text( '© 2020 todos os direitos reservados a Cartão Pró Vantagens.', style: TextStyle(fontSize: 10), ), ) ], ), Divider(), Row( children: [ Padding( padding: const EdgeInsets.all(16), child: Text( 'Rua Luís Camilo de Camargo, 175 -\n\Centro, Hortolândia (piso superior)', style: TextStyle(fontSize: 10), ), ), Padding( padding: const EdgeInsets.only(left: 16), child: IconButton( icon: Icon(CustomIcons.facebook), color: Colors.black, onPressed: () { launch( 'https://www.facebook.com/provantagens/'); }, ), ), Padding( padding: const EdgeInsets.only(left: 16), child: IconButton( icon: Icon(CustomIcons.instagram), color: Colors.black, onPressed: () { launch( 'https://www.instagram.com/cartaoprovantagens/'); }, ), ), ], ), ], ), ) ], ), ]); }, ) ), ); } tableBeneficios() { return Table( defaultColumnWidth: FlexColumnWidth(120.0), border: TableBorder( horizontalInside: BorderSide( color: Colors.black, style: BorderStyle.solid, width: 1.0, ), verticalInside: BorderSide( color: Colors.black, style: BorderStyle.solid, width: 1.0, ), ), children: [ _criarTituloTable(",Plus, Premium"), _criarLinhaTable("Seguro de vida\n\(Morte Acidental),X,X"), _criarLinhaTable("Seguro de Vida\n\(Qualquer natureza),,X"), _criarLinhaTable("Invalidez Total e Parcial,X,X"), _criarLinhaTable("Assistência Residencial,X,X"), _criarLinhaTable("Assistência Funeral,X,X"), _criarLinhaTable("Assistência Pet,X,X"), _criarLinhaTable("Assistência Natalidade,X,X"), _criarLinhaTable("Assistência Eletroassist,X,X"), _criarLinhaTable("Assistência Alimentação,X,X"), _criarLinhaTable("Descontos em Parceiros,X,X"), ], ); } _criarLinhaTable(String listaNomes) { return TableRow( children: listaNomes.split(',').map((name) { return Container( alignment: Alignment.center, child: RichText( text: TextSpan(children: <TextSpan>[ TextSpan( text: name != "X" ? '' : 'X', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, color: Colors.black, ), ), TextSpan( text: name != 'X' ? name : '', style: TextStyle( fontSize: 10.0, fontWeight: FontWeight.bold, color: Color.fromARGB(255, 30, 158, 8)), ), ]), ), padding: EdgeInsets.all(8.0), ); }).toList(), ); } _criarTituloTable(String listaNomes) { return TableRow( children: listaNomes.split(',').map((name) { return Container( alignment: Alignment.center, child: RichText( text: TextSpan(children: <TextSpan>[ TextSpan( text: name == "" ? '' : 'Plano ', style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, color: Colors.black, ), ), TextSpan( text: name, style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, color: Color.fromARGB(255, 30, 158, 8)), ), ]), ), padding: EdgeInsets.all(8.0), ); }).toList(), ); } void _storePosition(TapDownDetails details) { _tapPosition = details.globalPosition; } } ```
2020/11/13
[ "https://Stackoverflow.com/questions/64822800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14632998/" ]
This worked for me So I edited scrollposition.dart package from line 133 ``` @override //double get minScrollExtent => _minScrollExtent!; // double? _minScrollExtent; double get minScrollExtent { if (_minScrollExtent == null) { _minScrollExtent = 0.0; } return double.parse(_minScrollExtent.toString()); } double? _minScrollExtent; @override // double get maxScrollExtent => _maxScrollExtent!; // double? _maxScrollExtent; double get maxScrollExtent { if (_maxScrollExtent == null) { _maxScrollExtent = 0.0; } return double.parse(_maxScrollExtent.toString()); } double? _maxScrollExtent; ```
I solved the similar problem as follows. You can take advantage of the Boolean variable. I hope, help you. ``` child: !loading ? HomeCarousel(homeManager) : Center(child:ProgressIndicator()), ``` or ``` child: isLoading ? HomeCarousel(homeManager) : SplashScreen(), ``` ``` class SplashScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Text('Loading...') ), ); } } ```
64,822,800
Good Morning, I'm trying to put a Carousel on the home page looking for Firebase data, but for some reason, the first time I load the application it appears the message below: ``` ════════ Exception caught by widgets library ═════════════════════════════════════ ══════════════════ The following _CastError was thrown building DotsIndicator (animation: PageController # 734f9 (one client, offset 0.0), dirty, state: _AnimatedState # 636ca): Null check operator used on a null value ``` and the screen looks like this: [![Screen Fail](https://i.stack.imgur.com/dntBE.jpg)](https://i.stack.imgur.com/dntBE.jpg) After giving a hot reload the error continues to appear, but the image is loaded successfully, any tips of what I can do? [![Screen Ok](https://i.stack.imgur.com/ILvCb.jpg)](https://i.stack.imgur.com/ILvCb.jpg) HomeManager: ``` import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provantagens_app/models/section.dart'; class HomeManager extends ChangeNotifier{ HomeManager({this.images}){ _loadSections(); images = images ?? []; } void addSection(Section section){ _editingSections.add(section); notifyListeners(); } final List<dynamic> _sections = []; List<String> images; List<dynamic> newImages; List<dynamic> _editingSections = []; bool editing = false; bool loading = false; int index, totalItems; final Firestore firestore = Firestore.instance; Future<void> _loadSections() async{ loading = true; firestore.collection('home').snapshots().listen((snapshot){ _sections.clear(); for(final DocumentSnapshot document in snapshot.documents){ _sections.add( Section.fromDocument(document)); images = List<String>.from(document.data['images'] as List<dynamic>); } }); loading = false; notifyListeners(); } List<dynamic> get sections { if(editing) return _editingSections; else return _sections; } void enterEditing({Section section}){ editing = true; _editingSections = _sections.map((s) => s.clone()).toList(); defineIndex(section: section); notifyListeners(); } void saveEditing() async{ bool valid = true; for(final section in _editingSections){ if(!section.valid()) valid = false; } if(!valid) return; loading = true; notifyListeners(); for(final section in _editingSections){ await section.save(); } for(final section in List.from(_sections)){ if(!_editingSections.any((s) => s.id == section.id)){ await section.delete(); } } loading = false; editing = false; notifyListeners(); } void discardEditing(){ editing = false; notifyListeners(); } void removeSection(Section section){ _editingSections.remove(section); notifyListeners(); } void onMoveUp(Section section){ int index = _editingSections.indexOf(section); if(index != 0) { _editingSections.remove(section); _editingSections.insert(index - 1, section); index = _editingSections.indexOf(section); } notifyListeners(); } HomeManager clone(){ return HomeManager( images: List.from(images), ); } void onMoveDown(Section section){ index = _editingSections.indexOf(section); totalItems = _editingSections.length; if(index < totalItems - 1){ _editingSections.remove(section); _editingSections.insert(index + 1, section); index = _editingSections.indexOf(section); }else{ } notifyListeners(); } void defineIndex({Section section}){ index = _editingSections.indexOf(section); totalItems = _editingSections.length; notifyListeners(); } } ``` HomeScreen: ``` import 'package:carousel_pro/carousel_pro.dart'; import 'package:flutter/material.dart'; import 'package:provantagens_app/commom/custom_drawer.dart'; import 'package:provantagens_app/commom/custom_icons_icons.dart'; import 'package:provantagens_app/models/home_manager.dart'; import 'package:provantagens_app/models/section.dart'; import 'package:provantagens_app/screens/home/components/home_carousel.dart'; import 'package:provantagens_app/screens/home/components/menu_icon_tile.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; // ignore: must_be_immutable class HomeScreen extends StatelessWidget { HomeManager homeManager; Section section; List<Widget> get children => null; String videoUrl = 'https://www.youtube.com/watch?v=VFnDo3JUzjs'; int index; var _tapPosition; @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration( gradient: LinearGradient(colors: const [ Colors.white, Colors.white, ], begin: Alignment.topCenter, end: Alignment.bottomCenter)), child: Scaffold( backgroundColor: Colors.transparent, drawer: CustomDrawer(), appBar: AppBar( backgroundColor: Colors.transparent, iconTheme: IconThemeData(color: Colors.black), title: Text('Página inicial', style: TextStyle(color: Color.fromARGB(255, 30, 158, 8))), centerTitle: true, actions: <Widget>[ Divider(), ], ), body: Consumer<HomeManager>( builder: (_, homeManager, __){ return ListView(children: <Widget>[ AspectRatio( aspectRatio: 1, child:HomeCarousel(homeManager), ), Column( children: <Widget>[ Container( height: 50, ), Divider( color: Colors.black, ), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Padding( padding: const EdgeInsets.only(left:12.0), child: MenuIconTile(title: 'Parceiros', iconData: Icons.apartment, page: 1,), ), Padding( padding: const EdgeInsets.only(left:7.0), child: MenuIconTile(title: 'Beneficios', iconData: Icons.card_giftcard, page: 2,), ), Padding( padding: const EdgeInsets.only(right:3.0), child: MenuIconTile(title: 'Suporte', iconData: Icons.help_outline, page: 6,), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ MenuIconTile(iconData: Icons.assignment, title: 'Dados pessoais', page: 3) , MenuIconTile(iconData: Icons.credit_card_outlined, title: 'Meu cartão', page: 4) , MenuIconTile(iconData: Icons.account_balance_wallet_outlined, title: 'Pagamento', page: 5,) , ], ), Divider( color: Colors.black, ), Container( height: 50, ), Consumer<HomeManager>( builder: (_, sec, __){ return RaisedButton( child: Text('Teste'), onPressed: (){ Navigator.of(context) .pushReplacementNamed('/teste', arguments: sec); }, ); }, ), Text('Saiba onde usar o seu', style: TextStyle(color: Colors.black, fontSize: 20),), Text('Cartão Pró Vantagens', style: TextStyle(color: Color.fromARGB(255, 30, 158, 8), fontSize: 30),), AspectRatio( aspectRatio: 1, child: Image.network( 'https://static.wixstatic.com/media/d170e1_80b5f6510f5841c19046f1ed5bca71e4~mv2.png/v1/fill/w_745,h_595,al_c,q_90,usm_0.66_1.00_0.01/Arte_Cart%C3%83%C2%B5es.webp', fit: BoxFit.fill, ), ), Divider(), Container( height: 150, child: Row( children: [ AspectRatio( aspectRatio: 1, child: Image.network( 'https://static.wixstatic.com/media/d170e1_486dd638987b4ef48d12a4bafee20e80~mv2.png/v1/fill/w_684,h_547,al_c,q_90,usm_0.66_1.00_0.01/Arte_Cart%C3%83%C2%B5es_2.webp', fit: BoxFit.fill, ), ), Padding( padding: const EdgeInsets.only(left:20.0), child: RichText( text: TextSpan(children: <TextSpan>[ TextSpan( text: 'Adquira já o seu', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, color: Colors.black, ), ), TextSpan( text: '\n\CARTÃO PRÓ VANTAGENS', style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, color: Color.fromARGB(255, 30, 158, 8)), ), ]), ), ), ], ), ), Divider(), tableBeneficios(), Divider(), Padding( padding: const EdgeInsets.all(16.0), child: Column( children: [ Text( 'O cartão Pró-Vantagens é sediado na cidade de Hortolândia/SP e já está no mercado há mais de 3 anos. Somos um time de profissionais apaixonados por gestão de benefícios e empenhados em gerar o máximo de valor para os conveniados.'), FlatButton( onPressed: () { launch( 'https://www.youtube.com/watch?v=VFnDo3JUzjs'); }, child: Text('SAIBA MAIS')), ], ), ), Container( color: Color.fromARGB(255, 105, 190, 90), child: Column( children: <Widget>[ Row( children: [ Padding( padding: const EdgeInsets.all(16), child: Text( '© 2020 todos os direitos reservados a Cartão Pró Vantagens.', style: TextStyle(fontSize: 10), ), ) ], ), Divider(), Row( children: [ Padding( padding: const EdgeInsets.all(16), child: Text( 'Rua Luís Camilo de Camargo, 175 -\n\Centro, Hortolândia (piso superior)', style: TextStyle(fontSize: 10), ), ), Padding( padding: const EdgeInsets.only(left: 16), child: IconButton( icon: Icon(CustomIcons.facebook), color: Colors.black, onPressed: () { launch( 'https://www.facebook.com/provantagens/'); }, ), ), Padding( padding: const EdgeInsets.only(left: 16), child: IconButton( icon: Icon(CustomIcons.instagram), color: Colors.black, onPressed: () { launch( 'https://www.instagram.com/cartaoprovantagens/'); }, ), ), ], ), ], ), ) ], ), ]); }, ) ), ); } tableBeneficios() { return Table( defaultColumnWidth: FlexColumnWidth(120.0), border: TableBorder( horizontalInside: BorderSide( color: Colors.black, style: BorderStyle.solid, width: 1.0, ), verticalInside: BorderSide( color: Colors.black, style: BorderStyle.solid, width: 1.0, ), ), children: [ _criarTituloTable(",Plus, Premium"), _criarLinhaTable("Seguro de vida\n\(Morte Acidental),X,X"), _criarLinhaTable("Seguro de Vida\n\(Qualquer natureza),,X"), _criarLinhaTable("Invalidez Total e Parcial,X,X"), _criarLinhaTable("Assistência Residencial,X,X"), _criarLinhaTable("Assistência Funeral,X,X"), _criarLinhaTable("Assistência Pet,X,X"), _criarLinhaTable("Assistência Natalidade,X,X"), _criarLinhaTable("Assistência Eletroassist,X,X"), _criarLinhaTable("Assistência Alimentação,X,X"), _criarLinhaTable("Descontos em Parceiros,X,X"), ], ); } _criarLinhaTable(String listaNomes) { return TableRow( children: listaNomes.split(',').map((name) { return Container( alignment: Alignment.center, child: RichText( text: TextSpan(children: <TextSpan>[ TextSpan( text: name != "X" ? '' : 'X', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, color: Colors.black, ), ), TextSpan( text: name != 'X' ? name : '', style: TextStyle( fontSize: 10.0, fontWeight: FontWeight.bold, color: Color.fromARGB(255, 30, 158, 8)), ), ]), ), padding: EdgeInsets.all(8.0), ); }).toList(), ); } _criarTituloTable(String listaNomes) { return TableRow( children: listaNomes.split(',').map((name) { return Container( alignment: Alignment.center, child: RichText( text: TextSpan(children: <TextSpan>[ TextSpan( text: name == "" ? '' : 'Plano ', style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, color: Colors.black, ), ), TextSpan( text: name, style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, color: Color.fromARGB(255, 30, 158, 8)), ), ]), ), padding: EdgeInsets.all(8.0), ); }).toList(), ); } void _storePosition(TapDownDetails details) { _tapPosition = details.globalPosition; } } ```
2020/11/13
[ "https://Stackoverflow.com/questions/64822800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14632998/" ]
I faced the same issue. This is how I solved it ``` class PlansPage extends StatefulWidget { const PlansPage({Key? key}) : super(key: key); @override State<PlansPage> createState() => _PlansPageState(); } class _PlansPageState extends State<PlansPage> { int _currentPage = 1; late CarouselController carouselController; @override void initState() { super.initState(); carouselController = CarouselController(); } } ``` Then put initialization the carouselController inside the initState method I was able to use the methods jumpToPage(\_currentPage ) and animateToPage(\_currentPage) etc. I use animateToPage inside GestureDetector in onTap. ``` onTap: () { setState(() { _currentPage = pageIndex; }); carouselController.animateToPage(_currentPage); }, ``` I apologize in advance if this is inappropriate.
I solved the similar problem as follows. You can take advantage of the Boolean variable. I hope, help you. ``` child: !loading ? HomeCarousel(homeManager) : Center(child:ProgressIndicator()), ``` or ``` child: isLoading ? HomeCarousel(homeManager) : SplashScreen(), ``` ``` class SplashScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Text('Loading...') ), ); } } ```
24,879,895
Could someone kindly point me to the right direction to seek further or give me any hints regarding the following task? I'd like to list all the distinct values from a MySQL table from column A that don't have a specific value in column B. I mean none of the same A values have this specific value in B in any of there rows. Taking the following table (let this specific value be 1): ``` column A | column B ---------------------- apple | apple | apple | 1 banana | anything banana | lemon | lemon | 1 orange | ``` I'd like to get the following result: ``` banana orange ``` Thanks.
2014/07/22
[ "https://Stackoverflow.com/questions/24879895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3863264/" ]
This might help you: ``` SELECT DISTINCT A FROM MY_TABLE WHERE A NOT IN (SELECT DISTINCT A FROM MY_TABLE WHERE B = 1) ```
Since there are null values, I have also added a nvl condition to column B . **ORACLE:** ``` SELECT DISTINCT COLUMN_A FROM MY_TABLE WHERE COLUMN_A NOT IN (SELECT COLUMN_A FROM MY_TABLE WHERE nvl(COLUMN_B,'dummy') = '1'); ``` **MYSQL:** ``` SELECT DISTINCT COLUMN_A FROM MY_TABLE WHERE COLUMN_A NOT IN (SELECT COLUMN_A FROM MY_TABLE WHERE IFNULL(COLUMN_B,'dummy') = '1'); ```
24,879,895
Could someone kindly point me to the right direction to seek further or give me any hints regarding the following task? I'd like to list all the distinct values from a MySQL table from column A that don't have a specific value in column B. I mean none of the same A values have this specific value in B in any of there rows. Taking the following table (let this specific value be 1): ``` column A | column B ---------------------- apple | apple | apple | 1 banana | anything banana | lemon | lemon | 1 orange | ``` I'd like to get the following result: ``` banana orange ``` Thanks.
2014/07/22
[ "https://Stackoverflow.com/questions/24879895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3863264/" ]
Since there are null values, I have also added a nvl condition to column B . **ORACLE:** ``` SELECT DISTINCT COLUMN_A FROM MY_TABLE WHERE COLUMN_A NOT IN (SELECT COLUMN_A FROM MY_TABLE WHERE nvl(COLUMN_B,'dummy') = '1'); ``` **MYSQL:** ``` SELECT DISTINCT COLUMN_A FROM MY_TABLE WHERE COLUMN_A NOT IN (SELECT COLUMN_A FROM MY_TABLE WHERE IFNULL(COLUMN_B,'dummy') = '1'); ```
``` SELECT * FROM your_Table WHERE Column_A NOT IN( SELECT Column_A FROM Your_Table WHERE Column_B = '1' ) ```
24,879,895
Could someone kindly point me to the right direction to seek further or give me any hints regarding the following task? I'd like to list all the distinct values from a MySQL table from column A that don't have a specific value in column B. I mean none of the same A values have this specific value in B in any of there rows. Taking the following table (let this specific value be 1): ``` column A | column B ---------------------- apple | apple | apple | 1 banana | anything banana | lemon | lemon | 1 orange | ``` I'd like to get the following result: ``` banana orange ``` Thanks.
2014/07/22
[ "https://Stackoverflow.com/questions/24879895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3863264/" ]
Since there are null values, I have also added a nvl condition to column B . **ORACLE:** ``` SELECT DISTINCT COLUMN_A FROM MY_TABLE WHERE COLUMN_A NOT IN (SELECT COLUMN_A FROM MY_TABLE WHERE nvl(COLUMN_B,'dummy') = '1'); ``` **MYSQL:** ``` SELECT DISTINCT COLUMN_A FROM MY_TABLE WHERE COLUMN_A NOT IN (SELECT COLUMN_A FROM MY_TABLE WHERE IFNULL(COLUMN_B,'dummy') = '1'); ```
This statement gives you the expected result: ``` select COLUMNA from myTable where COLUMNA not in (select distinct COLUMNA from myTable where columnB =1) group by COLUMNA; ```
24,879,895
Could someone kindly point me to the right direction to seek further or give me any hints regarding the following task? I'd like to list all the distinct values from a MySQL table from column A that don't have a specific value in column B. I mean none of the same A values have this specific value in B in any of there rows. Taking the following table (let this specific value be 1): ``` column A | column B ---------------------- apple | apple | apple | 1 banana | anything banana | lemon | lemon | 1 orange | ``` I'd like to get the following result: ``` banana orange ``` Thanks.
2014/07/22
[ "https://Stackoverflow.com/questions/24879895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3863264/" ]
This might help you: ``` SELECT DISTINCT A FROM MY_TABLE WHERE A NOT IN (SELECT DISTINCT A FROM MY_TABLE WHERE B = 1) ```
``` SELECT * FROM your_Table WHERE Column_A NOT IN( SELECT Column_A FROM Your_Table WHERE Column_B = '1' ) ```
24,879,895
Could someone kindly point me to the right direction to seek further or give me any hints regarding the following task? I'd like to list all the distinct values from a MySQL table from column A that don't have a specific value in column B. I mean none of the same A values have this specific value in B in any of there rows. Taking the following table (let this specific value be 1): ``` column A | column B ---------------------- apple | apple | apple | 1 banana | anything banana | lemon | lemon | 1 orange | ``` I'd like to get the following result: ``` banana orange ``` Thanks.
2014/07/22
[ "https://Stackoverflow.com/questions/24879895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3863264/" ]
This might help you: ``` SELECT DISTINCT A FROM MY_TABLE WHERE A NOT IN (SELECT DISTINCT A FROM MY_TABLE WHERE B = 1) ```
This statement gives you the expected result: ``` select COLUMNA from myTable where COLUMNA not in (select distinct COLUMNA from myTable where columnB =1) group by COLUMNA; ```
417,648
I've been using [Wakoopa](http://wakoopa.com) recently, and I find it quite amusing. I had no idea ( well I had an idea but never got real data about it ) on how much time I spend in SO until this: [alt text http://img396.imageshack.us/img396/4699/wakoopaim1.png](http://img396.imageshack.us/img396/4699/wakoopaim1.png) So my programming question is: > > *How can I programmatically track the applications being used?* > > > My initial though was to use something like "tasklist" command and "netstat" and pool every 15 minutes or something like that, but I don't think this is the way they're doing this. Is there a library in .NET ( in C# I guess ) to do this? Does windows provides some kind of service like this? What about java? I usually have at least some vague idea on how some programming task could be performed, but for this I don't have a clue. The wakoopa app tracker works on OSX and Linux too, but it is clear to me they are three different apps, one per platform BTW, how much do you used SO? :)
2009/01/06
[ "https://Stackoverflow.com/questions/417648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20654/" ]
Use a Javascript object literal: ``` var obj = { a: 1, b: 2, c: 'hello' }; ``` You can then traverse it like this: ``` for (var key in obj){ console.log(key, obj[key]); } ``` And access properties on the object like this: ``` console.log(obj.a, obj.c); ```
What you could do is something like: ``` var hash = {}; hash.a = 1; hash.b = 2; hash.c = 'hello'; for(key in hash) { // key would be 'a' and hash[key] would be 1, and so on. } ```
417,648
I've been using [Wakoopa](http://wakoopa.com) recently, and I find it quite amusing. I had no idea ( well I had an idea but never got real data about it ) on how much time I spend in SO until this: [alt text http://img396.imageshack.us/img396/4699/wakoopaim1.png](http://img396.imageshack.us/img396/4699/wakoopaim1.png) So my programming question is: > > *How can I programmatically track the applications being used?* > > > My initial though was to use something like "tasklist" command and "netstat" and pool every 15 minutes or something like that, but I don't think this is the way they're doing this. Is there a library in .NET ( in C# I guess ) to do this? Does windows provides some kind of service like this? What about java? I usually have at least some vague idea on how some programming task could be performed, but for this I don't have a clue. The wakoopa app tracker works on OSX and Linux too, but it is clear to me they are three different apps, one per platform BTW, how much do you used SO? :)
2009/01/06
[ "https://Stackoverflow.com/questions/417648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20654/" ]
Use a Javascript object literal: ``` var obj = { a: 1, b: 2, c: 'hello' }; ``` You can then traverse it like this: ``` for (var key in obj){ console.log(key, obj[key]); } ``` And access properties on the object like this: ``` console.log(obj.a, obj.c); ```
Goint off of Triptych's stuff (Which Thanks)... ```js (function(){ (createSingleton = function(name){ // global this[name] = (function(params){ for(var i in params){ this[i] = params[i]; console.log('params[i]: ' + i + ' = ' + params[i]); } return this; })({key: 'val', name: 'param'}); })('singleton'); console.log(singleton.key); })(); ``` Just thought this was a nice little autonomous pattern...hope it helps! Thanks Triptych!
417,648
I've been using [Wakoopa](http://wakoopa.com) recently, and I find it quite amusing. I had no idea ( well I had an idea but never got real data about it ) on how much time I spend in SO until this: [alt text http://img396.imageshack.us/img396/4699/wakoopaim1.png](http://img396.imageshack.us/img396/4699/wakoopaim1.png) So my programming question is: > > *How can I programmatically track the applications being used?* > > > My initial though was to use something like "tasklist" command and "netstat" and pool every 15 minutes or something like that, but I don't think this is the way they're doing this. Is there a library in .NET ( in C# I guess ) to do this? Does windows provides some kind of service like this? What about java? I usually have at least some vague idea on how some programming task could be performed, but for this I don't have a clue. The wakoopa app tracker works on OSX and Linux too, but it is clear to me they are three different apps, one per platform BTW, how much do you used SO? :)
2009/01/06
[ "https://Stackoverflow.com/questions/417648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20654/" ]
What you could do is something like: ``` var hash = {}; hash.a = 1; hash.b = 2; hash.c = 'hello'; for(key in hash) { // key would be 'a' and hash[key] would be 1, and so on. } ```
Goint off of Triptych's stuff (Which Thanks)... ```js (function(){ (createSingleton = function(name){ // global this[name] = (function(params){ for(var i in params){ this[i] = params[i]; console.log('params[i]: ' + i + ' = ' + params[i]); } return this; })({key: 'val', name: 'param'}); })('singleton'); console.log(singleton.key); })(); ``` Just thought this was a nice little autonomous pattern...hope it helps! Thanks Triptych!
10,281,370
> > **Possible Duplicate:** > > [Most efficient way to check if a file is empty in Java on Windows](https://stackoverflow.com/questions/7190618/most-efficient-way-to-check-if-a-file-is-empty-in-java-on-windows) > > > How to a check if a file is empty in Java 7? I tried it using the available() method from ObjectInputStream, but it returns always zero even if the the file contains data.
2012/04/23
[ "https://Stackoverflow.com/questions/10281370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/570339/" ]
``` File file = new File(path); boolean empty = file.exists() && file.length() == 0; ``` I want to stress that if we want to check if the file is empty, then we have to consider that it exists.
According to J2RE javadocs: <http://docs.oracle.com/javase/7/docs/api/java/io/File.html#length>() ``` public long length() Returns the length of the file denoted by this abstract pathname. The return value is unspecified if this pathname denotes a directory. ``` So `new File("path to your file").length() > 0` should do the trick. Sorry for bd previous answer. :(
10,281,370
> > **Possible Duplicate:** > > [Most efficient way to check if a file is empty in Java on Windows](https://stackoverflow.com/questions/7190618/most-efficient-way-to-check-if-a-file-is-empty-in-java-on-windows) > > > How to a check if a file is empty in Java 7? I tried it using the available() method from ObjectInputStream, but it returns always zero even if the the file contains data.
2012/04/23
[ "https://Stackoverflow.com/questions/10281370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/570339/" ]
``` File file = new File("file_path"); System.out.println(file.length()); ```
``` File file = new File("path.txt"); if (file.exists()) { FileReader fr = new FileReader(file); if (fr.read() == -1) { System.out.println("EMPTY"); } else { System.out.println("NOT EMPTY"); } } else { System.out.println("DOES NOT EXISTS"); } ```
10,281,370
> > **Possible Duplicate:** > > [Most efficient way to check if a file is empty in Java on Windows](https://stackoverflow.com/questions/7190618/most-efficient-way-to-check-if-a-file-is-empty-in-java-on-windows) > > > How to a check if a file is empty in Java 7? I tried it using the available() method from ObjectInputStream, but it returns always zero even if the the file contains data.
2012/04/23
[ "https://Stackoverflow.com/questions/10281370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/570339/" ]
``` File file = new File("file_path"); System.out.println(file.length()); ```
``` BufferedReader br = new BufferedReader(new FileReader("your_location")); if (br.readLine()) == null ) { System.out.println("No errors, and file empty"); } ``` see [Most efficient way to check if a file is empty in Java on Windows](https://stackoverflow.com/questions/7190618/most-efficient-way-to-check-if-a-file-is-empty-in-java-on-windows)
10,281,370
> > **Possible Duplicate:** > > [Most efficient way to check if a file is empty in Java on Windows](https://stackoverflow.com/questions/7190618/most-efficient-way-to-check-if-a-file-is-empty-in-java-on-windows) > > > How to a check if a file is empty in Java 7? I tried it using the available() method from ObjectInputStream, but it returns always zero even if the the file contains data.
2012/04/23
[ "https://Stackoverflow.com/questions/10281370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/570339/" ]
``` File file = new File("file_path"); System.out.println(file.length()); ```
``` File file = new File(path); boolean empty = file.exists() && file.length() == 0; ``` I want to stress that if we want to check if the file is empty, then we have to consider that it exists.
10,281,370
> > **Possible Duplicate:** > > [Most efficient way to check if a file is empty in Java on Windows](https://stackoverflow.com/questions/7190618/most-efficient-way-to-check-if-a-file-is-empty-in-java-on-windows) > > > How to a check if a file is empty in Java 7? I tried it using the available() method from ObjectInputStream, but it returns always zero even if the the file contains data.
2012/04/23
[ "https://Stackoverflow.com/questions/10281370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/570339/" ]
``` BufferedReader br = new BufferedReader(new FileReader("your_location")); if (br.readLine()) == null ) { System.out.println("No errors, and file empty"); } ``` see [Most efficient way to check if a file is empty in Java on Windows](https://stackoverflow.com/questions/7190618/most-efficient-way-to-check-if-a-file-is-empty-in-java-on-windows)
According to J2RE javadocs: <http://docs.oracle.com/javase/7/docs/api/java/io/File.html#length>() ``` public long length() Returns the length of the file denoted by this abstract pathname. The return value is unspecified if this pathname denotes a directory. ``` So `new File("path to your file").length() > 0` should do the trick. Sorry for bd previous answer. :(
10,281,370
> > **Possible Duplicate:** > > [Most efficient way to check if a file is empty in Java on Windows](https://stackoverflow.com/questions/7190618/most-efficient-way-to-check-if-a-file-is-empty-in-java-on-windows) > > > How to a check if a file is empty in Java 7? I tried it using the available() method from ObjectInputStream, but it returns always zero even if the the file contains data.
2012/04/23
[ "https://Stackoverflow.com/questions/10281370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/570339/" ]
``` File file = new File(path); boolean empty = !file.exists() || file.length() == 0; ``` which can shortened to: ``` boolean empty = file.length() == 0; ``` since according to documentation the method returns > > The length, in bytes, of the file denoted by this abstract pathname, or 0L if the file does not exist > > >
``` File file = new File(path); boolean empty = file.exists() && file.length() == 0; ``` I want to stress that if we want to check if the file is empty, then we have to consider that it exists.
10,281,370
> > **Possible Duplicate:** > > [Most efficient way to check if a file is empty in Java on Windows](https://stackoverflow.com/questions/7190618/most-efficient-way-to-check-if-a-file-is-empty-in-java-on-windows) > > > How to a check if a file is empty in Java 7? I tried it using the available() method from ObjectInputStream, but it returns always zero even if the the file contains data.
2012/04/23
[ "https://Stackoverflow.com/questions/10281370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/570339/" ]
``` BufferedReader br = new BufferedReader(new FileReader("your_location")); if (br.readLine()) == null ) { System.out.println("No errors, and file empty"); } ``` see [Most efficient way to check if a file is empty in Java on Windows](https://stackoverflow.com/questions/7190618/most-efficient-way-to-check-if-a-file-is-empty-in-java-on-windows)
``` File file = new File("path.txt"); if (file.exists()) { FileReader fr = new FileReader(file); if (fr.read() == -1) { System.out.println("EMPTY"); } else { System.out.println("NOT EMPTY"); } } else { System.out.println("DOES NOT EXISTS"); } ```
10,281,370
> > **Possible Duplicate:** > > [Most efficient way to check if a file is empty in Java on Windows](https://stackoverflow.com/questions/7190618/most-efficient-way-to-check-if-a-file-is-empty-in-java-on-windows) > > > How to a check if a file is empty in Java 7? I tried it using the available() method from ObjectInputStream, but it returns always zero even if the the file contains data.
2012/04/23
[ "https://Stackoverflow.com/questions/10281370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/570339/" ]
According to J2RE javadocs: <http://docs.oracle.com/javase/7/docs/api/java/io/File.html#length>() ``` public long length() Returns the length of the file denoted by this abstract pathname. The return value is unspecified if this pathname denotes a directory. ``` So `new File("path to your file").length() > 0` should do the trick. Sorry for bd previous answer. :(
``` File file = new File("path.txt"); if (file.exists()) { FileReader fr = new FileReader(file); if (fr.read() == -1) { System.out.println("EMPTY"); } else { System.out.println("NOT EMPTY"); } } else { System.out.println("DOES NOT EXISTS"); } ```
10,281,370
> > **Possible Duplicate:** > > [Most efficient way to check if a file is empty in Java on Windows](https://stackoverflow.com/questions/7190618/most-efficient-way-to-check-if-a-file-is-empty-in-java-on-windows) > > > How to a check if a file is empty in Java 7? I tried it using the available() method from ObjectInputStream, but it returns always zero even if the the file contains data.
2012/04/23
[ "https://Stackoverflow.com/questions/10281370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/570339/" ]
``` File file = new File(path); boolean empty = !file.exists() || file.length() == 0; ``` which can shortened to: ``` boolean empty = file.length() == 0; ``` since according to documentation the method returns > > The length, in bytes, of the file denoted by this abstract pathname, or 0L if the file does not exist > > >
``` File file = new File("path.txt"); if (file.exists()) { FileReader fr = new FileReader(file); if (fr.read() == -1) { System.out.println("EMPTY"); } else { System.out.println("NOT EMPTY"); } } else { System.out.println("DOES NOT EXISTS"); } ```
10,281,370
> > **Possible Duplicate:** > > [Most efficient way to check if a file is empty in Java on Windows](https://stackoverflow.com/questions/7190618/most-efficient-way-to-check-if-a-file-is-empty-in-java-on-windows) > > > How to a check if a file is empty in Java 7? I tried it using the available() method from ObjectInputStream, but it returns always zero even if the the file contains data.
2012/04/23
[ "https://Stackoverflow.com/questions/10281370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/570339/" ]
``` File file = new File(path); boolean empty = file.exists() && file.length() == 0; ``` I want to stress that if we want to check if the file is empty, then we have to consider that it exists.
``` File file = new File("path.txt"); if (file.exists()) { FileReader fr = new FileReader(file); if (fr.read() == -1) { System.out.println("EMPTY"); } else { System.out.println("NOT EMPTY"); } } else { System.out.println("DOES NOT EXISTS"); } ```
33,281,167
Following [this tutorial](http://www.wikihow.com/Create-a-Secure-Login-Script-in-PHP-and-MySQL) to create a safe login system, I came to this problem. In Part 7 of 8: Create HTML Pages, section 1 Create the login form (index.php), it uses: ``` <form action="includes/process_login.php" method="post" name="login_form"> ``` Although earlier on the tutorial it states (Part 3 of 8, section 1, first paragraph): > > In a production environment you'll probably want to locate this file > and all your other include files, outside of the web server's document > root. If you do that, and we strongly suggest that you do, you will > need to alter your include or require statements as necessary, so that > the application can find the include files. > > > So my includes folder is not inside /var/www/html/mysite/ or /var/www/html/, but in /var/www/, and my form became: ``` <form action="../../includes/process_login.php" method="post" name="login_form"> ``` (which works for the php includes). But this one don't work, I get this error: > > <http://localhost/includes/process_login.php> The requested URL > /includes/process\_login.php was not found on this server. > > > Why is it acting as if my includes was inside /var/www/html/ ? I checked all my /var/www/ folders using ``` grep -rnw . -e 'process_login.php' ``` and this is the only occurrence of that string (with the ../../). What am I missing?
2015/10/22
[ "https://Stackoverflow.com/questions/33281167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1086511/" ]
> > Anyway, I still want to understand why this is needed. > > > You have to understand that the html file is "executed" on the client side, meaning that if you link to something in the html file that is higher than the public folder (which the client perceives as root), the client cant reach it, as it is not available to the client. The client just cant send a request to a folder which is not made available to it by the web server. A php script however is executed on the server side, meaning it can access folders that are higher than the html perceived root. Basically: html thinks the root directory is the public folder, php thinks the root directory is the actual server root directory.
I found a workaround by including a file that just includes another, being the first in a public folder and the second in a hidden folder. The form: ``` <form action="process_login.php" method="post" name="login_form"> ``` First file (public\_folder/mysite/process\_login.php): ``` <?php include '../../includes/process_login.php'; ``` Second file (../../includes/process\_login.php): ``` <?php include_once 'db_connect.php'; include_once 'functions.php'; sec_session_start(); // Our custom secure way of starting a PHP session. if (isset($_POST['email'], $_POST['p'])) { $email = $_POST['email']; $pwd = $_POST['p']; // The hashed password. if (login($email, $pwd, $conn) == true) { // Login success header('Location: ../coisas/protected_page.php'); } else { // Login failed header('Location: ../coisas/index.php?error=1'); } } else { // The correct POST variables were not sent to this page. echo 'Invalid Request'; } ``` Anyway, I still want to understand why this is needed.
40,838
[`DMA`](http://www.valassis.com/by-industry/financial/banks-used-in-top-dmas.aspx?r=1) and `MMA` are commonly used to denote a large, metropolitan municipal entity. Is there a difference between the two? Is there a certified definition to these terms? Google is a bit inconclusive about the issue.
2012/11/11
[ "https://gis.stackexchange.com/questions/40838", "https://gis.stackexchange.com", "https://gis.stackexchange.com/users/382/" ]
If you look at the tool help you'll note that [Join Field](http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Join_Field/001700000065000000/) permanently adds 1 or more fields to the input table. The tool you probably want is [Add Join](http://help.arcgis.com/en/arcgisdesktop/10.0/help/0017/001700000064000000.htm), which works more like the interactive join command to create a temporary join. You'll probably want to use [Remove Join](http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Remove_Join/001700000066000000/) when you're done though to clean up after yourself.
In addition to blah238's answer, you should also use the [Add Attribute Index](http://resources.arcgis.com/en/help/main/10.1/index.html#//00170000005z000000) geoprocessing tool to create an index for the join. This tool accomplishes the same thing as this prompt: ![enter image description here](https://i.stack.imgur.com/odBli.jpg) This will greatly increase performance. Note that some read-only table file types (e.g. CSV) don't support attribute indices, so you'll have to export them to a .dbf file first.
40,838
[`DMA`](http://www.valassis.com/by-industry/financial/banks-used-in-top-dmas.aspx?r=1) and `MMA` are commonly used to denote a large, metropolitan municipal entity. Is there a difference between the two? Is there a certified definition to these terms? Google is a bit inconclusive about the issue.
2012/11/11
[ "https://gis.stackexchange.com/questions/40838", "https://gis.stackexchange.com", "https://gis.stackexchange.com/users/382/" ]
If you look at the tool help you'll note that [Join Field](http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Join_Field/001700000065000000/) permanently adds 1 or more fields to the input table. The tool you probably want is [Add Join](http://help.arcgis.com/en/arcgisdesktop/10.0/help/0017/001700000064000000.htm), which works more like the interactive join command to create a temporary join. You'll probably want to use [Remove Join](http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Remove_Join/001700000066000000/) when you're done though to clean up after yourself.
This has been reported to the ArcGIS Ideas forum here: <https://geonet.esri.com/ideas/8679> A python script to automate joining the fast way has been provided here: <http://www.arcgis.com/home/item.html?id=da1540fb59d84b7cb02627856f65a98d>
34,799,907
In my SQL Server stored procedures I want to do this: ``` "hello xxx how are you" ``` where `xxx` is a value of a variable I tried this ``` CREATE PROCEDURE insertToPinTable (@callerID VARCHAR (200), @vAccount VARCHAR (200)) AS BEGIN DECLARE @textEnglish VARCHAR textEnglish = CONCAT ( "hello", @vAccount) INSERT INTO pinData([CallerID], [body], [processed]) VALUES (@callerID, @textEnglish, 0) END ``` I get an error > > Incorrect syntax near 'textEnglish' > > > it seems that using `CONCAT` is not correct, could you help me please (if I can insert the value of vAccount to the `hello` word, then in the same way I can insert the value of textEnglish, to the string `how are you`)
2016/01/14
[ "https://Stackoverflow.com/questions/34799907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2038257/" ]
``` CREATE PROCEDURE insertToPinTable ( @callerID VARCHAR (200), @vAccount VARCHAR (200) ) AS BEGIN DECLARE @textEnglish VARCHAR(255) --missing length previously set @textEnglish = 'hello'+ @vAccount --missing set keyword INSERT INTO pinData([CallerID], [body], [processed]) VALUES (@callerID, @textEnglish, 0) END ```
If you just want to change a string from ``` "hello xxx how are you" ``` to ``` "hello Mr. Smith how are you" ``` You might think about place holder replacement: Define your string as a template: ``` DECLARE @template VARCHAR(100)='hello {Name} how are you?'; ``` And then use ``` SELECT REPLACE(@template,'{Name}','Mr. Smith'); ```
7,682,561
> > **Possible Duplicate:** > > [How to read a CSV line with "?](https://stackoverflow.com/questions/2139750/how-to-read-a-csv-line-with) > > > I have seen a number of related questions but none have directly addressed what I am trying to do. I am reading in lines of text from a CSV file. All the items are in quotes and some have additional commas within the quotes. I would like to split the line along commas, but ignore the commas within quotes. Is there a way to do this within Python that does not require a number of regex statements. An example is: ``` "114111","Planes,Trains,and Automobiles","50","BOOK" ``` which I would like parsed into 4 separate variables of values: ``` "114111" "Planes,Trains,and Automobiles" "50" "Book" ``` Is there a simple option in `line.split()` that I am missing ?
2011/10/07
[ "https://Stackoverflow.com/questions/7682561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/442158/" ]
Don't try to re-invent the wheel. If you want to read lines from a CSV file, use Python's [`csv` module](http://docs.python.org/dev/library/csv.html?highlight=csv#csv) from the standard library. **Example:** ``` > cat test.py import csv with open('some.csv') as f: reader = csv.reader(f) for row in reader: print(row) > cat some.csv "114111","Planes,Trains,and Automobiles","50","BOOK" > python test.py ['114111', 'Planes,Trains,and Automobiles', '50', 'BOOK'] [] ``` Job done!
You can probably split on "," that is "[quote][comma][quote]" the other option is coming up with an escape character, so if somebody wants to embed a comma in the string they do \c and if they want a backslash they do \\. Then you have to split the string, then unescape it before processing.
45,748,285
I'm trying to build a site where the user can first login anonymously using firebase and then convert his account to permanent by signing in with facebook. I'm following the instructions given at <https://firebase.google.com/docs/auth/web/anonymous-auth> but i'm getting the following error "Uncaught ReferenceError: response is not defined". I also tried converting the account using Google Sign in but then i get the error "googleUser is not defined". What am i doing wrong? This is my code:- ``` <html> <body> <button onclick = "anonymousLogin()">Anonymous Signin</butto> <button onclick = "facebookSignin()">Facebook Signin</button> <button onclick = "facebookSignout()">Facebook Signout</button> </body> <script> function anonymousLogin(){ firebase.auth().signInAnonymously().catch(function(error) { // Handle Errors here. var errorCode = error.code; console.log(errorCode) var errorMessage = error.message; console.log(errorMessage) }); } function facebookSignin() { var provider = new firebase.auth.FacebookAuthProvider(); var credential = firebase.auth.FacebookAuthProvider.credential( response.authResponse.accessToken); auth.currentUser.link(credential).then(function(user) { console.log("Anonymous account successfully upgraded", user); }, function(error) { console.log("Error upgrading anonymous account", error); }); } </script> </html> ```
2017/08/18
[ "https://Stackoverflow.com/questions/45748285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8481300/" ]
okay i found a solution. Apparently converting from anonymous to facebook user needs you to find the token yourself. I found this workaround. ``` var provider = new firebase.auth.FacebookAuthProvider(); firebase.auth().currentUser.linkWithPopup(provider) ```
I think `response` here refers to the event that Facebook login passes to the callback. [Facebook traditionally calls this `response`](https://developers.facebook.com/docs/facebook-login/web), but [our Github sample](https://github.com/firebase/quickstart-js/blob/master/auth/facebook-credentials.html#L81) calls it `events`. The name of course isn't important, but you're not declaring it for your callback. ``` function facebookSignin(response) { var provider = new firebase.auth.FacebookAuthProvider(); var credential = firebase.auth.FacebookAuthProvider.credential( response.authResponse.accessToken); ``` Also see <https://github.com/firebase/quickstart-js/blob/master/auth/facebook-credentials.html#L81>
298,305
How to do this in Java - passing a collection of subtype to a method requiring a collection of base type? The example below gives: ``` The method foo(Map<String,List>) is not applicable for the arguments (Map<String,MyList>) ``` I can implement by creating a class hierarchy for the typed collections - but is it possible otherwise? ``` public void testStackOverflow() { class MyList extends AbstractList { public Object get(int index) { return null; } public int size() { return 0; } }; Map <String, List> baseColl = null; Map <String, MyList> subColl = null; foo (subColl); } private void foo (Map <String, List> in) { } ``` EDIT: Turns out from the answers that this requires "bounded wildcard" so adding this text for searchability
2008/11/18
[ "https://Stackoverflow.com/questions/298305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2887/" ]
Change `foo` to: ``` private void foo(Map <String, ? extends List> in) { } ``` That will restrict what you can do within `foo`, but that's reasonable. You know that any value you fetch from the map will be a list, but you don't know what kind of value is valid to put into the map.
as jon s says: ``` private void foo (Map <String, ? extends List> in { ... } ``` will fix the errors. you will still have warnings though. take a look the get-put principle at: <http://www.ibm.com/developerworks/java/library/j-jtp07018.html>
15,713,080
I have a usecase for which I would like to know if HTML5's Server-sent-Events is suitable. Multiple clients (Javascript+HTML5 browsers) connect to the web server (with a Java EE backend). Each client could be looking at a different view at any time, depending on what is their object of interest. My **Question** is: How to keep multiple clients (on different views) up-to-date on the updates happening on the server-side, **without** flooding all clients with all updates on all views ? Important points that I need to consider are: 1. Many clients might be interested in the same events. If two clients are looking at the same view, they MUST get identical events. 2. Events to be sent to a client depend on the view that client is currently at. 3. Some clients may not be interested in any events (i.e they might be viewing static data) 4. A given client could be dynamically changing their interest. for ex: close View1 and open View2. 5. A client could be interested in multiple event channels (for ex: two dynamically-changing views could be part of a single page). 6. I can target only browsers with complete support for SSE. 7. There will only be a maximum of 100 clients (browsers) connected to the server at any time. So, I could have the luxury of having more than one connection open (for SSE), per client. I have searched SO/Google for SSE and couldnt (yet) get reliable solution for production quality software. I dont want to go back to old Comet techniques, before fully exploring SSE. Is SSE (by itself) capable of delivering on these requirements ? I am looking into Atmosphere right now, but I dont want to resort to some polyfill that imitates SSE, before deciding that SSE wont be sufficient by itself. **What I plan to do if this is not possible:** The server could broadcast all events to all clients and let the clients figure it out. This would mean, lots of unnecessary traffic from server to client and complex client code.
2013/03/29
[ "https://Stackoverflow.com/questions/15713080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1733060/" ]
Unless you can target a specific set of recent browsers you will always have to support some sort of fallback. [Atmosphere](https://github.com/Atmosphere/atmosphere) looks like a good solution for that. As to sending the right events to the right clients: Keep track of the clients and their preferences in either a Session object (check of Atmosphere is configured to support sessions) or your own Map. It looks like you can create multiple session broadcasters in Atmosphere as outlined here: <http://blog.javaforge.net/post/32659151672/atmosphere-per-session-broadcaster> Disclaimer: I've never used this myself.
What you could do is to send parameters via GET when you register an event with `EventSource`. The only problem lies at point #4, for which you should close the connection and re-register the event. I tried that myself and it works pretty well.
5,769,250
I'm using jQuery to show and hide various divs to paginate content. However, immediately after selecting an option that shows or hides the divs (for example, page 1, 2 or 3) and scrolls erratically up and down rather than let me scroll down the page. I have no idea at all what could be doing this, and having searched Stack Overflow and Google it doesn't appear to be a problem that anyone else has faced. Does anyone have advice on what could be causing this problem and how to rectify it?
2011/04/24
[ "https://Stackoverflow.com/questions/5769250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/701279/" ]
You're wanting to do an [svn switch](http://svnbook.red-bean.com/en/1.5/svn.ref.svn.c.switch.html) either via the command line or many SVN clients (i.e. Tortoise), expose this easily through the GUI. However, if you've deleted .svn folders (which help track the base version of files before modification), you may find you need to check out again.
you cant move folders like that in SVN. have you tried to recheck it out ? or you can delete the folder from the svn, and them move it to its parent, and delete the hidden "svn" folder in it, then commit it again .
14,059,704
I've been looking on Google for a solution to this, but I don't even know which words should I use to find it... Anyway, my problem is that Eclipse looks like this in Linux Mint 14 x64: <http://i.stack.imgur.com/BBfyg.png> I'm using Eclipse downloaded from their webpage, not from the repositories. I've tried resetting the perspective, deleting both the eclipse and workspace folders but it keeps looking like this. Any ideas? **EDIT** I finally managed to get rid of it. It looks like it had something to do with GTK. I changed the appearance to Classic in Preferences and it solved it.
2012/12/27
[ "https://Stackoverflow.com/questions/14059704", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1846142/" ]
Going to Window > Preferences > General > Appearance and changing the theme to Classic seems to solve the problem.
Changing the Eclipse Preferences from GTK to Classic did not work for me. Only the background of some Eclipse components get displayed in gray then which makes the visual corruptions less visible. Yet it helped to change the GTK theme in Linux Mint from "Mint-X" to "Adwaita", which also looks ok. So this could be a workaround. Update: This is a bit bug/issue/missing feature in the Mint-X theme which can easily be fixed manually. See <http://dentrassi.de/2013/04/23/fixing-the-mint-x-theme-for-eclipseswt/>
README.md exists but content is empty. Use the Edit dataset card button to edit it.
Downloads last month
0
Edit dataset card

Models trained or fine-tuned on tyson0420/stackexchange-4dpo-filby-clang-keywords