File tree Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -151,15 +151,23 @@ class _MessageListState extends State<MessageList> {
151151    });
152152  }
153153
154-   void  _scrollChanged () {
155-     final  scrollPosition =  scrollController.position;
156-     if  (scrollPosition.extentBefore ==  0 ) {
154+   void  _adjustButtonVisibility (ScrollMetrics  scrollMetrics) {
155+     if  (scrollMetrics.extentBefore ==  0 ) {
157156      _scrollToBottomVisibleValue.value =  false ;
158157    } else  {
159158      _scrollToBottomVisibleValue.value =  true ;
160159    }
161160  }
162161
162+   void  _scrollChanged () {
163+     _adjustButtonVisibility (scrollController.position);
164+   }
165+ 
166+   bool  _metricsChanged (ScrollMetricsNotification  scrollMetricsNotification) {
167+     _adjustButtonVisibility (scrollMetricsNotification.metrics);
168+     return  true ;
169+   }
170+ 
163171  @override 
164172  Widget  build (BuildContext  context) {
165173    assert (model !=  null );
@@ -180,15 +188,7 @@ class _MessageListState extends State<MessageList> {
180188            child:  ConstrainedBox (
181189              constraints:  const  BoxConstraints (maxWidth:  760 ),
182190              child:  NotificationListener <ScrollMetricsNotification >(
183-                 onNotification:  (scrollMetricsNotification) {
184-                   final  metrics =  scrollMetricsNotification.metrics;
185-                   if  (metrics.extentBefore ==  0 ) {
186-                     _scrollToBottomVisibleValue.value =  false ;
187-                   } else  {
188-                     _scrollToBottomVisibleValue.value =  true ;
189-                   }
190-                   return  true ;
191-                 },
191+                 onNotification:  _metricsChanged,
192192                child:  Stack (
193193                  children:  < Widget > [
194194                    _buildListView (context),
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments